Repository navigation
Conversation
POST /admin/campaign/<id>/cancel called CoordinatorDAO.cancel_campaign(), which only existed on OrganizerDAO, so every call was a 500. Move the logic to CoordinatorDAO.cancel_campaign() and let OrganizerDAO delegate to it, so there is one implementation. The endpoint now returns the campaign id, its status and how many rounds were cancelled. A campaign with a finalized round can no longer be cancelled (400): it has results, so it is closed instead (finalized with a report, or archived). Rounds that are already cancelled are left as they are. If the rounds to cancel have completed votes, which would no longer count, the cancel is refused with a warning unless the request sets discard_completed (the same flag remove_juror uses). tools/admin.py passed the campaign object where OrganizerDAO expects an id; pass the id, mention the votes in its confirmation prompt, and print the number of rounds actually cancelled. Adds a regression test (a 500 before the fix; a non-coordinator gets 403; completed votes need discard_completed; an earlier cancelled round is untouched) and extends test_home_client (cancel refused once finalized, and still refused after reopening). Fixes #675. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.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.
Fixes #675.
POST /admin/campaign/<id>/cancelcalledCoordinatorDAO.cancel_campaign(), which didn't exist, so it was always a 500. The logic now lives onCoordinatorDAO.cancel_campaign(), andOrganizerDAO.cancel_campaign()delegates to it: one implementation. The endpoint returns{id, status, cancelled_rounds}.discard_completed: truecancels anyway. This is the same flagremove_juroruses for discarding a juror's completed votes. Votes are not deleted: they keep their status and values, and their round is cancelled.tools/admin.py cancelnow passes the campaign id, which is whatOrganizerDAO.cancel_campaign()expects, mentions the votes in its yes/no prompt, and prints the number of rounds it actually cancelled.Permissions are unchanged:
CoordinatorDAO.from_campaignallows the campaign's coordinators and maintainers; others get 403. Cancelling a single finalized round through/admin/round/<id>/cancelis still allowed, as before; that is left for a separate decision.Tests
test_coordinator_cancels_campaign: a coordinator cancels a campaign with one active round and one round cancelled earlier; after one vote, a cancel withoutdiscard_completedis refused with the warning and the round stays active; with it, the active round is cancelled with no open tasks left, the earlier round keeps its close date, andcancelled_roundsis 1; a juror who isn't a coordinator gets 403. It fails on master with the 500.test_home_clientnow also checks that a finalized campaign can't be cancelled, also not after reopening it, and that its rounds stay finalized.tools/admin.pyitself (it needs a database).Written by Claude (Claude Code) on behalf of @lgelauff.
🤖 Generated with Claude Code