From 683245022139a4121829470ae4534e7a5bf594cf Mon Sep 17 00:00:00 2001 From: Roberto Rosario Date: Sun, 9 Dec 2018 14:59:59 -0400 Subject: [PATCH] Generic forms: Don't raise, display exceptions Update the generic single object create and edit views to display critical exceptions instead of just raising them and stoping execution. The should allow removing duplicated exception to message code in subclasses of these views. Signed-off-by: Roberto Rosario --- mayan/apps/common/generics.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/mayan/apps/common/generics.py b/mayan/apps/common/generics.py index 0a4b97a5d3..322a39ac75 100644 --- a/mayan/apps/common/generics.py +++ b/mayan/apps/common/generics.py @@ -355,6 +355,9 @@ class SingleObjectCreateView(ObjectNameMixin, ViewPermissionCheckMixin, ExtraCon 'error': exception } ) + return super( + SingleObjectCreateView, self + ).form_invalid(form=form) else: context = self.get_context_data() @@ -452,8 +455,9 @@ class SingleObjectEditView(ObjectNameMixin, ViewPermissionCheckMixin, ObjectPerm 'error': exception } ) - - raise exception + return super( + SingleObjectEditView, self + ).form_invalid(form=form) else: messages.success( self.request,