Improve journal removing

This commit is contained in:
Pierre Brunet 2017-03-12 20:33:17 +01:00
parent 5f9ec9a2ab
commit 5932aad9fa

View File

@ -239,6 +239,12 @@ class JournalDeleteView(CanEditPropMixin, DeleteView):
template_name = 'core/delete_confirm.jinja'
success_url = reverse_lazy('accounting:club_details')
def dispatch(self, request, *args, **kwargs):
self.object = self.get_object()
if self.object.operations.count() == 0:
return super(JournalDeleteView, self).dispatch(request, *args, **kwargs)
else:
raise PermissionDenied
# Operation views