Rename problem data fields
This commit is contained in:
parent
acdf94a8c9
commit
5e72b472e6
8 changed files with 277 additions and 170 deletions
45
judge/migrations/0183_rename_custom_checker_cpp.py
Normal file
45
judge/migrations/0183_rename_custom_checker_cpp.py
Normal 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",
|
||||
),
|
||||
]
|
Loading…
Add table
Add a link
Reference in a new issue