Drop output_prefix_override and use show_testcases
This commit is contained in:
parent
97d0239963
commit
8f046c59c1
8 changed files with 61 additions and 16 deletions
|
@ -71,7 +71,6 @@ class ContestProblemInlineForm(ModelForm):
|
||||||
"hidden_subtasks": TextInput(attrs={"size": "3"}),
|
"hidden_subtasks": TextInput(attrs={"size": "3"}),
|
||||||
"points": TextInput(attrs={"size": "1"}),
|
"points": TextInput(attrs={"size": "1"}),
|
||||||
"order": 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",
|
"is_pretested",
|
||||||
"max_submissions",
|
"max_submissions",
|
||||||
"hidden_subtasks",
|
"hidden_subtasks",
|
||||||
"output_prefix_override",
|
"show_testcases",
|
||||||
"order",
|
"order",
|
||||||
"rejudge_column",
|
"rejudge_column",
|
||||||
)
|
)
|
||||||
|
|
|
@ -528,7 +528,7 @@ class ContestProblemForm(ModelForm):
|
||||||
"problem",
|
"problem",
|
||||||
"points",
|
"points",
|
||||||
"partial",
|
"partial",
|
||||||
"output_prefix_override",
|
"show_testcases",
|
||||||
"max_submissions",
|
"max_submissions",
|
||||||
)
|
)
|
||||||
widgets = {
|
widgets = {
|
||||||
|
|
30
judge/migrations/0164_show_testcase.py
Normal file
30
judge/migrations/0164_show_testcase.py
Normal 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
|
||||||
|
),
|
||||||
|
]
|
17
judge/migrations/0165_drop_output_prefix_override.py
Normal file
17
judge/migrations/0165_drop_output_prefix_override.py
Normal 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",
|
||||||
|
),
|
||||||
|
]
|
|
@ -772,12 +772,9 @@ class ContestProblem(models.Model):
|
||||||
partial = models.BooleanField(default=True, verbose_name=_("partial"))
|
partial = models.BooleanField(default=True, verbose_name=_("partial"))
|
||||||
is_pretested = models.BooleanField(default=False, verbose_name=_("is pretested"))
|
is_pretested = models.BooleanField(default=False, verbose_name=_("is pretested"))
|
||||||
order = models.PositiveIntegerField(db_index=True, verbose_name=_("order"))
|
order = models.PositiveIntegerField(db_index=True, verbose_name=_("order"))
|
||||||
output_prefix_override = models.IntegerField(
|
show_testcases = models.BooleanField(
|
||||||
help_text=_("0 to not show testcases, 1 to show"),
|
|
||||||
verbose_name=_("visible testcases"),
|
verbose_name=_("visible testcases"),
|
||||||
null=True,
|
default=False,
|
||||||
blank=True,
|
|
||||||
default=0,
|
|
||||||
)
|
)
|
||||||
max_submissions = models.IntegerField(
|
max_submissions = models.IntegerField(
|
||||||
help_text=_(
|
help_text=_(
|
||||||
|
|
|
@ -109,6 +109,13 @@ class Organization(models.Model):
|
||||||
"Organization membership test must be Profile or primany key"
|
"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):
|
def __str__(self):
|
||||||
return self.name
|
return self.name
|
||||||
|
|
||||||
|
|
|
@ -259,13 +259,13 @@ class SubmissionStatus(SubmissionDetailBase):
|
||||||
)
|
)
|
||||||
|
|
||||||
contest = submission.contest_or_none
|
contest = submission.contest_or_none
|
||||||
prefix_length = 0
|
show_testcases = False
|
||||||
can_see_testcases = self.access_testcases_in_contest()
|
can_see_testcases = self.access_testcases_in_contest()
|
||||||
|
|
||||||
if contest is not None:
|
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["cases_data"] = get_cases_data(submission)
|
||||||
context["can_see_testcases"] = True
|
context["can_see_testcases"] = True
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -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 %}
|
{% set is_pretest = submission.is_pretested %}
|
||||||
|
|
||||||
{% if submission.status != 'IE' %}
|
{% if submission.status != 'IE' %}
|
||||||
|
|
Loading…
Reference in a new issue