From b45176ed7bcc977772878576ff55af7202fecbb0 Mon Sep 17 00:00:00 2001 From: Evan Zhang Date: Fri, 4 Jan 2019 15:31:11 -0500 Subject: [PATCH] Display available judges on problem pages (#851) Addresses #78. --- judge/views/problem.py | 5 +++-- resources/problem.scss | 4 ++-- templates/problem/problem.html | 27 ++++++++++++++++++++++++++- 3 files changed, 31 insertions(+), 5 deletions(-) diff --git a/judge/views/problem.py b/judge/views/problem.py index b32e839f8f..73238893b6 100644 --- a/judge/views/problem.py +++ b/judge/views/problem.py @@ -31,8 +31,8 @@ from django_ace.widgets import ACE_URL from judge.comments import CommentedDetailView from judge.forms import ProblemSubmitForm -from judge.models import Problem, Submission, ContestSubmission, ContestProblem, Language, ProblemGroup, Solution, \ - ProblemTranslation, TranslatedProblemForeignKeyQuerySet, RuntimeVersion, ProblemType +from judge.models import ContestSubmission, ContestProblem, Judge, Language, Problem, ProblemGroup, ProblemTranslation, \ + ProblemType, RuntimeVersion, Solution, Submission, TranslatedProblemForeignKeyQuerySet from judge.pdf_problems import HAS_PDF, DefaultPdfMaker from judge.utils.diggpaginator import DiggPaginator from judge.utils.opengraph import generate_opengraph @@ -174,6 +174,7 @@ def get_context_data(self, **kwargs): if contest_problem.max_submissions: context['submissions_left'] = max(contest_problem.max_submissions - get_contest_submission_count(self.object.code, user.profile), 0) + context['available_judges'] = Judge.objects.filter(online=True, problems=self.object) context['show_languages'] = self.object.allowed_languages.count() != Language.objects.count() context['has_pdf_render'] = HAS_PDF context['completed_problem_ids'] = self.get_completed_problems() diff --git a/resources/problem.scss b/resources/problem.scss index 4dfe42fdb0..1f800acaf5 100644 --- a/resources/problem.scss +++ b/resources/problem.scss @@ -127,7 +127,7 @@ ul.problem-list { content: " "; } -.authors-value { +.authors-value, .judges-value { padding-left: 1.5em; } @@ -268,4 +268,4 @@ ul.problem-list { padding: 0 3px; font-size: 13px; } -} \ No newline at end of file +} diff --git a/templates/problem/problem.html b/templates/problem/problem.html index c5d4203b2b..b2d619ec63 100644 --- a/templates/problem/problem.html +++ b/templates/problem/problem.html @@ -34,7 +34,7 @@ min-width: 12.5em; } - #problem-types, #allowed-langs { + #problem-types, #allowed-langs, #available-judges { padding-top: 1em; } @@ -238,6 +238,31 @@

{{ title }}

{% endif %} + {% if problem.is_editable_by(request.user) %} +
+ {% trans trimmed count=available_judges|length %} + Judge: + {% pluralize count %} + Judges: + {% endtrans %} + +
+ {% if available_judges %} + {% if perms.judge.change_judge %} + {% for judge in available_judges %} + {{ judge.name }} + {% if not loop.last %}, {% endif %} + {% endfor %} + {% else %} + {{ available_judges|join(", ") }} + {% endif %} + {% else %} + {{ _('none available') }} + {% endif %} +
+
+ {% endif %} {% endblock %} {% block description %}