@@ -387,41 +387,14 @@ public function deleteAction(Request $request, int $teamId): Response
387387 #[Route(path: '/delete-multiple ' , name: 'jury_team_delete_multiple ' , methods: ['GET ' , 'POST ' ])]
388388 public function deleteMultipleAction (Request $ request ): Response
389389 {
390- $ ids = $ request ->query ->all ('ids ' );
391- if (empty ($ ids )) {
392- throw new BadRequestHttpException ('No IDs specified for deletion ' );
393- }
394-
395- $ teams = $ this ->em ->getRepository (Team::class)->findBy (['teamid ' => $ ids ]);
396-
397- $ deletableTeams = [];
398- foreach ($ teams as $ team ) {
399- $ isLocked = false ;
400- foreach ($ team ->getContests () as $ contest ) {
401- if ($ contest ->isLocked ()) {
402- $ isLocked = true ;
403- break ;
404- }
405- }
406- if (!$ isLocked && $ team ->getCategory ()) {
407- foreach ($ team ->getCategory ()->getContests () as $ contest ) {
408- if ($ contest ->isLocked ()) {
409- $ isLocked = true ;
410- break ;
411- }
412- }
413- }
414- if (!$ isLocked ) {
415- $ deletableTeams [] = $ team ;
416- }
417- }
418-
419- if (empty ($ deletableTeams )) {
420- $ this ->addFlash ('warning ' , 'No teams could be deleted (they might be in a locked contest). ' );
421- return $ this ->redirectToRoute ('jury_teams ' );
422- }
423-
424- return $ this ->deleteEntities ($ request , $ deletableTeams , $ this ->generateUrl ('jury_teams ' ));
390+ return $ this ->deleteMultiple (
391+ $ request ,
392+ Team::class,
393+ 'teamid ' ,
394+ 'jury_teams ' ,
395+ 'No teams could be deleted (they might be in a locked contest). ' ,
396+ fn (Team $ team ) => !$ team ->isLocked ()
397+ );
425398 }
426399
427400 #[IsGranted('ROLE_ADMIN ' )]
0 commit comments