How to use the pretalx.common.urls.EventUrls function in pretalx

To help you get started, we’ve selected a few pretalx examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pretalx / pretalx / src / pretalx / submission / models / review.py View on Github external
return self.submission.event

    @cached_property
    def display_score(self) -> str:
        """Helper method to get a display string of the review's score."""
        if self.override_vote is True:
            return _("Positive override")
        if self.override_vote is False:
            return _("Negative override (Veto)")
        if self.score is None:
            return "×"
        return self.submission.event.settings.get(
            f"review_score_name_{self.score}"
        ) or str(self.score)

    class urls(EventUrls):
        base = "{self.submission.orga_urls.reviews}"
        delete = "{base}{self.pk}/delete"


class ReviewPhase(models.Model):
    """ReviewPhases determine reviewer access rights during a (potentially
    open) timeframe.

    :param is_active: Is this phase currently active? There can be only one
        active phase per event. Use the ``activate`` method to activate a
        review phase, as it will take care of this limitation.
    :param position: Helper field to deal with relative positioning of review
        phases next to each other.
    """

    event = models.ForeignKey(
github pretalx / pretalx / src / pretalx / person / models / profile.py View on Github external
verbose_name=_("Biography"),
        help_text=phrases.base.use_markdown,
        null=True,
        blank=True,
    )
    has_arrived = models.BooleanField(
        default=False, verbose_name=_("The speaker has arrived")
    )

    objects = ScopedManager(event="event")

    class urls(EventUrls):
        public = "{self.event.urls.base}speaker/{self.user.code}/"
        talks_ical = "{self.urls.public}talks.ics"

    class orga_urls(EventUrls):
        base = "{self.event.orga_urls.speakers}{self.user.id}/"
        password_reset = "{self.event.orga_urls.speakers}{self.user.id}/reset"
        toggle_arrived = "{self.event.orga_urls.speakers}{self.user.id}/toggle-arrived"

    def __str__(self):
        """Help when debugging."""
        user = self.user.get_display_name() if self.user else None
        return f"SpeakerProfile(event={self.event.slug}, user={user})"

    @cached_property
    def code(self):
        return self.user.code

    @cached_property
    def submissions(self):
        """All non-deleted.
github pretalx / pretalx / src / pretalx / submission / models / question.py View on Github external
verbose_name=_("Publish answers"),
        help_text=_(
            "Answers will be shown on talk or speaker pages as appropriate. Please note that you cannot make a question public after the first answers have been given, to allow speakers explicit consent before publishing information."
        ),
    )
    is_visible_to_reviewers = models.BooleanField(
        default=True,
        verbose_name=_("Show answers to reviewers"),
        help_text=_(
            "Should answers to this question be shown to reviewers? This is helpful if you want to collect personal information, but use anonymous reviews."
        ),
    )
    objects = ScopedManager(event="event", _manager_class=QuestionManager)
    all_objects = ScopedManager(event="event", _manager_class=AllQuestionManager)

    class urls(EventUrls):
        base = "{self.event.cfp.urls.questions}{self.pk}/"
        edit = "{base}edit"
        up = "{base}up"
        down = "{base}down"
        delete = "{base}delete"
        toggle = "{base}toggle"

    def __str__(self):
        """Help when debugging."""
        return f"Question(event={self.event.slug}, variant={self.variant}, target={self.target}, question={self.question})"

    @cached_property
    def grouped_answers(self):
        if self.variant == QuestionVariant.FILE:
            return [{"answer": answer, "count": 1} for answer in self.answers.all()]
        if self.variant in [QuestionVariant.CHOICES, QuestionVariant.MULTIPLE]:
github pretalx / pretalx / src / pretalx / common / exporter.py View on Github external
Override the get_qr_code method to override the QR code itself.
        """
        return False

    @property
    def icon(self) -> str:
        """Return either a fa- string or some other symbol to accompany the
        exporter in displays."""
        raise NotImplementedError()  # NOQA

    def render(self, **kwargs) -> Tuple[str, str, str]:
        """Render the exported file and return a tuple consisting of a file
        name, a file type and file content."""
        raise NotImplementedError()  # NOQA

    class urls(EventUrls):
        """The urls.base attribute contains the relative URL where this
        exporter's data will be found, e.g. /event/schedule/export/myexport.ext
        Use ``exporter.urls.base.full()`` for the complete URL, taking into
        account the configured event URL, or HTML export URL."""

        base = "{self.event.urls.export}{self.quoted_identifier}"

    def get_qrcode(self):
        image = qrcode.make(
            self.urls.base.full(), image_factory=qrcode.image.svg.SvgImage
        )
        return mark_safe(ET.tostring(image.get_image()).decode())


class CSVExporterMixin:
    def render(self, **kwargs):
github pretalx / pretalx / src / pretalx / schedule / models / room.py View on Github external
)
    position = models.PositiveIntegerField(
        null=True,
        blank=True,
        verbose_name=_("Position"),
        help_text=_(
            "This is the order that rooms are displayed in in the schedule (lower = left)."
        ),
    )

    objects = ScopedManager(event="event")

    class Meta:
        ordering = ("position",)

    class urls(EventUrls):
        settings_base = edit = "{self.event.orga_urls.room_settings}{self.pk}/"
        delete = "{settings_base}delete"
        up = "{settings_base}up"
        down = "{settings_base}down"

    def __str__(self) -> str:
        return str(self.name)
