Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import datetime as dt
from typing import List
from django.db import models
from django.utils.functional import cached_property
from django_scopes import ScopedManager
from pretalx.common.mixins import LogMixin
zerotime = dt.time(0, 0)
class Availability(LogMixin, models.Model):
"""The Availability class models when people or rooms are available for.
:class:`~pretalx.schedule.models.slot.TalkSlot` objects.
The power of this class is not within its rather simple data model,
but with the operations available on it. An availability object can
span multiple days, but due to our choice of input widget, it will
usually only span a single day at most.
"""
event = models.ForeignKey(
to="event.Event", related_name="availabilities", on_delete=models.CASCADE
)
person = models.ForeignKey(
to="person.SpeakerProfile",
related_name="availabilities",
from django.core.validators import RegexValidator
from django.db import models, transaction
from django.utils.crypto import get_random_string
from django.utils.functional import cached_property
from django.utils.translation import gettext_lazy as _
from django_scopes import scope, scopes_disabled
from i18nfield.fields import I18nCharField
from pretalx.common.mixins import LogMixin
from pretalx.common.urls import EventUrls, build_absolute_uri
from pretalx.person.models import User
SLUG_CHARS = "a-zA-Z0-9.-"
class Organiser(LogMixin, models.Model):
"""The Organiser model represents the entity responsible for at least one.
:class:`~pretalx.event.models.event.Event`.
"""
name = I18nCharField(max_length=190, verbose_name=_("Name"))
slug = models.SlugField(
max_length=50,
db_index=True,
unique=True,
validators=[
RegexValidator(
regex=f"^[{SLUG_CHARS}]+$",
message=_(
"The slug may only contain letters, numbers, dots and dashes."
),
import datetime as dt
from urllib.parse import urlparse
import pytz
from django.db import models
from django.utils.functional import cached_property
from django.utils.translation import gettext_lazy as _
from django_scopes import ScopedManager
from i18nfield.fields import I18nCharField
from pretalx.common.mixins import LogMixin
from pretalx.common.urls import get_base_url
class TalkSlot(LogMixin, models.Model):
"""The TalkSlot object is the scheduled version of a.
:class:`~pretalx.submission.models.submission.Submission`.
TalkSlots always belong to one submission and one :class:`~pretalx.schedule.models.schedule.Schedule`.
:param is_visible: This parameter is set on schedule release. Only confirmed talks will be visible.
"""
submission = models.ForeignKey(
to="submission.Submission",
on_delete=models.PROTECT,
related_name="slots",
null=True,
blank=True, # If the submission is empty, this is a break or similar event
)
import datetime as dt
from django.db import models
from django.utils.functional import cached_property
from django.utils.timezone import now
from django.utils.translation import gettext_lazy as _
from django_scopes import ScopedManager
from i18nfield.fields import I18nCharField, I18nTextField
from pretalx.common.mixins import LogMixin
from pretalx.common.phrases import phrases
from pretalx.common.urls import EventUrls
class CfP(LogMixin, models.Model):
"""Every :class:`~pretalx.event.models.event.Event` has one Call for
P(apers|articipation|roposals).
:param deadline: The regular deadline. Please note that submissions can be available for longer than this if different deadlines are configured on single submission types.
"""
event = models.OneToOneField(to="event.Event", on_delete=models.PROTECT)
headline = I18nCharField(
max_length=300, null=True, blank=True, verbose_name=_("headline")
)
text = I18nTextField(
null=True,
blank=True,
verbose_name=_("text"),
help_text=phrases.base.use_markdown,
)
import math
from django.db import models
from django.utils.timezone import now
from django.utils.translation import ugettext_lazy as _
from pretalx.common.mixins import LogMixin
from pretalx.common.mixins.models import GenerateCode
from pretalx.common.urls import EventUrls
class SubmitterAccessCode(LogMixin, GenerateCode, models.Model):
event = models.ForeignKey(
to="event.Event",
on_delete=models.CASCADE,
related_name="submitter_access_codes",
)
code = models.CharField(
verbose_name=_("Access code"), max_length=255, db_index=True,
)
track = models.ForeignKey(
to="submission.Track",
on_delete=models.CASCADE,
verbose_name=_("Track"),
help_text=_(
"You can restrict the access code to a single track, or leave it open for all tracks."
),
related_name="submitter_access_codes",
import string
from django.db import models
from django.utils.crypto import get_random_string
from django.utils.translation import ugettext_lazy as _
from pretalx.common.mixins import LogMixin
from pretalx.common.urls import EventUrls, build_absolute_uri
# TODO: Delete this unused class in June 2018 when we're sure migrations went well
class EventPermission(LogMixin, models.Model):
event = models.ForeignKey(
to='event.Event',
related_name='permissions',
on_delete=models.CASCADE,
)
user = models.ForeignKey(
to='person.User',
related_name='permissions',
on_delete=models.CASCADE,
null=True, blank=True,
)
is_orga = models.BooleanField(
default=True,
verbose_name=_('Organises the event'),
)
is_reviewer = models.BooleanField(
]
class QuestionTarget(Choices):
SUBMISSION = "submission"
SPEAKER = "speaker"
REVIEWER = "reviewer"
valid_choices = [
(SUBMISSION, _("per submission")),
(SPEAKER, _("per speaker")),
(REVIEWER, _("for reviewers")),
]
class Question(LogMixin, models.Model):
"""Questions can be asked per.
:class:`~pretalx.submission.models.submission.Submission`, per speaker, or
of reviewers per :class:`~pretalx.submission.models.review.Review`.
Questions can have many types, which offers a flexible framework to give organisers
the opportunity to get all the information they need.
:param variant: Can be any of 'number', 'string', 'text', 'boolean',
'file', 'choices', or 'multiple_choice'. Defined in the
``QuestionVariant`` class.
:param target: Can be any of 'submission', 'speaker', or 'reviewer'.
Defined in the ``QuestionTarget`` class.
:param required: If this is ``True``, the answer must be given at
submission time. On boolean questions: must check box.
:param position: Position in the question order in this event.
to="submission.Question", on_delete=models.PROTECT, related_name="options"
)
answer = I18nCharField(max_length=200)
objects = ScopedManager(event="question__event")
@cached_property
def event(self):
return self.question.event
def __str__(self):
"""Used in choice forms."""
return str(self.answer)
class Answer(LogMixin, models.Model):
"""Answers are connected to a.
:class:`~pretalx.submission.models.question.Question`, and, depending on
type, a :class:`~pretalx.person.models.user.User`, a
:class:`~pretalx.submission.models.submission.Submission`, or a
:class:`~pretalx.submission.models.review.Review`.
"""
question = models.ForeignKey(
to="submission.Question", on_delete=models.PROTECT, related_name="answers"
)
submission = models.ForeignKey(
to="submission.Submission",
on_delete=models.PROTECT,
related_name="answers",
null=True,