Skip to content

Election pages #88

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 9 commits into
base: main
Choose a base branch
from
Draft

Election pages #88

wants to merge 9 commits into from

Conversation

gunmack
Copy link
Contributor

@gunmack gunmack commented Mar 12, 2025

Thought I'd make a draft of what I have so far:

image

  • Some background on elections and links to register and vote (they dont point anywhere else, yet)

image

  • List of past election info

@gunmack gunmack marked this pull request as draft March 12, 2025 03:13
@gunmack gunmack requested a review from EarthenSky March 12, 2025 03:13
@gunmack
Copy link
Contributor Author

gunmack commented Mar 12, 2025

  • From what I understand, I should be calling the backend urls which will respond with data from the database. Also same logic for sending data to the backend.

  • I tried running the FastAPI app and then calling it from the frontend but I kept getting blocked by CORS. Assuming there's a specific way it's all set up.

  • Also, about using mock data; do I load a test database with the Election tables and add mock data to that? or did you mean something else?

@EarthenSky
Copy link
Contributor

This looks awesome so far!

From what I understand, I should be calling the backend urls which will respond with data from the database. Also same logic for sending data to the backend.

100%! I have a list of API endpoints from sean's PR, which I'll be adding to. But if you feel that an endpoint should exist, feel free to assume it exists & ask me for it.

I tried running the FastAPI app and then calling it from the frontend but I kept getting blocked by CORS. Assuming there's a specific way it's all set up.

Oh heck. There's a configuration in webpack that should address this issue if I recall correctly. I hope this isn't related to what you mentioned before about your ubuntu version not working nicely with webpack... I'll look into this & update you if I find anything!

Also, about using mock data; do I load a test database with the Election tables and add mock data to that? or did you mean something else?

For developing the backend, I'll be loading the database with mock data for my own testing. For developing the frontend, you'll want to write functions that don't actually make any web requests, but which respond with up-to-date data.

The idea is that your mock data will be pretty low effort & you'll be able to confirm most of the behaviour of the application without being blocked by the backend working. After the backend is working, I'll have loaded some mock data into the db for testing, with which you can actually introduce the API calls.

Copy link
Contributor

@EarthenSky EarthenSky left a comment

Choose a reason for hiding this comment

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

lgtm!

@gunmack
Copy link
Contributor Author

gunmack commented Mar 16, 2025

So I got some JSON data from chat gpt and I tried to use the fields as specified in the database schema

  • Title of each election is also stored as a slug
  • The titles are displayed in a list

image

  • Tried to replicate the old website
  • For the JSON fields, had to add a Position field(s) inside each election ( I didn't see a positions field in the schema )
  • TODO: add a field to store candidate's social media links

image

Snippets from the JSON file

image

image

@gunmack gunmack requested a review from EarthenSky March 16, 2025 09:56
Copy link
Contributor

@EarthenSky EarthenSky left a comment

Choose a reason for hiding this comment

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

Sorry for the delay in reviewing! Feel free to annoy me and I'll happily throw you a review.

The pages all look really nice! The only important change is that multiple elections can be registered for at the same time.

An fyi that speeches will eventually be stored in html, but that's a problem for future us :)

if (userInfoStr) {
setUserInfo(JSON.parse(userInfoStr));
}
}, 100); // 100ms to let Page load login info
Copy link
Contributor

Choose a reason for hiding this comment

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

what's this 100ms wait for? I'd assume session storage doesn't need a timeout to be accessed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I copied it from the Profile page lol. Regardless, it's not needed here because the /register page also deals with that. I'll remove it.

@@ -25,7 +29,8 @@ const router = createHashRouter([

{ path: '/about_elections', element: <AboutElections /> },
{ path: '/past_elections', element: <PastElections /> },
{ path: '/past_elections/:slug', element: <ElectionInfo /> }
{ path: '/past_elections/:slug', element: <ElectionInfo /> },
{ path: '/register', element: <Register /> }
Copy link
Contributor

Choose a reason for hiding this comment

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

It's possible for multiple elections to exist at once. Right now there's actually the general & sfss council rep elections going on. Could we make it so that registering is elections/:slug/register?

In this case, we'd also want to change the URL from /past_elections/ to /elections/.

The backend will deal with the complexity of there being multiple elections run at once; you should just have to call the endpoints using the current election's slug.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think you reviewed outdated files. I already implemented the changes you suggested lol.

Copy link
Contributor Author

@gunmack gunmack Mar 29, 2025

Choose a reason for hiding this comment

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

so when the frontend calls for old election data, assuming the backend will sort elections in order and only send previous elections? Because I added some extra booleans in the json data to mimic that ( just for testing).

Will the endpoint only send previous elections or will it also include currently in progress ones?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's possible for multiple elections to exist at once. Right now there's actually the general & sfss council rep elections going on. Could we make it so that registering is elections/:slug/register?

Should this be linked through the list of elections? Like the list that contains old elections will also contain the currently in progress ones, but only let users register when they click on them?

Copy link
Contributor

Choose a reason for hiding this comment

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

Will the endpoint only send previous elections or will it also include currently in progress ones?

Up to you! You can give me whatever requests you think are easiest. I'd imagine we include all elections, including in-progress ones. However, we'd probably include a property in the json that says what stage an election is at (ended, voting, registration) so the frontend can display the information however you wish.

Copy link
Contributor

Choose a reason for hiding this comment

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

only let users register when they click on them?

there will be a backend endpoint that looks something like POST /api/elections/:slug/register, and a frontend page /elections/:slug/register

I imagine that when someone navigates to the election page /elections/:slug/register you first check the endpoint GET /api/elections/:slug/info, then display "sorry this election is no longer accepting nominations" if the election is no longer in the registration period. The result of the info endpoint will say what the status of the election is.

added some mock elections to implement
registration
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.

2 participants