From 5df8a8b29b264461d79ea8707434a2cc91506bb1 Mon Sep 17 00:00:00 2001 From: Luca Date: Wed, 14 Feb 2024 01:45:33 +0100 Subject: [PATCH] feat: add Score model --- pretalx_musicrate/migrations/0009_score.py | 34 +++++++++++++++++++ pretalx_musicrate/models.py | 5 +++ .../pretalx_musicrate/enhanced_list.html | 8 ++--- pretalx_musicrate/views.py | 2 +- 4 files changed, 44 insertions(+), 5 deletions(-) create mode 100644 pretalx_musicrate/migrations/0009_score.py diff --git a/pretalx_musicrate/migrations/0009_score.py b/pretalx_musicrate/migrations/0009_score.py new file mode 100644 index 0000000..3bc48f5 --- /dev/null +++ b/pretalx_musicrate/migrations/0009_score.py @@ -0,0 +1,34 @@ +# Generated by Django 4.2.8 on 2024-02-14 00:36 + +import django.db.models.deletion +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("submission", "0072_alter_reviewscore_label"), + ("pretalx_musicrate", "0008_assignee"), + ] + + operations = [ + migrations.CreateModel( + name="Score", + fields=[ + ( + "id", + models.AutoField( + auto_created=True, primary_key=True, serialize=False + ), + ), + ("value", models.FloatField()), + ( + "submission", + models.OneToOneField( + on_delete=django.db.models.deletion.CASCADE, + to="submission.submission", + ), + ), + ], + ), + ] diff --git a/pretalx_musicrate/models.py b/pretalx_musicrate/models.py index 1b12af1..d71d0b4 100644 --- a/pretalx_musicrate/models.py +++ b/pretalx_musicrate/models.py @@ -112,3 +112,8 @@ class Assignee(models.Model): user = models.ForeignKey( "person.User", on_delete=models.CASCADE, related_name="assigned_submissions" ) + + +class Score(models.Model): + submission = models.OneToOneField("submission.Submission", on_delete=models.CASCADE) + value = models.FloatField() diff --git a/pretalx_musicrate/templates/pretalx_musicrate/enhanced_list.html b/pretalx_musicrate/templates/pretalx_musicrate/enhanced_list.html index fe20d1f..75bb6ce 100644 --- a/pretalx_musicrate/templates/pretalx_musicrate/enhanced_list.html +++ b/pretalx_musicrate/templates/pretalx_musicrate/enhanced_list.html @@ -65,8 +65,8 @@ {% translate "Rating" %} - - + + {% translate "Title" %} @@ -97,8 +97,8 @@ {% for submission in submissions %} - {% if submission.rating %} - {{ submission.rating.value }} + {% if submission.score %} + {{ submission.score.value }} {% else %} – {% endif %} diff --git a/pretalx_musicrate/views.py b/pretalx_musicrate/views.py index cdef06a..d1f7a12 100644 --- a/pretalx_musicrate/views.py +++ b/pretalx_musicrate/views.py @@ -479,7 +479,7 @@ class AssigneeView(EventPermissionRequired, FormView, SingleObjectMixin): class EnhancedSubmissionList(SubmissionList): - sortable_fields = ("code", "rating", "title", "state", "assignee") + sortable_fields = ("code", "score", "title", "state", "assignee") template_name = "pretalx_musicrate/enhanced_list.html" def get_filter_form(self):