From 3489b4ddf7eeea701699fe75414fcfbde56ebb77 Mon Sep 17 00:00:00 2001 From: Evan Date: Sun, 6 Jun 2021 13:17:34 -0400 Subject: [PATCH] Add option to hide problem authors while in contest --- judge/admin/contest.py | 5 +-- judge/migrations/0119_hide_problem_authors.py | 18 +++++++++++ judge/models/contest.py | 3 ++ judge/views/ticket.py | 4 +++ templates/problem/problem.html | 32 ++++++++++--------- 5 files changed, 45 insertions(+), 17 deletions(-) create mode 100644 judge/migrations/0119_hide_problem_authors.py diff --git a/judge/admin/contest.py b/judge/admin/contest.py index b81a2708d0..d3f603c770 100644 --- a/judge/admin/contest.py +++ b/judge/admin/contest.py @@ -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')}), diff --git a/judge/migrations/0119_hide_problem_authors.py b/judge/migrations/0119_hide_problem_authors.py new file mode 100644 index 0000000000..31c2808040 --- /dev/null +++ b/judge/migrations/0119_hide_problem_authors.py @@ -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'), + ), + ] diff --git a/judge/models/contest.py b/judge/models/contest.py index 2bd9ab2a69..8fcf9e83be 100644 --- a/judge/models/contest.py +++ b/judge/models/contest.py @@ -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 ' diff --git a/judge/views/ticket.py b/judge/views/ticket.py index 86f7d0390a..178bafa4e8 100644 --- a/judge/views/ticket.py +++ b/judge/views/ticket.py @@ -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): diff --git a/templates/problem/problem.html b/templates/problem/problem.html index b5f3c393e6..1b7ca9461f 100644 --- a/templates/problem/problem.html +++ b/templates/problem/problem.html @@ -201,21 +201,23 @@

{{ title }}


- {% cache 86400 'problem_authors' problem.id LANGUAGE_CODE %} - {% with authors=problem.authors.all() %} - {% if authors %} -
- {% trans trimmed count=authors|length %} - Author: - {% pluralize count %} - Authors: - {% endtrans %} -
{{ link_users(authors) }}
-
- {% 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 %} +
+ {% trans trimmed count=authors|length %} + Author: + {% pluralize count %} + Authors: + {% endtrans %} +
{{ link_users(authors) }}
+
+ {% endif %} + {% endwith %} + {% endcache %} + {% endif %} {% if not contest_problem or not contest_problem.contest.hide_problem_tags %}