Skip to content

Commit

Permalink
Only show edit/resubmit button if you are allowed to edit.
Browse files Browse the repository at this point in the history
  • Loading branch information
meisterT committed Oct 6, 2024
1 parent b3db6ab commit 5a6b3b5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
7 changes: 6 additions & 1 deletion webapp/src/Controller/Jury/SubmissionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -748,6 +748,10 @@ public function teamOutputAction(Submission $submission, Contest $contest, Judgi
return Utils::streamAsBinaryFile($outputRun, $filename);
}

private function allowEdit(): bool {
return $this->dj->getUser()->getTeam() && $this->dj->checkrole('team');
}

/**
* @throws NonUniqueResultException
*/
Expand Down Expand Up @@ -865,13 +869,14 @@ public function sourceAction(
'originalSubmission' => $originalSubmission,
'originalFiles' => $originalFiles,
'originalFileStats' => $originalFileStats,
'allowEdit' => $this->allowEdit(),
]);
}

#[Route(path: '/{submission}/edit-source', name: 'jury_submission_edit_source')]
public function editSourceAction(Request $request, Submission $submission, #[MapQueryParameter] ?int $rank = null): Response
{
if (!$this->dj->getUser()->getTeam() || !$this->dj->checkrole('team')) {
if (!$this->allowEdit()) {
$this->addFlash('danger', 'You cannot re-submit code without being a team.');
return $this->redirectToLocalReferrer($this->router, $request, $this->generateUrl(
'jury_submission',
Expand Down
10 changes: 6 additions & 4 deletions webapp/templates/jury/submission_source.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,12 @@
href="{{ path('jury_submission_source', {submission: submission.submitid, fetch: file.rank}) }}">
<i class="fas fa-download"></i> Download
</a>
<a class="btn btn-secondary btn-sm"
href="{{ path('jury_submission_edit_source', {submission: submission.submitid, rank: file.rank}) }}">
<i class="fas fa-pencil-alt"></i> Edit
</a>
{% if allowEdit %}
<a class="btn btn-secondary btn-sm"
href="{{ path('jury_submission_edit_source', {submission: submission.submitid, rank: file.rank}) }}">
<i class="fas fa-pencil-alt"></i> Edit
</a>
{% endif %}
</div>

{{ file.sourcecode | codeEditor(file.rank, submission.language.aceLanguage) }}
Expand Down

0 comments on commit 5a6b3b5

Please sign in to comment.