Skip to content

Reject adding a person to two ballots from the same election#2756

Open
c-tonneslan wants to merge 1 commit into
DemocracyClub:masterfrom
c-tonneslan:fix/reject-duplicate-election-memberships
Open

Reject adding a person to two ballots from the same election#2756
c-tonneslan wants to merge 1 commit into
DemocracyClub:masterfrom
c-tonneslan:fix/reject-duplicate-election-memberships

Conversation

@c-tonneslan
Copy link
Copy Markdown

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 clean on MembershipFormSet that walks the non-deleted forms, collects their ballots, and rejects any pair that share an election_id (so two wards on the same council on the same date, the canonical case). Error is attached to the second ballot_paper_id field and names the conflicting ballot so it's clear what to remove.

Test goes through the formset directly with two sibling ballots (dulwich_post_ballot and camberwell_post_ballot, both attached to the existing UK examples' election fixture).

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Can add person to multiple ballots in same organisation; throws a 500

1 participant