From 5932aad9fa3b9d09c4b7b2fea7d5e6d5a7ef1f48 Mon Sep 17 00:00:00 2001 From: Krophil Date: Sun, 12 Mar 2017 20:33:17 +0100 Subject: [PATCH] Improve journal removing --- accounting/views.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/accounting/views.py b/accounting/views.py index 8ea2c3c1..51808632 100644 --- a/accounting/views.py +++ b/accounting/views.py @@ -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