You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
🐛 Fix the nominee list preview while nominations are open - #3095
While nominations are open the nominee list showed the nominations of you, from every election ever, rather than the people you nominated in the election you were looking at. It now shows both, scoped to that election.
Nominee.visible() also gains the nominator case, otherwise the links in that list 404 for everyone except staff and the nominee.
jefftriplett
changed the title
Fix the nominee list preview while nominations are open
🐛 Fix the nominee list preview while nominations are open
Aug 14, 2026
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR fixes the nominee list “preview” behavior during an open nominations window by scoping results to the election in the URL and including nominees relevant to the logged-in user (people they nominated, plus themselves if nominated). It also expands nominee visibility rules so nominators can open nominee detail pages without hitting a 404, and adds tests to prevent regressions.
Changes:
Update NomineeList.get_queryset() to filter nominees by the current election and include both “nominated by me” and “I was nominated” cases.
Update Nominee.visible() to allow access for authenticated nominators during the nomination window.
Add view tests covering preview scoping and nominee-detail visibility for nominators vs. other users.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
File
Description
apps/nominations/views.py
Fixes NomineeList preview queryset to include relevant nominees and scope by election (uses Q(...) + distinct()).
apps/nominations/models.py
Expands Nominee.visible() to include nominators and handles unauthenticated users explicitly.
apps/nominations/tests/test_views.py
Adds regression tests for nominee list preview behavior and nominee detail access for nominators.
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.
Suppressed comments (2)
apps/nominations/views.py:88
get_queryset() returns None for anonymous users when nominations aren't complete. Django ListView expects an iterable/queryset; returning an explicit empty queryset avoids edge cases (e.g., pagination/allow_empty checks) and keeps the intent clear.
return None
apps/nominations/models.py:256
Nominee.visible() now grants access to any nominator regardless of whether the nomination window is still open. That means a nominator who knows the URL could view a nominee page after nominations close even if the nominee is not accepted/approved yet. If the intent is only to make the nominee-list preview links work while nominations are open, gate this case on self.election.nominations_open.
# A nominator can see the person they nominated, so that the links
# in the nominee list preview work while nominations are open.
return self.nominations.filter(nominator=user).exists()
Restrict nomination access after the nomination window closes
apps/nominations/models.py:256
This grants a nominator access even after the nomination window closes, including for nominees whose nominations were never accepted or approved. The list switches to only accepted/approved nominees after close, so the detail permission should limit this new exception to the open-window preview (or otherwise apply the same publication rules); add an self.election.nominations_open check here.
🧠 Review effort: Lite
Give feedback about Copilot approvals in this survey to enter a drawing for a $150 gift card.
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
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 #3094.
While nominations are open the nominee list showed the nominations of you, from every election ever, rather than the people you nominated in the election you were looking at. It now shows both, scoped to that election.
Nominee.visible()also gains the nominator case, otherwise the links in that list 404 for everyone except staff and the nominee.