Skip to content

Commit

Permalink
Display available judges on problem pages (DMOJ#851)
Browse files Browse the repository at this point in the history
Addresses DMOJ#78.
  • Loading branch information
Ninjaclasher authored and Xyene committed Jan 4, 2019
1 parent 36babc4 commit 7caf4d3
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 5 deletions.
5 changes: 3 additions & 2 deletions judge/views/problem.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions resources/problem.scss
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ ul.problem-list {
content: " ";
}

.authors-value {
.authors-value, .judges-value {
padding-left: 1.5em;
}

Expand Down Expand Up @@ -268,4 +268,4 @@ ul.problem-list {
padding: 0 3px;
font-size: 13px;
}
}
}
27 changes: 26 additions & 1 deletion templates/problem/problem.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
min-width: 12.5em;
}

#problem-types, #allowed-langs {
#problem-types, #allowed-langs, #available-judges {
padding-top: 1em;
}

Expand Down Expand Up @@ -238,6 +238,31 @@ <h2 style="color:#393630; display: inline-block">{{ title }}</h2>
</div>
</div>
{% endif %}
{% if problem.is_editable_by(request.user) %}
<div id="available-judges">
<i class="fa fa-database fa-fw"></i><span
class="pi-name">{% trans trimmed count=available_judges|length %}
Judge:
{% pluralize count %}
Judges:
{% endtrans %}
</span>
<div class="pi-value judges-value">
{% if available_judges %}
{% if perms.judge.change_judge %}
{% for judge in available_judges %}
<a href="{{ url('admin:judge_judge_change', judge.id) }}">{{ judge.name }}</a>
{% if not loop.last %}, {% endif %}
{% endfor %}
{% else %}
{{ available_judges|join(", ") }}
{% endif %}
{% else %}
<i>{{ _('none available') }}</i>
{% endif %}
</div>
</div>
{% endif %}
{% endblock %}

{% block description %}
Expand Down

0 comments on commit 7caf4d3

Please sign in to comment.