Rename problem data fields

This commit is contained in:
cuom1999 2024-03-18 23:53:35 -05:00
parent acdf94a8c9
commit 5e72b472e6
8 changed files with 277 additions and 170 deletions

View file

@ -0,0 +1,75 @@
# Generated by Django 3.2.18 on 2024-03-19 04:28
from django.db import migrations, models
def migrate_checker(apps, schema_editor):
ProblemData = apps.get_model("judge", "ProblemData")
ProblemTestCase = apps.get_model("judge", "ProblemTestCase")
for p in ProblemData.objects.all():
if p.checker == "customval":
p.checker = "customcpp"
p.save()
for p in ProblemTestCase.objects.all():
if p.checker == "customval":
p.checker = "customcpp"
p.save()
class Migration(migrations.Migration):
dependencies = [
("judge", "0181_remove_math_engine"),
]
operations = [
migrations.RunPython(migrate_checker, migrations.RunPython.noop, atomic=True),
migrations.AlterField(
model_name="problemdata",
name="checker",
field=models.CharField(
blank=True,
choices=[
("standard", "Standard"),
("floats", "Floats"),
("floatsabs", "Floats (absolute)"),
("floatsrel", "Floats (relative)"),
("rstripped", "Non-trailing spaces"),
("sorted", "Unordered"),
("identical", "Byte identical"),
("linecount", "Line-by-line"),
("custom", "Custom checker (PY)"),
("customcpp", "Custom checker (CPP)"),
("interact", "Interactive"),
("testlib", "Testlib"),
],
max_length=10,
verbose_name="checker",
),
),
migrations.AlterField(
model_name="problemtestcase",
name="checker",
field=models.CharField(
blank=True,
choices=[
("standard", "Standard"),
("floats", "Floats"),
("floatsabs", "Floats (absolute)"),
("floatsrel", "Floats (relative)"),
("rstripped", "Non-trailing spaces"),
("sorted", "Unordered"),
("identical", "Byte identical"),
("linecount", "Line-by-line"),
("custom", "Custom checker (PY)"),
("customcpp", "Custom checker (CPP)"),
("interact", "Interactive"),
("testlib", "Testlib"),
],
max_length=10,
verbose_name="checker",
),
),
]

View file

@ -0,0 +1,45 @@
# Generated by Django 3.2.18 on 2024-03-19 04:45
import django.core.validators
from django.db import migrations, models
import judge.models.problem_data
import judge.utils.problem_data
def migrate_checker(apps, schema_editor):
ProblemData = apps.get_model("judge", "ProblemData")
for p in ProblemData.objects.all():
p.custom_checker_cpp = p.custom_validator
p.save()
class Migration(migrations.Migration):
dependencies = [
("judge", "0182_rename_customcpp"),
]
operations = [
migrations.AddField(
model_name="problemdata",
name="custom_checker_cpp",
field=models.FileField(
blank=True,
null=True,
storage=judge.utils.problem_data.ProblemDataStorage(),
upload_to=judge.models.problem_data.problem_directory_file,
validators=[
django.core.validators.FileExtensionValidator(
allowed_extensions=["cpp"]
)
],
verbose_name="custom cpp checker file",
),
),
migrations.RunPython(migrate_checker, migrations.RunPython.noop, atomic=True),
migrations.RemoveField(
model_name="problemdata",
name="custom_validator",
),
]

View file

@ -38,7 +38,7 @@ CHECKERS = (
("identical", _("Byte identical")),
("linecount", _("Line-by-line")),
("custom", _("Custom checker (PY)")),
("customval", _("Custom validator (CPP)")),
("customcpp", _("Custom checker (CPP)")),
("interact", _("Interactive")),
("testlib", _("Testlib")),
)
@ -90,8 +90,8 @@ class ProblemData(models.Model):
upload_to=problem_directory_file,
validators=[FileExtensionValidator(allowed_extensions=["py"])],
)
custom_validator = models.FileField(
verbose_name=_("custom validator file"),
custom_checker_cpp = models.FileField(
verbose_name=_("custom cpp checker file"),
storage=problem_data_storage,
null=True,
blank=True,
@ -186,9 +186,9 @@ class ProblemData(models.Model):
self.custom_checker.name = problem_directory_file_helper(
new, self.custom_checker.name
)
if self.custom_validator:
self.custom_validator.name = problem_directory_file_helper(
new, self.custom_validator.name
if self.custom_checker_cpp:
self.custom_checker_cpp.name = problem_directory_file_helper(
new, self.custom_checker_cpp.name
)
if self.interactive_judge:
self.interactive_judge.name = problem_directory_file_helper(

View file

@ -82,8 +82,8 @@ class ProblemDataCompiler(object):
)
return custom_checker_path[1]
if case.checker == "customval":
custom_checker_path = split_path_first(case.custom_validator.name)
if case.checker == "customcpp":
custom_checker_path = split_path_first(case.custom_checker_cpp.name)
if len(custom_checker_path) != 2:
raise ProblemDataError(
_("How did you corrupt the custom checker path?")
@ -98,7 +98,7 @@ class ProblemDataCompiler(object):
}
if case.checker == "testlib":
custom_checker_path = split_path_first(case.custom_validator.name)
custom_checker_path = split_path_first(case.custom_checker_cpp.name)
if len(custom_checker_path) != 2:
raise ProblemDataError(
_("How did you corrupt the custom checker path?")

View file

@ -89,7 +89,7 @@ class ProblemDataForm(ModelForm):
"checker",
"checker_args",
"custom_checker",
"custom_validator",
"custom_checker_cpp",
"interactive_judge",
"fileio_input",
"fileio_output",