From c973f26627e404a2b1024d2503e92debb85a6306 Mon Sep 17 00:00:00 2001 From: Evan Date: Thu, 3 Jan 2019 14:53:55 -0500 Subject: [PATCH 1/3] Show available judges for problems --- judge/views/problem.py | 5 +++-- resources/problem.scss | 4 ++-- templates/problem/problem.html | 26 +++++++++++++++++++++++++- 3 files changed, 30 insertions(+), 5 deletions(-) diff --git a/judge/views/problem.py b/judge/views/problem.py index b32e839f8f..d5d70827c4 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['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..333f30f0a4 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,30 @@

{{ title }}

{% endif %} + {% if problem.is_editable_by(request.user) %} +
+ {% trans trimmed count=judges|length %} + Judge: + {% pluralize count %} + Judges: + {% endtrans %} +
+ {% if judges %} + {% if perms.judge.change_judge %} + {% for judge in judges %} + {{ judge.name }} + {% if not loop.last %}, {% endif %} + {% endfor %} + {% else %} + {{ judges|join(", ") }} + {% endif %} + {% else %} + {{ _('No available judges') }} + {% endif %} +
+
+ {% endif %} {% endblock %} {% block description %} From d063d69c259e060544508c2c284408ff93b11187 Mon Sep 17 00:00:00 2001 From: Evan Date: Thu, 3 Jan 2019 15:45:11 -0500 Subject: [PATCH 2/3] Minor requested changes --- judge/views/problem.py | 2 +- templates/problem/problem.html | 19 ++++++++++--------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/judge/views/problem.py b/judge/views/problem.py index d5d70827c4..73238893b6 100644 --- a/judge/views/problem.py +++ b/judge/views/problem.py @@ -174,7 +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['judges'] = Judge.objects.filter(online=True, problems=self.object) + 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/templates/problem/problem.html b/templates/problem/problem.html index 333f30f0a4..ff103e1c50 100644 --- a/templates/problem/problem.html +++ b/templates/problem/problem.html @@ -241,23 +241,24 @@

{{ title }}

{% if problem.is_editable_by(request.user) %}
{% trans trimmed count=judges|length %} - Judge: - {% pluralize count %} - Judges: - {% endtrans %} + class="pi-name">{% trans trimmed count=available_judges|length %} + Judge: + {% pluralize count %} + Judges: + {% endtrans %} +
- {% if judges %} + {% if available_judges %} {% if perms.judge.change_judge %} - {% for judge in judges %} + {% for judge in available_judges %} {{ judge.name }} {% if not loop.last %}, {% endif %} {% endfor %} {% else %} - {{ judges|join(", ") }} + {{ available_judges|join(", ") }} {% endif %} {% else %} - {{ _('No available judges') }} + {{ _('None available') }} {% endif %}
From f9357acbe3bfa116fb67003dfeeb308af6c49e21 Mon Sep 17 00:00:00 2001 From: Evan Zhang Date: Thu, 3 Jan 2019 22:53:02 -0500 Subject: [PATCH 3/3] Minor nit. --- templates/problem/problem.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/problem/problem.html b/templates/problem/problem.html index ff103e1c50..b2d619ec63 100644 --- a/templates/problem/problem.html +++ b/templates/problem/problem.html @@ -258,7 +258,7 @@

{{ title }}

{{ available_judges|join(", ") }} {% endif %} {% else %} - {{ _('None available') }} + {{ _('none available') }} {% endif %}