22
22
use Symfony \Component \HttpKernel \KernelInterface ;
23
23
use Symfony \Component \PropertyAccess \PropertyAccess ;
24
24
use Symfony \Component \Routing \Attribute \Route ;
25
+ use Symfony \Component \Routing \RouterInterface ;
25
26
use Symfony \Component \Security \Http \Attribute \IsGranted ;
26
27
27
28
#[IsGranted('ROLE_JURY ' )]
@@ -98,12 +99,24 @@ public function indexAction(): Response
98
99
99
100
$ executable = $ lang ->getCompileExecutable ();
100
101
102
+ $ allowJudgeOptions = [
103
+ 'toggle_partial ' => 'language_toggle.html.twig ' ,
104
+ 'partial_arguments ' => [
105
+ 'path ' => 'jury_language_toggle_judge ' ,
106
+ 'language ' => $ lang ,
107
+ 'value ' => $ lang ->getAllowJudge (),
108
+ ],
109
+ ];
110
+
111
+ if (!$ lang ->getAllowJudge ()) {
112
+ $ allowJudgeOptions ['cssclass ' ] = 'text-danger font-weight-bold ' ;
113
+ }
114
+
101
115
// Merge in the rest of the data.
102
116
$ langdata = array_merge ($ langdata , [
103
117
'entrypoint ' => ['value ' => $ lang ->getRequireEntryPoint () ? 'yes ' : 'no ' ],
104
118
'extensions ' => ['value ' => implode (', ' , $ lang ->getExtensions ())],
105
- 'allowjudge ' => $ lang ->getAllowJudge () ?
106
- ['value ' => 'yes ' ] : ['value ' => 'no ' , 'cssclass ' =>'text-danger font-weight-bold ' ],
119
+ 'allowjudge ' => $ allowJudgeOptions ,
107
120
'executable ' => [
108
121
'value ' => $ executable === null ? '- ' : $ executable ->getShortDescription (),
109
122
'link ' => $ executable === null ? null : $ this ->generateUrl ('jury_executable ' , [
@@ -222,8 +235,11 @@ public function toggleSubmitAction(Request $request, string $langId): Response
222
235
}
223
236
224
237
#[Route(path: '/{langId}/toggle-judge ' , name: 'jury_language_toggle_judge ' )]
225
- public function toggleJudgeAction (Request $ request , string $ langId ): Response
226
- {
238
+ public function toggleJudgeAction (
239
+ RouterInterface $ router ,
240
+ Request $ request ,
241
+ string $ langId
242
+ ): Response {
227
243
$ language = $ this ->em ->getRepository (Language::class)->find ($ langId );
228
244
if (!$ language ) {
229
245
throw new NotFoundHttpException (sprintf ('Language with ID %s not found ' , $ langId ));
@@ -239,7 +255,11 @@ public function toggleJudgeAction(Request $request, string $langId): Response
239
255
240
256
$ this ->dj ->auditlog ('language ' , $ langId , 'set allow judge ' ,
241
257
$ request ->request ->getBoolean ('value ' ) ? 'yes ' : 'no ' );
242
- return $ this ->redirectToRoute ('jury_language ' , ['langId ' => $ langId ]);
258
+ return $ this ->redirectToLocalReferrer (
259
+ $ router ,
260
+ $ request ,
261
+ $ this ->generateUrl ('jury_language ' , ['langId ' => $ langId ])
262
+ );
243
263
}
244
264
245
265
#[Route(path: '/{langId}/toggle-filter-compiler-flags ' , name: 'jury_language_toggle_filter_compiler_files ' )]
0 commit comments