From bf72a7a1f3eed12f0844fd7e7b008e5f4e7746f2 Mon Sep 17 00:00:00 2001 From: Edo Storm Date: Mon, 6 Jan 2025 16:06:01 +0100 Subject: [PATCH 1/3] fix: avoid double validation of submit form --- proposals/forms.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/proposals/forms.py b/proposals/forms.py index 626c2ae6..73e363f9 100644 --- a/proposals/forms.py +++ b/proposals/forms.py @@ -880,7 +880,14 @@ def clean(self): from proposals.utils.stepper import Stepper validator = Stepper(self.instance, request=self.request) - if validator.get_form_errors(): + + form_errors = validator.get_form_errors() + + if form_errors: + #If there are only errors on the submit form, we override this + #validation. Otherwise saving the updated data becomes impossible + if len(form_errors) == 1 and form_errors[0]["page_name"] == _("Indienen"): + return self.add_error( None, _("Aanvraag bevat nog foutmeldingen"), From 712a4917e1168602ead7ecd1a564a18c568f6324 Mon Sep 17 00:00:00 2001 From: Edo Storm Date: Mon, 6 Jan 2025 16:09:04 +0100 Subject: [PATCH 2/3] style: black --- proposals/forms.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/proposals/forms.py b/proposals/forms.py index 73e363f9..9eecf162 100644 --- a/proposals/forms.py +++ b/proposals/forms.py @@ -884,8 +884,8 @@ def clean(self): form_errors = validator.get_form_errors() if form_errors: - #If there are only errors on the submit form, we override this - #validation. Otherwise saving the updated data becomes impossible + # If there are only errors on the submit form, we override this + # validation. Otherwise saving the updated data becomes impossible if len(form_errors) == 1 and form_errors[0]["page_name"] == _("Indienen"): return self.add_error( From aded79e8ca7b53c6e549a68a81064f940b4a2ce3 Mon Sep 17 00:00:00 2001 From: Edo Storm Date: Wed, 8 Jan 2025 10:10:40 +0100 Subject: [PATCH 3/3] fix: submit validation error check for url instead of page --- proposals/forms.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/proposals/forms.py b/proposals/forms.py index 9eecf162..a9ba0a4f 100644 --- a/proposals/forms.py +++ b/proposals/forms.py @@ -886,7 +886,7 @@ def clean(self): if form_errors: # If there are only errors on the submit form, we override this # validation. Otherwise saving the updated data becomes impossible - if len(form_errors) == 1 and form_errors[0]["page_name"] == _("Indienen"): + if len(form_errors) == 1 and "proposals/submit" in form_errors[0]["url"]: return self.add_error( None,