Skip to content

Second Elections PR#105

Merged
p-north merged 27 commits into
mainfrom
dev-elections-2
Aug 25, 2025
Merged

Second Elections PR#105
p-north merged 27 commits into
mainfrom
dev-elections-2

Conversation

@EarthenSky
Copy link
Copy Markdown
Collaborator

@EarthenSky EarthenSky commented Apr 11, 2025

For #25

Finalize elections backend. Support self-registration & return speeches from GET elections/by_name/{slug} endpoint

TODOs:

  • test every endpoint at least once
  • add more examples to the test db

@EarthenSky
Copy link
Copy Markdown
Collaborator Author

@gunmack I've added 7 more API endpoints, which handle uploading personal info & registering in elections. This should be everything we need for the elections pages!

It now also returns speeches and personal info for a person. There are a reasonable number of special cases, but the important ones are as follows:

  • you can only register, or modify/delete your registration for an election during the nomination period
  • registration will be rejected if you have not first provided nominee info. This means that, after logging into the website through SFU's authentication, a user will have to provide their legal name in order to register (if they have not already done so).

You may want to read the code in this PR to see what format the data will be returned as, but I can help clarify as well, so feel free to ask me any questions!

whew

@p-north p-north removed the request for review from gunmack August 19, 2025 23:52
@p-north p-north self-assigned this Aug 19, 2025
@p-north p-north requested a review from jbriones1 August 19, 2025 23:53
@p-north p-north marked this pull request as ready for review August 19, 2025 23:54
@p-north
Copy link
Copy Markdown
Contributor

p-north commented Aug 19, 2025

-Finalized the election backend, added various integration tests. Cleaned up API endpoints as many had syntactic errors and bugs
-All test cases have passed according to pytest.
image

@p-north p-north added documentation Improvements or additions to documentation new feature an enhancement labels Aug 20, 2025
Copy link
Copy Markdown
Contributor

@jbriones1 jbriones1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some questions and suggestions.

Comment thread src/alembic/versions/243190df5588_create_election_tables.py
Comment thread src/alembic/versions/243190df5588_create_election_tables.py Outdated
Comment thread src/alembic/versions/243190df5588_create_election_tables.py
Comment thread src/elections/crud.py
Comment thread src/elections/crud.py
Comment thread src/elections/urls.py Outdated
Comment thread src/elections/urls.py Outdated
Comment thread src/officers/constants.py
Comment thread tests/integration/test_elections.py
Comment thread tests/integration/test_elections.py Outdated
@p-north
Copy link
Copy Markdown
Contributor

p-north commented Aug 21, 2025

Updated election endpoints as per suggestion.

image

@p-north p-north requested review from Copilot and jbriones1 August 21, 2025 21:43

This comment was marked as outdated.

@p-north p-north requested a review from Copilot August 22, 2025 19:19
@p-north
Copy link
Copy Markdown
Contributor

p-north commented Aug 22, 2025

-Update: deprecated the update_registration endpoint as no longer required.

Copy link
Copy Markdown

Copilot AI left a comment

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 finalizes the elections backend by implementing election management features including self-registration for candidates and returning speeches from election details endpoints. The changes add comprehensive CRUD operations for elections, nominee registrations, and nominee information management.

Key changes:

  • Adds complete test coverage for all election endpoints with both authorized and unauthorized access scenarios
  • Updates database schema to support available positions per election and nominee information storage
  • Implements full election API with creation, updating, deletion, and candidate registration endpoints

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
tests/integration/test_elections.py Comprehensive integration tests for all election endpoints
src/officers/constants.py Defines position constants for different election types
src/load_test_db.py Updates test data with nominee info and election positions
src/elections/urls.py Complete election API implementation with registration and nominee info endpoints
src/elections/tables.py Updated database schema with nominee info and application tables
src/elections/crud.py CRUD operations for elections, registrations, and nominee information
src/alembic/versions/46d14891e1a9_elections.py Empty migration file
src/alembic/versions/243190df5588_create_election_tables.py Database migration for election tables

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread src/elections/urls.py Outdated
Comment thread src/elections/urls.py Outdated
Comment thread src/elections/urls.py Outdated
Comment thread src/elections/urls.py Outdated
Comment thread src/elections/urls.py Outdated
Comment thread src/alembic/versions/46d14891e1a9_elections.py Outdated
Copy link
Copy Markdown
Contributor

@jbriones1 jbriones1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few questions about commented out code, but overall looks good

Comment thread tests/integration/test_elections.py Outdated
Comment thread tests/integration/test_elections.py Outdated
@p-north p-north requested a review from jbriones1 August 25, 2025 00:57
Copy link
Copy Markdown
Contributor

@jbriones1 jbriones1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only one real change requested (urls.py line 477-481), others are suggestions or comments.

Comment thread src/elections/urls.py
Comment thread src/elections/urls.py Outdated
Comment thread tests/integration/test_elections.py
Comment thread tests/integration/test_elections.py
@p-north p-north requested a review from jbriones1 August 25, 2025 17:53
Copy link
Copy Markdown
Contributor

@jbriones1 jbriones1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! Thank you for the changes to the endpoint names, it makes the autogenerated Angular services way less verbose.

@p-north p-north merged commit ddd5c4a into main Aug 25, 2025
3 checks passed
@p-north p-north deleted the dev-elections-2 branch August 25, 2025 19:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation new feature an enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants