pretalx-musicrate/pretalx_musicrate/models.py

53 lines
1.6 KiB
Python

from decimal import Decimal
from secrets import token_urlsafe
from django.db import models
from django.utils.translation import gettext_lazy as _
def generate_token():
return token_urlsafe(32)
class MusicrateSettings(models.Model):
event = models.OneToOneField(
to="event.Event",
on_delete=models.CASCADE,
related_name="pretalx_musicrate_settings",
)
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,
)
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,
)
join_token = models.CharField(max_length=43, default=generate_token)
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"),
)