Skip to content

Commit

Permalink
Drop output_prefix_override and use show_testcases
Browse files Browse the repository at this point in the history
  • Loading branch information
cuom1999 committed Aug 25, 2023
1 parent 97d0239 commit 8f046c5
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 16 deletions.
3 changes: 1 addition & 2 deletions judge/admin/contest.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ class Meta:
"hidden_subtasks": TextInput(attrs={"size": "3"}),
"points": TextInput(attrs={"size": "1"}),
"order": TextInput(attrs={"size": "1"}),
"output_prefix_override": TextInput(attrs={"size": "1"}),
}


Expand All @@ -86,7 +85,7 @@ class ContestProblemInline(admin.TabularInline):
"is_pretested",
"max_submissions",
"hidden_subtasks",
"output_prefix_override",
"show_testcases",
"order",
"rejudge_column",
)
Expand Down
2 changes: 1 addition & 1 deletion judge/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ class Meta:
"problem",
"points",
"partial",
"output_prefix_override",
"show_testcases",
"max_submissions",
)
widgets = {
Expand Down
30 changes: 30 additions & 0 deletions judge/migrations/0164_show_testcase.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Generated by Django 3.2.18 on 2023-08-25 23:03

from django.db import migrations, models


def migrate_show_testcases(apps, schema_editor):
ContestProblem = apps.get_model("judge", "ContestProblem")

for c in ContestProblem.objects.all():
if c.output_prefix_override == 1:
c.show_testcases = True
c.save()


class Migration(migrations.Migration):

dependencies = [
("judge", "0163_email_change"),
]

operations = [
migrations.AddField(
model_name="contestproblem",
name="show_testcases",
field=models.BooleanField(default=False, verbose_name="visible testcases"),
),
migrations.RunPython(
migrate_show_testcases, migrations.RunPython.noop, atomic=True
),
]
17 changes: 17 additions & 0 deletions judge/migrations/0165_drop_output_prefix_override.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 3.2.18 on 2023-08-25 23:11

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("judge", "0164_show_testcase"),
]

operations = [
migrations.RemoveField(
model_name="contestproblem",
name="output_prefix_override",
),
]
7 changes: 2 additions & 5 deletions judge/models/contest.py
Original file line number Diff line number Diff line change
Expand Up @@ -772,12 +772,9 @@ class ContestProblem(models.Model):
partial = models.BooleanField(default=True, verbose_name=_("partial"))
is_pretested = models.BooleanField(default=False, verbose_name=_("is pretested"))
order = models.PositiveIntegerField(db_index=True, verbose_name=_("order"))
output_prefix_override = models.IntegerField(
help_text=_("0 to not show testcases, 1 to show"),
show_testcases = models.BooleanField(
verbose_name=_("visible testcases"),
null=True,
blank=True,
default=0,
default=False,
)
max_submissions = models.IntegerField(
help_text=_(
Expand Down
7 changes: 7 additions & 0 deletions judge/models/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,13 @@ def __contains__(self, item):
"Organization membership test must be Profile or primany key"
)

def delete(self, *args, **kwargs):
contests = self.contest_set
for contest in contests.all():
if contest.organizations.count() == 1:
contest.delete()
super().delete(*args, **kwargs)

def __str__(self):
return self.name

Expand Down
6 changes: 3 additions & 3 deletions judge/views/submission.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,13 +259,13 @@ def get_context_data(self, **kwargs):
)

contest = submission.contest_or_none
prefix_length = 0
show_testcases = False
can_see_testcases = self.access_testcases_in_contest()

if contest is not None:
prefix_length = contest.problem.output_prefix_override or 0
show_testcases = contest.problem.show_testcases or False

if contest is None or prefix_length > 0 or can_see_testcases:
if contest is None or show_testcases or can_see_testcases:
context["cases_data"] = get_cases_data(submission)
context["can_see_testcases"] = True
try:
Expand Down
5 changes: 0 additions & 5 deletions templates/submission/status-testcases.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
{% if submission.contest_or_none %}
{% set prefix_length = submission.contest_or_none.problem.output_prefix_override %}
{% else %}
{% set prefix_length = None %}
{% endif %}
{% set is_pretest = submission.is_pretested %}

{% if submission.status != 'IE' %}
Expand Down

0 comments on commit 8f046c5

Please sign in to comment.