Reject adding a person to two ballots from the same election#2756
Open
c-tonneslan wants to merge 1 commit into
Open
Reject adding a person to two ballots from the same election#2756c-tonneslan wants to merge 1 commit into
c-tonneslan wants to merge 1 commit into
Conversation
The person edit form's membership formset let you add the same person to two ballots in the same election (e.g. two wards on the same date), which then 500'd downstream and had to be unstuck via the admin. Cross-validate on the formset's clean() and reject the second entry with a useful error pointing at the conflicting ballot. Closes DemocracyClub#2685 Signed-off-by: Charlie Tonneslan <cst0520@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #2685.
@pmk01 reported that the person edit form let you add the same person to two ballots in the same organisation, which then 500'd and had to be unstuck through the admin. @chris48s asked for validation up-front.
Added a
cleanonMembershipFormSetthat walks the non-deleted forms, collects their ballots, and rejects any pair that share anelection_id(so two wards on the same council on the same date, the canonical case). Error is attached to the secondballot_paper_idfield and names the conflicting ballot so it's clear what to remove.Test goes through the formset directly with two sibling ballots (
dulwich_post_ballotandcamberwell_post_ballot, both attached to the existing UK examples' election fixture).