Drop output_prefix_override and use show_testcases

This commit is contained in:
cuom1999 2023-08-25 18:12:53 -05:00
parent 97d0239963
commit 8f046c59c1
8 changed files with 61 additions and 16 deletions

View file

@ -71,7 +71,6 @@ class ContestProblemInlineForm(ModelForm):
"hidden_subtasks": TextInput(attrs={"size": "3"}),
"points": TextInput(attrs={"size": "1"}),
"order": TextInput(attrs={"size": "1"}),
"output_prefix_override": TextInput(attrs={"size": "1"}),
}
@ -86,7 +85,7 @@ class ContestProblemInline(admin.TabularInline):
"is_pretested",
"max_submissions",
"hidden_subtasks",
"output_prefix_override",
"show_testcases",
"order",
"rejudge_column",
)

View file

@ -528,7 +528,7 @@ class ContestProblemForm(ModelForm):
"problem",
"points",
"partial",
"output_prefix_override",
"show_testcases",
"max_submissions",
)
widgets = {

View file

@ -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
),
]

View file

@ -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",
),
]

View file

@ -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=_(

View file

@ -109,6 +109,13 @@ class Organization(models.Model):
"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

View file

@ -259,13 +259,13 @@ class SubmissionStatus(SubmissionDetailBase):
)
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:

View file

@ -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' %}