Skip to content

🐛 Fix the nominee list preview while nominations are open - #3095

Open
jefftriplett wants to merge 2 commits into
mainfrom
fix-nominee-list-preview
Open

🐛 Fix the nominee list preview while nominations are open#3095
jefftriplett wants to merge 2 commits into
mainfrom
fix-nominee-list-preview

Conversation

@jefftriplett

Copy link
Copy Markdown
Member

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.

Copilot AI lite review requested due to automatic review settings August 14, 2026 01:14
@jefftriplett 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

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread apps/nominations/views.py
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings August 14, 2026 12:53

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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()

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.

Bug: Nominee list shows nominations of you, not nominations you made, and ignores the election

2 participants