@@ -209,13 +209,10 @@ def schoolclass_students_csv(schoolclass: str, who: AuthenticatedUser = Depends(
209209 if not schoolclass :
210210 raise HTTPException (status_code = 404 , detail = f"Schoolclass { schoolclass } not found" )
211211
212- if who .role in ["schooladministrator" , "globaladministrator" ] or who .user in schoolclass .sophomorixAdmins :
213- file_path = schoolclass .students_csv ()
214- filename = file_path .split ('/' )[- 1 ]
215-
216- return FileResponse (path = file_path , filename = filename , media_type = 'csv' )
212+ file_path = schoolclass .students_csv ()
213+ filename = file_path .split ('/' )[- 1 ]
217214
218- return HTTPException ( status_code = 401 , detail = f"Teacher { who . user } is not member of schoolclass { schoolclass . cn } " )
215+ return FileResponse ( path = file_path , filename = filename , media_type = 'csv' )
219216
220217@router .get ("/{schoolclass}/pdf_students_list" , name = "Generate a students list as PDF from a specific schoolclass" )
221218def schoolclass_students_pdf (schoolclass : str , who : AuthenticatedUser = Depends (RoleChecker ("GST" ))):
@@ -242,17 +239,14 @@ def schoolclass_students_pdf(schoolclass: str, who: AuthenticatedUser = Depends(
242239 if not schoolclass :
243240 raise HTTPException (status_code = 404 , detail = f"Schoolclass { schoolclass } not found" )
244241
245- if who .role in ["schooladministrator" , "globaladministrator" ] or who .user in schoolclass .sophomorixAdmins :
246- try :
247- file_path = print_schoolclass_list (schoolclass .cn , who .user , school = who .school )
248- filename = file_path .split ('/' )[- 1 ]
249- except Exception as e :
250- # Temporary 500, must be better filtered
251- raise HTTPException (status_code = 500 , detail = f"Failed to generate list: { str (e )} " )
252-
253- return FileResponse (path = file_path , filename = filename , media_type = 'pdf' )
242+ try :
243+ file_path = print_schoolclass_list (schoolclass .cn , who .user , school = who .school )
244+ filename = file_path .split ('/' )[- 1 ]
245+ except Exception as e :
246+ # Temporary 500, must be better filtered
247+ raise HTTPException (status_code = 500 , detail = f"Failed to generate list: { str (e )} " )
254248
255- return HTTPException ( status_code = 401 , detail = f"Teacher { who . user } is not member of schoolclass { schoolclass . cn } " )
249+ return FileResponse ( path = file_path , filename = filename , media_type = 'pdf' )
256250
257251@router .get ("/{schoolclass}/parents" , name = "Get the list of parents from a specific schoolclass" )
258252def schoolclass_parents (schoolclass : str , who : AuthenticatedUser = Depends (RoleChecker ("GST" ))):
0 commit comments