From 22544c428d47606ecbc57107d36db4a75fa4fbc8 Mon Sep 17 00:00:00 2001 From: Topvennie Date: Wed, 3 Apr 2024 12:27:36 +0200 Subject: [PATCH] chore: fix some db issues --- backend/api/fixtures/checks.yaml | 14 ++++--------- backend/api/fixtures/submissions.yaml | 21 ++++--------------- .../api/migrations/0008_add_extra_checks.py | 15 +++++++------ backend/api/models/checks.py | 1 + 4 files changed, 16 insertions(+), 35 deletions(-) diff --git a/backend/api/fixtures/checks.yaml b/backend/api/fixtures/checks.yaml index 134302e7..e3ff5791 100644 --- a/backend/api/fixtures/checks.yaml +++ b/backend/api/fixtures/checks.yaml @@ -1,22 +1,16 @@ -- model: api.extracheck - pk: 1 - fields: - project: 123456 - run_script: 'scripts/run.sh' - - model: api.fileextension pk: 1 fields: - extension: 'class' + extension: "class" - model: api.fileextension pk: 2 fields: - extension: 'png' + extension: "png" - model: api.fileextension pk: 3 fields: - extension: 'java' + extension: "java" - model: api.fileextension pk: 4 fields: - extension: 'py' + extension: "py" diff --git a/backend/api/fixtures/submissions.yaml b/backend/api/fixtures/submissions.yaml index af3627eb..3cb123db 100644 --- a/backend/api/fixtures/submissions.yaml +++ b/backend/api/fixtures/submissions.yaml @@ -3,36 +3,23 @@ fields: group: 1 submission_number: 1 - submission_time: '2021-01-01T00:00:00Z' + submission_time: "2021-01-01T00:00:00Z" structure_checks_passed: True - model: api.submission pk: 2 fields: group: 1 submission_number: 2 - submission_time: '2021-01-02T00:00:00Z' + submission_time: "2021-01-02T00:00:00Z" structure_checks_passed: True - model: api.submissionfile pk: 1 fields: submission: 1 - file: 'submissions/1/1/1.txt' + file: "submissions/1/1/1.txt" - model: api.submissionfile pk: 2 fields: submission: 2 - file: 'submissions/1/2/1.txt' - -- model: api.extrachecksresult - pk: 1 - fields: - submission: 1 - extra_check: 1 - passed: False -- model: api.extrachecksresult - pk: 2 - fields: - submission: 2 - extra_check: 1 - passed: True + file: "submissions/1/2/1.txt" diff --git a/backend/api/migrations/0008_add_extra_checks.py b/backend/api/migrations/0008_add_extra_checks.py index 5677e3ff..63c9b8fd 100644 --- a/backend/api/migrations/0008_add_extra_checks.py +++ b/backend/api/migrations/0008_add_extra_checks.py @@ -1,7 +1,6 @@ -from django.db import migrations, models - from api.models.checks import DockerImage from api.models.submission import ErrorTemplates +from django.db import migrations, models from ypovoli.settings import FILE_PATHS @@ -13,7 +12,7 @@ class Migration(migrations.Migration): operations = [ migrations.CreateModel( - name="docker_images", + name="dockerimage", fields=[ ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('name', models.CharField(max_length=256, blank=False, null=False)), @@ -22,7 +21,7 @@ class Migration(migrations.Migration): ] ), migrations.CreateModel( - name="error_templates", + name="errortemplate", fields=[ ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('message_key', models.CharField(max_length=256, blank=False, null=False)), @@ -35,7 +34,7 @@ class Migration(migrations.Migration): migrations.AddField( model_name="extracheck", name="docker_image_id", - field=models.ForeignKey(DockerImage, on_delete=models.CASCADE, related_name="extra_checks"), + field=models.ForeignKey(to="api.dockerimage", on_delete=models.CASCADE, related_name="extra_checks"), ), migrations.AddField( model_name="extracheck", @@ -53,13 +52,13 @@ class Migration(migrations.Migration): field=models.BooleanField(default=True, blank=False, null=False) ), migrations.AddField( - model_name="extracheckresult", + model_name="extrachecksresult", name="error_message", - field=models.ForeignKey(ErrorTemplates, on_delete=models.CASCADE, + field=models.ForeignKey(to="api.errortemplate", on_delete=models.CASCADE, related_name="extra_checks_results", blank=True, null=True) ), migrations.AddField( - model_name="extracheckresult", + model_name="extrachecksresult", name="log_file", field=models.CharField(max_length=256, blank=False, null=True) ) diff --git a/backend/api/models/checks.py b/backend/api/models/checks.py index abeed715..ffb1aeb6 100644 --- a/backend/api/models/checks.py +++ b/backend/api/models/checks.py @@ -48,6 +48,7 @@ class DockerImage(models.Model): """ # ID should be generated automatically + id = models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID') # Name of the docker image name = models.CharField(