@@ -116,7 +116,7 @@ async def register_in_election(db_session: database.DBSession, body: NomineeAppl
116116 # allow any election officer running an election to register for it
117117 await registrations .crud .add_registration (
118118 db_session ,
119- NomineeApplication (
119+ NomineeApplicationDB (
120120 computing_id = body .computing_id , nominee_election = slugified_name , position = body .position , speech = None
121121 ),
122122 )
@@ -150,7 +150,7 @@ async def update_registration(
150150 computing_id : str ,
151151 position : OfficerPositionEnum ,
152152):
153- if body .position not in [o .value for o in OfficerPositionEnum ]:
153+ if body .position and body . position not in [o .value for o in OfficerPositionEnum ]:
154154 raise HTTPException (status_code = status .HTTP_400_BAD_REQUEST , detail = f"invalid position { body .position } " )
155155
156156 slugified_name = slugify (election_name )
@@ -160,7 +160,7 @@ async def update_registration(
160160 status_code = status .HTTP_404_NOT_FOUND , detail = f"election with slug { slugified_name } does not exist"
161161 )
162162
163- # self updates can only be done during nomination period. Officer updates can be done whenever
163+ # self updates can only be done during nomination period. Admin updates can be done whenever
164164 if election .status (datetime .datetime .now ()) != ElectionStatusEnum .NOMINATIONS :
165165 raise HTTPException (
166166 status_code = status .HTTP_400_BAD_REQUEST , detail = "speeches can only be updated during the nomination period"
@@ -175,16 +175,10 @@ async def update_registration(
175175 registration .update_from_params (body )
176176
177177 await registrations .crud .update_registration (db_session , registration )
178- await db_session .commit ()
179178
180- registrant = await registrations .crud .get_one_registration_in_election (
181- db_session , registration .computing_id , slugified_name , registration .position
182- )
183- if not registrant :
184- raise HTTPException (
185- status_code = status .HTTP_500_INTERNAL_SERVER_ERROR , detail = "failed to find changed registrant"
186- )
187- return registrant
179+ await db_session .commit ()
180+ await db_session .refresh (registration )
181+ return registration
188182
189183
190184@router .delete (
0 commit comments