@@ -188,7 +188,7 @@ async def new_officer_term(
188188 for officer_info in officer_info_list :
189189 officer_info .valid_or_raise ()
190190
191- _ , session_computing_id = logged_in_or_raise (request , db_session )
191+ _ , session_computing_id = await logged_in_or_raise (request , db_session )
192192 await WebsiteAdmin .has_permission_or_raise (db_session , session_computing_id )
193193
194194 for officer_info in officer_info_list :
@@ -231,7 +231,7 @@ async def update_info(
231231 officer_info_upload : OfficerInfoUpload = Body () # noqa: B008
232232):
233233 officer_info_upload .valid_or_raise ()
234- _ , session_computing_id = logged_in_or_raise (request , db_session )
234+ _ , session_computing_id = await logged_in_or_raise (request , db_session )
235235
236236 if computing_id != session_computing_id :
237237 await WebsiteAdmin .has_permission_or_raise (
@@ -266,8 +266,11 @@ async def update_term(
266266 term_id : int ,
267267 officer_term_upload : OfficerTermUpload = Body (), # noqa: B008
268268):
269+ """
270+ A website admin may change the position & term length however they wish.
271+ """
269272 officer_term_upload .valid_or_raise ()
270- _ , session_computing_id = logged_in_or_raise (request , db_session )
273+ _ , session_computing_id = await logged_in_or_raise (request , db_session )
271274
272275 old_officer_term = await officers .crud .get_officer_term_by_id (db_session , term_id )
273276 if old_officer_term .computing_id != session_computing_id :
@@ -291,10 +294,6 @@ async def update_term(
291294 errmsg = "only admins can write new versions of position, start_date, and end_date"
292295 )
293296
294- if officer_term_upload .position != old_officer_term .position :
295- # TODO: update the end_date here
296- pass
297-
298297 # TODO (#27): log all important changes to a .log file
299298 success = await officers .crud .update_officer_term (
300299 db_session ,
@@ -308,10 +307,10 @@ async def update_term(
308307 new_officer_term = await officers .crud .get_officer_term_by_id (db_session , term_id )
309308 return JSONResponse ({
310309 "officer_term" : new_officer_term .serializable_dict (),
311- "validation_failures" : [], # none for now, but may be important later
310+ # none for now, but may be added if frontend requests
311+ "validation_failures" : [],
312312 })
313313
314- # TODO: test this endpoint
315314@router .delete (
316315 "/term/{term_id}" ,
317316 description = "Remove the specified officer term. Only website admins can run this endpoint. BE CAREFUL WITH THIS!" ,
@@ -321,7 +320,7 @@ async def remove_officer(
321320 db_session : database .DBSession ,
322321 term_id : int ,
323322):
324- _ , session_computing_id = logged_in_or_raise (request , db_session )
323+ _ , session_computing_id = await logged_in_or_raise (request , db_session )
325324 await WebsiteAdmin .has_permission_or_raise (
326325 db_session , session_computing_id ,
327326 errmsg = "must have website admin permissions to remove a term"
@@ -331,6 +330,7 @@ async def remove_officer(
331330
332331 # TODO (#27): log all important changes to a .log file
333332 await officers .crud .delete_officer_term_by_id (db_session , term_id )
333+ await db_session .commit ()
334334
335335 return JSONResponse ({
336336 "officer_term" : deleted_officer_term .serializable_dict (),
0 commit comments