2023-12-15 18:14:33 +01:00
|
|
|
from decimal import Decimal
|
2023-12-15 02:32:20 +01:00
|
|
|
from secrets import token_urlsafe
|
|
|
|
|
2023-12-13 23:58:00 +01:00
|
|
|
from django.db import models
|
2023-12-14 19:40:14 +01:00
|
|
|
from django.utils.translation import gettext_lazy as _
|
2023-12-16 21:25:17 +01:00
|
|
|
from django_scopes import ScopedManager
|
2023-12-13 23:58:00 +01:00
|
|
|
|
|
|
|
|
2023-12-15 02:32:20 +01:00
|
|
|
def generate_token():
|
|
|
|
return token_urlsafe(32)
|
|
|
|
|
|
|
|
|
2023-12-13 23:58:00 +01:00
|
|
|
class MusicrateSettings(models.Model):
|
|
|
|
event = models.OneToOneField(
|
|
|
|
to="event.Event",
|
|
|
|
on_delete=models.CASCADE,
|
|
|
|
related_name="pretalx_musicrate_settings",
|
|
|
|
)
|
2023-12-14 19:40:14 +01:00
|
|
|
submission_types = models.ManyToManyField(
|
|
|
|
to="submission.SubmissionType",
|
|
|
|
related_name="pretalx_musicrate_settings",
|
|
|
|
help_text=_(
|
|
|
|
"You can limit pretalx-musicrate to some session types. Leave this field empty to rate all session types."
|
|
|
|
),
|
|
|
|
verbose_name=_("Session Types"),
|
|
|
|
blank=True,
|
|
|
|
)
|
2023-12-15 00:06:53 +01:00
|
|
|
genre_question = models.OneToOneField(
|
|
|
|
to="submission.Question",
|
|
|
|
on_delete=models.SET_NULL,
|
|
|
|
related_name="pretalx_musicrate_settings_genre",
|
|
|
|
verbose_name=_("Genre Question"),
|
|
|
|
blank=True,
|
|
|
|
null=True,
|
|
|
|
)
|
|
|
|
origin_question = models.OneToOneField(
|
|
|
|
to="submission.Question",
|
|
|
|
on_delete=models.SET_NULL,
|
|
|
|
related_name="pretalx_musicrate_settings_origin",
|
|
|
|
verbose_name=_("Origin Question"),
|
|
|
|
blank=True,
|
|
|
|
null=True,
|
|
|
|
)
|
2023-12-15 02:32:20 +01:00
|
|
|
join_token = models.CharField(max_length=43, default=generate_token)
|
2023-12-15 18:14:33 +01:00
|
|
|
advance_threshold = models.DecimalField(
|
|
|
|
max_digits=3,
|
|
|
|
decimal_places=2,
|
|
|
|
default=Decimal("0.6"),
|
|
|
|
help_text=_(
|
|
|
|
"The fraction of jurors that has to submit a rating before the presenter view automatically advances to the next submission."
|
|
|
|
),
|
|
|
|
verbose_name=_("Advance Threshold"),
|
|
|
|
)
|
2023-12-16 01:05:05 +01:00
|
|
|
last_submission = models.ForeignKey(
|
|
|
|
"submission.Submission",
|
|
|
|
on_delete=models.SET_NULL,
|
|
|
|
related_name="pretalx_musicrate_settings",
|
|
|
|
null=True,
|
|
|
|
)
|
2023-12-16 03:29:52 +01:00
|
|
|
link_questions = models.ManyToManyField(
|
|
|
|
to="submission.Question",
|
|
|
|
related_name="pretalx_musicrate_settings_links",
|
|
|
|
verbose_name=_("Link Questions"),
|
|
|
|
blank=True,
|
|
|
|
)
|
2023-12-16 01:05:05 +01:00
|
|
|
|
|
|
|
|
2023-12-16 21:25:17 +01:00
|
|
|
class Juror(models.Model):
|
|
|
|
objects = ScopedManager(event="event")
|
|
|
|
|
2023-12-16 01:05:05 +01:00
|
|
|
event = models.ForeignKey(
|
|
|
|
"event.Event", on_delete=models.CASCADE, related_name="jurors"
|
|
|
|
)
|
|
|
|
token = models.CharField(max_length=43, default=generate_token, primary_key=True)
|
|
|
|
last_submission = models.ForeignKey(
|
|
|
|
"submission.Submission",
|
|
|
|
on_delete=models.SET_NULL,
|
|
|
|
related_name="jurors",
|
|
|
|
null=True,
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
class Rating(models.Model):
|
|
|
|
RATING_CHOICES = [
|
|
|
|
("10", "sehr gut"),
|
|
|
|
("9", "ziemlich gut"),
|
|
|
|
("8", "gut"),
|
|
|
|
("7", "eher gut"),
|
|
|
|
("6", "ok"),
|
|
|
|
("5", "naja"),
|
|
|
|
("4", "eher schlecht"),
|
|
|
|
("3", "schlecht"),
|
|
|
|
("2", "ziemlich schlecht"),
|
|
|
|
("1", "sehr schlecht"),
|
|
|
|
]
|
|
|
|
rating = models.CharField(max_length=2, choices=RATING_CHOICES, blank=True)
|
|
|
|
submission = models.ForeignKey(
|
|
|
|
"submission.Submission", on_delete=models.CASCADE, related_name="ratings"
|
|
|
|
)
|
|
|
|
juror = models.ForeignKey(Juror, on_delete=models.CASCADE, related_name="ratings")
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
constraints = [
|
|
|
|
models.UniqueConstraint(
|
|
|
|
fields=("submission", "juror"), name="unique_rating"
|
|
|
|
),
|
|
|
|
]
|
2024-02-13 15:30:34 +01:00
|
|
|
|
|
|
|
|
|
|
|
class Assignee(models.Model):
|
|
|
|
submission = models.OneToOneField("submission.Submission", on_delete=models.CASCADE)
|
|
|
|
user = models.ForeignKey(
|
|
|
|
"person.User", on_delete=models.CASCADE, related_name="assigned_submissions"
|
|
|
|
)
|