Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: avoid double validation of submit form #834

Merged
merged 4 commits into from
Jan 8, 2025
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion proposals/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works surprisingly well, but I would much rather have a test like

"proposals/submit" in error["url"].lower()"

The URL just feels a lot more dependable.

return
self.add_error(
None,
_("Aanvraag bevat nog foutmeldingen"),
Expand Down
Loading