From de3678ea8e5e7e25b97ba68eaddb5eb74a4d8833 Mon Sep 17 00:00:00 2001 From: Hironsan Date: Fri, 21 Oct 2022 16:43:26 +0900 Subject: [PATCH] Add score field to Example model --- .../examples/migrations/0007_example_score.py | 18 ++++++++++++++++++ backend/examples/models.py | 1 + backend/examples/serializers.py | 1 + 3 files changed, 20 insertions(+) create mode 100644 backend/examples/migrations/0007_example_score.py diff --git a/backend/examples/migrations/0007_example_score.py b/backend/examples/migrations/0007_example_score.py new file mode 100644 index 00000000..a8f6afdc --- /dev/null +++ b/backend/examples/migrations/0007_example_score.py @@ -0,0 +1,18 @@ +# Generated by Django 4.0.7 on 2022-10-21 07:37 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("examples", "0006_alter_example_upload_name"), + ] + + operations = [ + migrations.AddField( + model_name="example", + name="score", + field=models.FloatField(default=100), + ), + ] diff --git a/backend/examples/models.py b/backend/examples/models.py index 51465fc5..733e64e8 100644 --- a/backend/examples/models.py +++ b/backend/examples/models.py @@ -18,6 +18,7 @@ class Example(models.Model): project = models.ForeignKey(to=Project, on_delete=models.CASCADE, related_name="examples") annotations_approved_by = models.ForeignKey(to=User, on_delete=models.SET_NULL, null=True, blank=True) text = models.TextField(null=True, blank=True) + score = models.FloatField(default=100) created_at = models.DateTimeField(auto_now_add=True, db_index=True) updated_at = models.DateTimeField(auto_now=True) diff --git a/backend/examples/serializers.py b/backend/examples/serializers.py index fad6690e..eb6bf615 100644 --- a/backend/examples/serializers.py +++ b/backend/examples/serializers.py @@ -45,6 +45,7 @@ class ExampleSerializer(serializers.ModelSerializer): "text", "is_confirmed", "upload_name", + "score", ] read_only_fields = ["filename", "is_confirmed", "upload_name"]