Skip to content

Commit

Permalink
Add option to hide problem authors while in contest
Browse files Browse the repository at this point in the history
  • Loading branch information
Ninjaclasher authored and quantum5 committed Jun 6, 2021
1 parent 4a08233 commit 3489b4d
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 17 deletions.
5 changes: 3 additions & 2 deletions judge/admin/contest.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,9 @@ class Meta:
class ContestAdmin(NoBatchDeleteMixin, VersionAdmin):
fieldsets = (
(None, {'fields': ('key', 'name', 'authors', 'curators', 'testers')}),
(_('Settings'), {'fields': ('is_visible', 'use_clarifications', 'hide_problem_tags', 'run_pretests_only',
'locked_after', 'scoreboard_visibility', 'points_precision')}),
(_('Settings'), {'fields': ('is_visible', 'use_clarifications', 'hide_problem_tags', 'hide_problem_authors',
'run_pretests_only', 'locked_after', 'scoreboard_visibility',
'points_precision')}),
(_('Scheduling'), {'fields': ('start_time', 'end_time', 'time_limit')}),
(_('Details'), {'fields': ('description', 'og_image', 'logo_override_image', 'tags', 'summary')}),
(_('Format'), {'fields': ('format_name', 'format_config', 'problem_label_script')}),
Expand Down
18 changes: 18 additions & 0 deletions judge/migrations/0119_hide_problem_authors.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 2.2.24 on 2021-06-06 17:18

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('judge', '0118_convert_to_dates'),
]

operations = [
migrations.AddField(
model_name='contest',
name='hide_problem_authors',
field=models.BooleanField(default=False, help_text='Whether problem authors should be hidden by default.', verbose_name='hide problem authors'),
),
]
3 changes: 3 additions & 0 deletions judge/models/contest.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ class Contest(models.Model):
hide_problem_tags = models.BooleanField(verbose_name=_('hide problem tags'),
help_text=_('Whether problem tags should be hidden by default.'),
default=False)
hide_problem_authors = models.BooleanField(verbose_name=_('hide problem authors'),
help_text=_('Whether problem authors should be hidden by default.'),
default=False)
run_pretests_only = models.BooleanField(verbose_name=_('run pretests only'),
help_text=_('Whether judges should grade pretests only, versus all '
'testcases. Commonly set during a contest, then unset '
Expand Down
4 changes: 4 additions & 0 deletions judge/views/ticket.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ class NewProblemTicketView(ProblemMixin, TitleMixin, NewTicketView):
template_name = 'ticket/new_problem.html'

def get_assignees(self):
if self.request.in_contest:
contest = self.request.participation.contest
if self.object.contests.filter(contest=contest).exists():
return contest.authors.all()
return self.object.authors.all()

def get_title(self):
Expand Down
32 changes: 17 additions & 15 deletions templates/problem/problem.html
Original file line number Diff line number Diff line change
Expand Up @@ -201,21 +201,23 @@ <h2 style="color:#393630; display: inline-block">{{ title }}</h2>

<hr style="padding-top: 0.7em">

{% cache 86400 'problem_authors' problem.id LANGUAGE_CODE %}
{% with authors=problem.authors.all() %}
{% if authors %}
<div class="problem-info-entry">
<i class="fa fa-pencil-square-o fa-fw"></i><span
class="pi-name">{% trans trimmed count=authors|length %}
Author:
{% pluralize count %}
Authors:
{% endtrans %}</span>
<div class="pi-value authors-value">{{ link_users(authors) }}</div>
</div>
{% endif %}
{% endwith %}
{% endcache %}
{% if not contest_problem or not contest_problem.contest.hide_problem_authors %}
{% cache 86400 'problem_authors' problem.id LANGUAGE_CODE %}
{% with authors=problem.authors.all() %}
{% if authors %}
<div class="problem-info-entry">
<i class="fa fa-pencil-square-o fa-fw"></i><span
class="pi-name">{% trans trimmed count=authors|length %}
Author:
{% pluralize count %}
Authors:
{% endtrans %}</span>
<div class="pi-value authors-value">{{ link_users(authors) }}</div>
</div>
{% endif %}
{% endwith %}
{% endcache %}
{% endif %}

{% if not contest_problem or not contest_problem.contest.hide_problem_tags %}
<div id="problem-types">
Expand Down

0 comments on commit 3489b4d

Please sign in to comment.