Skip to content

Commit 9a69613

Browse files
committed
deprecate update_registration endpoints
1 parent 9ffd823 commit 9a69613

File tree

2 files changed

+66
-66
lines changed

2 files changed

+66
-66
lines changed

src/elections/urls.py

Lines changed: 50 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -430,55 +430,55 @@ async def register_in_election(
430430
))
431431
await db_session.commit()
432432

433-
@router.patch(
434-
"/registration/{election_name:str}",
435-
description="update your speech for a specific position for an election"
436-
)
437-
async def update_registration(
438-
request: Request,
439-
db_session: database.DBSession,
440-
election_name: str,
441-
position: str,
442-
speech: str | None,
443-
):
444-
logged_in, _, computing_id = await is_logged_in(request, db_session)
445-
if not logged_in:
446-
raise HTTPException(
447-
status_code=status.HTTP_401_UNAUTHORIZED,
448-
detail="must be logged in to update election registration"
449-
)
450-
elif position not in OfficerPosition.position_list():
451-
raise HTTPException(
452-
status_code=status.HTTP_400_BAD_REQUEST,
453-
detail=f"invalid position {position}"
454-
)
455-
456-
current_time = datetime.now()
457-
slugified_name = _slugify(election_name)
458-
election = await elections.crud.get_election(db_session, slugified_name)
459-
if election is None:
460-
raise HTTPException(
461-
status_code=status.HTTP_404_NOT_FOUND,
462-
detail=f"election with slug {slugified_name} does not exist"
463-
)
464-
elif election.status(current_time) != elections.tables.STATUS_NOMINATIONS:
465-
raise HTTPException(
466-
status_code=status.HTTP_400_BAD_REQUEST,
467-
detail="speeches can only be updated during the nomination period"
468-
)
469-
elif not await elections.crud.get_all_registrations(db_session, computing_id, slugified_name):
470-
raise HTTPException(
471-
status_code=status.HTTP_404_NOT_FOUND,
472-
detail="you are not yet registered in this election"
473-
)
474-
475-
await elections.crud.update_registration(db_session, NomineeApplication(
476-
computing_id=computing_id,
477-
nominee_election=slugified_name,
478-
position=position,
479-
speech=speech
480-
))
481-
await db_session.commit()
433+
# @router.patch(
434+
# "/registration/{election_name:str}",
435+
# description="update your speech for a specific position for an election"
436+
# )
437+
# async def update_registration(
438+
# request: Request,
439+
# db_session: database.DBSession,
440+
# election_name: str,
441+
# position: str,
442+
# speech: str | None,
443+
# ):
444+
# logged_in, _, computing_id = await is_logged_in(request, db_session)
445+
# if not logged_in:
446+
# raise HTTPException(
447+
# status_code=status.HTTP_401_UNAUTHORIZED,
448+
# detail="must be logged in to update election registration"
449+
# )
450+
# elif position not in OfficerPosition.position_list():
451+
# raise HTTPException(
452+
# status_code=status.HTTP_400_BAD_REQUEST,
453+
# detail=f"invalid position {position}"
454+
# )
455+
456+
# current_time = datetime.now()
457+
# slugified_name = _slugify(election_name)
458+
# election = await elections.crud.get_election(db_session, slugified_name)
459+
# if election is None:
460+
# raise HTTPException(
461+
# status_code=status.HTTP_404_NOT_FOUND,
462+
# detail=f"election with slug {slugified_name} does not exist"
463+
# )
464+
# elif election.status(current_time) != elections.tables.STATUS_NOMINATIONS:
465+
# raise HTTPException(
466+
# status_code=status.HTTP_400_BAD_REQUEST,
467+
# detail="speeches can only be updated during the nomination period"
468+
# )
469+
# elif not await elections.crud.get_all_registrations(db_session, computing_id, slugified_name):
470+
# raise HTTPException(
471+
# status_code=status.HTTP_404_NOT_FOUND,
472+
# detail="you are not yet registered in this election"
473+
# )
474+
475+
# await elections.crud.update_registration(db_session, NomineeApplication(
476+
# computing_id=computing_id,
477+
# nominee_election=slugified_name,
478+
# position=position,
479+
# speech=speech
480+
# ))
481+
# await db_session.commit()
482482

483483
@router.delete(
484484
"/registration/{election_name:str}/{position:str}",
@@ -616,4 +616,4 @@ async def provide_nominee_info(
616616

617617

618618
nominee_info = await elections.crud.get_nominee_info(db_session, computing_id)
619-
return JSONResponse(nominee_info.as_serializable())
619+
return JSONResponse(nominee_info.as_serializable())

tests/integration/test_elections.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -149,11 +149,11 @@ async def test_endpoints(client, database_setup):
149149
})
150150
assert response.status_code == 401
151151

152-
response = await client.patch(f"/elections/registration/{election_name}", params={
153-
"position": "president",
154-
"speech": "I would like to run for president because I'm the best in Valorant at SFU."
155-
})
156-
assert response.status_code == 401
152+
# response = await client.patch(f"/elections/registration/{election_name}", params={
153+
# "position": "president",
154+
# "speech": "I would like to run for president because I'm the best in Valorant at SFU."
155+
# })
156+
# assert response.status_code == 401
157157

158158
response = await client.put("/elections/nominee/info", params={
159159
"full_name": "John Doe VI",
@@ -285,18 +285,18 @@ async def test_endpoints_admin(client, database_setup):
285285
})
286286
assert response.status_code == 200
287287

288-
# update the registration
289-
response = await client.patch(f"/elections/registration/{election_name}", params={
290-
"position": "president",
291-
"speech": "Vote for me as president"
292-
})
293-
assert response.status_code == 200
288+
# # update the registration
289+
# response = await client.patch(f"/elections/registration/{election_name}", params={
290+
# "position": "president",
291+
# "speech": "Vote for me as president"
292+
# })
293+
# assert response.status_code == 200
294294
# try updating a non-registered election
295-
response = await client.patch("/elections/registration/testElection4", params={
296-
"position": "president",
297-
"speech": "Vote for me as president, I am good at valorant."
298-
})
299-
assert response.status_code == 404
295+
# response = await client.patch("/elections/registration/testElection4", params={
296+
# "position": "president",
297+
# "speech": "Vote for me as president, I am good at valorant."
298+
# })
299+
# assert response.status_code == 404
300300

301301
# delete an election
302302
response = await client.delete("/elections/testElection4")

0 commit comments

Comments
 (0)