@@ -78,7 +78,7 @@ async def has_access(db_session: database.DBSession, request: Request) -> bool:
7878
7979 has_private_access = await has_access (db_session , request )
8080
81- all_officer_data = await officers .crud .all_officer_terms (db_session , has_private_access , view_only_filled_in )
81+ all_officer_data = await officers .crud .all_officer_data (db_session , has_private_access , view_only_filled_in )
8282 all_officer_data = [officer_data .serializable_dict () for officer_data in all_officer_data ]
8383 return JSONResponse (all_officer_data )
8484
@@ -92,7 +92,7 @@ async def get_officer_terms(
9292 computing_id : str ,
9393 # the maximum number of terms to return, in chronological order
9494 max_terms : int | None = None ,
95- view_only_filled_in : bool = True ,
95+ include_inactive : bool = False ,
9696):
9797 # TODO: put these into a function
9898 session_id = request .cookies .get ("session_id" , None )
@@ -105,18 +105,18 @@ async def get_officer_terms(
105105 raise HTTPException (status_code = 401 )
106106
107107 if (
108- not view_only_filled_in
109- and computing_id != session_computing_id
108+ computing_id != session_computing_id
109+ and include_inactive
110110 and not await WebsiteAdmin .has_permission (db_session , session_computing_id )
111111 ):
112112 raise HTTPException (status_code = 401 )
113113
114114 # all term info is public, so anyone can get any of it
115- officer_terms = await officers .crud .officer_terms (
115+ officer_terms = await officers .crud .get_officer_terms (
116116 db_session ,
117117 computing_id ,
118118 max_terms ,
119- view_only_filled_in = view_only_filled_in
119+ include_inactive = include_inactive
120120 )
121121 return JSONResponse ([term .serializable_dict () for term in officer_terms ])
122122
@@ -323,13 +323,11 @@ async def update_term(
323323 # the current user can only input the info for another user if they have permissions
324324 raise HTTPException (status_code = 401 , detail = "must have website admin permissions to update another user" )
325325
326- # TODO: turn is_active into a utils function
327- is_active = (old_officer_term .end_date is None ) or (datetime .today () <= old_officer_term .end_date )
328326 if (
329- not is_active
327+ not utils . is_active_term ( old_officer_term )
330328 and not await WebsiteAdmin .has_permission (db_session , session_computing_id )
331329 ):
332- raise HTTPException (status_code = 401 , detail = "only website admin can update a past ( non-active) term" )
330+ raise HTTPException (status_code = 401 , detail = "only website admin can update a non-active term" )
333331
334332 # NOTE: Only admins can write new versions of position, start_date, and end_date.
335333 if (
0 commit comments