github pretalx / pretalx / src / pretalx / submission / models / cfp.py View on Github external
on_delete=models.PROTECT,
        related_name="+",
        verbose_name=_("Default submission type"),
    )
    deadline = models.DateTimeField(
        null=True,
        blank=True,
        verbose_name=_("deadline"),
        help_text=_(
            "Please put in the last date you want to accept submissions from users."
        ),
    )

    objects = ScopedManager(event="event")

    class urls(EventUrls):
        base = "{self.event.orga_urls.cfp}"
        editor = "{base}flow/"
        questions = "{base}questions/"
        new_question = "{questions}new"
        remind_questions = "{questions}remind"
        text = edit_text = "{base}text"
        types = "{base}types/"
        new_type = "{types}new"
        tracks = "{base}tracks/"
        new_track = "{tracks}new"
        access_codes = "{base}access-codes/"
        new_access_code = "{access_codes}new"
        public = "{self.event.urls.base}cfp"
        submit = "{self.event.urls.base}submit/"

    def __str__(self) -> str:
github pretalx / pretalx / src / pretalx / event / models / organiser.py View on Github external
message=_(
                    "The slug may only contain letters, numbers, dots and dashes."
                ),
            )
        ],
        verbose_name=_("Short form"),
        help_text=_(
            "Should be short, only contain lowercase letters and numbers, and must be unique, as it is used in URLs."
        ),
    )

    def __str__(self) -> str:
        """Used in generated forms."""
        return str(self.name)

    class orga_urls(EventUrls):
        base = "/orga/organiser/{self.slug}/"
        delete = "{base}delete"
        teams = "{base}teams/"
        new_team = "{teams}new"

    @transaction.atomic
    def shred(self):
        """Irrevocably deletes the organiser and all related events and their
        data."""
        for event in self.events.all():
            with scope(event=event):
                event.shred()
        with scopes_disabled():
            self.logged_actions().delete()
        self.delete()
github pretalx / pretalx / src / pretalx / event / models / event.py View on Github external
new_room = "{room_settings}new"
        schedule = "{base}schedule/"
        schedule_export = "{schedule}export/"
        schedule_export_trigger = "{schedule_export}trigger"
        schedule_export_download = "{schedule_export}download"
        release_schedule = "{schedule}release"
        reset_schedule = "{schedule}reset"
        toggle_schedule = "{schedule}toggle"
        reviews = "{base}reviews/"
        schedule_api = "{base}schedule/api/"
        talks_api = "{schedule_api}talks/"
        plugins = "{settings}plugins"
        information = "{base}info/"
        new_information = "{base}info/new"

    class api_urls(EventUrls):
        base = "/api/events/{self.slug}/"
        submissions = "{base}submissions/"
        talks = "{base}talks/"
        schedules = "{base}schedules/"
        speakers = "{base}speakers/"
        reviews = "{base}reviews/"
        rooms = "{base}rooms/"

    class Meta:
        ordering = ("date_from",)

    def __str__(self) -> str:
        return str(self.name)

    @cached_property
    def locales(self) -> list:
github pretalx / pretalx / src / pretalx / submission / models / review.py View on Github external
verbose_name=_("Reviewers can accept and reject submissions"), default=False,
    )
    speakers_can_change_submissions = models.BooleanField(
        verbose_name=_("Speakers can modify their submissions before acceptance"),
        help_text=_(
            "By default, modification of submissions is locked after the CfP ends, and is re-enabled once the submission was accepted."
        ),
        default=False,
    )

    objects = ScopedManager(event="event")

    class Meta:
        ordering = ("position",)

    class urls(EventUrls):
        base = "{self.event.orga_urls.review_settings}phase/{self.pk}/"
        delete = "{base}delete"
        up = "{base}up"
        down = "{base}down"
        activate = "{base}activate"

    def activate(self) -> None:
        """Activates this review phase and deactivates all others in this
        event."""
        self.event.review_phases.all().update(is_active=False)
        self.is_active = True
        self.save()

    activate.alters_data = True
github pretalx / pretalx / src / pretalx / event / models / organiser.py View on Github external
"""A TeamInvite is someone who has been invited to a team but hasn't accept
    the invitation yet."""

    team = models.ForeignKey(to=Team, related_name="invites", on_delete=models.CASCADE)
    email = models.EmailField(null=True, blank=True, verbose_name=_("Email"))
    token = models.CharField(
        default=generate_invite_token, max_length=64, null=True, blank=True
    )

    def __str__(self) -> str:
        """Help with debugging."""
        return _("Invite to team {team} for {email}").format(
            team=str(self.team), email=self.email
        )

    class urls(EventUrls):
        invitation = "/orga/invitation/{self.token}"

    def send(self, event):
        from pretalx.mail.models import QueuedMail

        invitation_link = build_absolute_uri(
            "orga:invitation.view", kwargs={"code": self.token}
        )
        invitation_text = _(
            """Hi!
You have been invited to the {name} event organiser team - Please click here to accept:

{invitation_link}

See you there,
The {event} team"""