@@ -261,7 +261,7 @@ async def update_info(
261261
262262 updated_officer_info = await officers .crud .get_officer_info (db_session , computing_id )
263263 return JSONResponse ({
264- "updated_officer_info " : updated_officer_info .serializable_dict (),
264+ "officer_info " : updated_officer_info .serializable_dict (),
265265 "validation_failures" : validation_failures ,
266266 })
267267
@@ -316,14 +316,31 @@ async def update_term(
316316
317317 new_officer_term = await officers .crud .get_officer_term_by_id (db_session , term_id )
318318 return JSONResponse ({
319- "updated_officer_term " : new_officer_term .serializable_dict (),
319+ "officer_term " : new_officer_term .serializable_dict (),
320320 "validation_failures" : [], # none for now, but may be important later
321321 })
322322
323+ # TODO: test this endpoint
323324@router .delete (
324325 "/term/{term_id}" ,
325326 description = "Remove the specified officer term. Only website admins can run this endpoint. BE CAREFUL WITH THIS!" ,
326327)
327- async def remove_officer ():
328- # TODO: this
329- return {}
328+ async def remove_officer (
329+ request : Request ,
330+ db_session : database .DBSession ,
331+ term_id : int ,
332+ ):
333+ _ , session_computing_id = logged_in_or_raise (request , db_session )
334+ await WebsiteAdmin .has_permission_or_raise (
335+ db_session , session_computing_id ,
336+ errmsg = "must have website admin permissions to remove a term"
337+ )
338+
339+ deleted_officer_term = await officers .crud .get_officer_term_by_id (db_session , term_id )
340+
341+ # TODO: log all important changes to a .log file
342+ await officers .crud .delete_officer_term_by_id (db_session , term_id )
343+
344+ return JSONResponse ({
345+ "officer_term" : deleted_officer_term .serializable_dict (),
346+ })
0 commit comments