How to use pretalx - 10 common examples

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 / common / management / commands / create_test_event.py View on Github external
def build_speaker(self):
        email = self.fake.user_name() + "@example.org"
        user = User.objects.filter(email__iexact=email).first()
        if user:
            return user
        user = User.objects.create_user(
            name=self.fake.name(),
            email=email,
            locale="en",
            timezone="Europe/Berlin",
            # TODO: generate avatar,
        )
        SpeakerProfile.objects.create(
            user=user, event=self.event, biography="\n\n".join(self.fake.texts(2))
        )
        return user
github pretalx / pretalx / src / pretalx / common / management / commands / create_test_event.py View on Github external
def build_submission(self, speaker, submission_type, submission_time):
        with self.freeze_time(submission_time):
            submission = Submission.objects.create(
                event=self.event,
                title=self.fake.catch_phrase(),
                submission_type=submission_type,
                track=random.choice(self.event.tracks.all()),
                abstract=self.fake.bs().capitalize() + "!",
                description=self.fake.text(),
                content_locale="en",
                do_not_record=random.choice([False] * 10 + [True]),
            )
            submission.log_action("pretalx.submission.create", person=speaker)
        submission.speakers.add(speaker)
        return submission
github pretalx / pretalx / src / pretalx / common / management / commands / create_test_event.py View on Github external
)
        if end_stage == "cfp":
            event_start = now() + dt.timedelta(days=35)
        elif end_stage == "review":
            event_start = now() + dt.timedelta(days=25)
        elif end_stage == "over":
            event_start = now() - dt.timedelta(days=10)
        else:  # end_stage == 'schedule'
            event_start = now() - dt.timedelta(days=1)
        self.bs = self.fake.bs()
        self.catch_phrase = self.fake.catch_phrase()
        intro = f"We provide a {self.catch_phrase.lower()} to {self.bs}."
        disclaimer = """This is an automatically generated event to test and showcase pretalx features.
Feel free to look around, but don\'t be alarmed if something doesn\'t quite make sense. You can always create your own free test event at [pretalx.com](https://pretalx.com)!"""
        with scopes_disabled():
            event = Event.objects.create(
                name="DemoCon",
                slug="democon",
                organiser=organiser,
                is_public=True,
                date_from=event_start.date(),
                date_to=event_start.date() + dt.timedelta(days=2),
                timezone="Europe/Berlin",
                email=self.fake.user_name() + "@example.org",
                primary_color=self.fake.hex_color(),
                locale_array="en",
                locale="en",
                landing_page_text=f"# Welcome to DemoCon!\n\n{intro}\n\n{disclaimer}",
            )
        with scope(event=event):
            event.build_initial_data()
            team.limit_events.add(event)
github pretalx / pretalx / src / pretalx / orga / forms / mails.py View on Github external
def save(self, *args, **kwargs):
        obj = super().save(*args, **kwargs)
        if self.has_changed() and "to" in self.changed_data:
            addresses = list(
                set(a.strip().lower() for a in (obj.to or "").split(",") if a.strip())
            )
            for address in addresses:
                user = User.objects.filter(email__iexact=address).first()
                if user:
                    addresses.remove(address)
                    obj.to_users.add(user)
            addresses = ",".join(addresses) if addresses else ""
            obj.to = addresses
            obj.save()
        return obj
github pretalx / pretalx / src / pretalx / orga / views / submission.py View on Github external
)

    @cached_property
    def object(self):
        return self.get_object()

    @context
    def submission(self):
        return self.object


class SubmissionStateChange(SubmissionViewMixin, TemplateView):
    permission_required = "orga.change_submission_state"
    template_name = "orga/submission/state_change.html"
    TARGETS = {
        "submit": SubmissionStates.SUBMITTED,
        "accept": SubmissionStates.ACCEPTED,
        "reject": SubmissionStates.REJECTED,
        "confirm": SubmissionStates.CONFIRMED,
        "delete": SubmissionStates.DELETED,
        "withdraw": SubmissionStates.WITHDRAWN,
        "cancel": SubmissionStates.CANCELED,
    }

    @cached_property
    def _target(self) -> str:
        """Returns one of
        submit|accept|reject|confirm|delete|withdraw|cancel."""
        return self.TARGETS[self.request.resolver_match.url_name.split(".")[-1]]

    @context
    def target(self):
github pretalx / pretalx / src / pretalx / orga / views / person.py View on Github external
def dispatch(self, request, *args, **kwargs):
        search = request.GET.get("search")
        if not search or len(search) < 2:
            return JsonResponse({"count": 0, "results": []})

        events = self.request.user.get_events_for_permission(
            can_change_submissions=True
        )
        queryset = User.objects.filter(
            Q(name__icontains=search) | Q(email__icontains=search),
            profiles__event__in=events,
        )
        if request.GET.get("orga", "false").lower() == "true":
            queryset = queryset.filter(teams__in=request.event.teams)

        return JsonResponse(
            {
                "count": len(queryset),
                "results": [
                    {"email": user.email, "name": user.name} for user in queryset
                ],
github pretalx / pretalx / src / pretalx / schedule / models / schedule.py View on Github external
def speakers_concerned(self):
        """Returns a dictionary of speakers with their new and changed talks in
        this schedule.

        Each speaker is assigned a dictionary with ``create`` and
        ``update`` fields, each containing a list of submissions.
        """
        if self.changes["action"] == "create":
            return {
                speaker: {
                    "create": self.talks.filter(submission__speakers=speaker),
                    "update": [],
                }
                for speaker in User.objects.filter(submissions__slots__schedule=self)
            }

        if self.changes["count"] == len(self.changes["canceled_talks"]):
            return []

        speakers = defaultdict(lambda: {"create": [], "update": []})
        for new_talk in self.changes["new_talks"]:
            for speaker in new_talk.submission.speakers.all():
                speakers[speaker]["create"].append(new_talk)
        for moved_talk in self.changes["moved_talks"]:
            for speaker in moved_talk["submission"].speakers.all():
                speakers[speaker]["update"].append(moved_talk)
        return speakers
github pretalx / pretalx / src / pretalx / event / models / event.py View on Github external
def speakers(self):
        """Returns a queryset of all speakers (of type.

        :class:`~pretalx.person.models.user.User`) visible in the current
        released schedule.
        """
        from pretalx.person.models import User

        return User.objects.filter(submissions__in=self.talks).order_by("id").distinct()
github pretalx / pretalx / src / pretalx / orga / views / mails.py View on Github external
track_id__in=tracks
                )
            )
            user_set.update(users)
        submission_types = form.cleaned_data.get("submission_types")
        if submission_types:
            users = User.objects.filter(
                submissions__in=self.request.event.submissions.filter(
                    submission_type_id__in=submission_types
                )
            )
            user_set.update(users)

        for recipient in form.cleaned_data.get("recipients"):
            if recipient == "reviewers":
                users = User.objects.filter(
                    teams__in=self.request.event.teams.filter(is_reviewer=True)
                ).distinct()
            elif recipient == "no_slides":
                users = User.objects.filter(
                    submissions__in=self.request.event.submissions.filter(
                        resources__isnull=True, state="confirmed"
                    )
                )
            else:
                submission_filter = {"state": recipient}  # e.g. "submitted"

                users = User.objects.filter(
                    submissions__in=self.request.event.submissions.filter(
                        **submission_filter
                    )
                )
github pretalx / pretalx / src / pretalx / common / views.py View on Github external
def form_valid(self, form):
        pk = form.save()
        user = User.objects.filter(pk=pk).first()
        if not user:
            messages.error(
                self.request,
                _(
                    "There was an error when logging in. Please contact the organiser for further help."
                ),
            )
            return redirect(self.get_error_url())
        if not user.is_active:
            messages.error(self.request, _("User account is deactivated."))
            return redirect(self.get_error_redirect())

        login(self.request, user, backend="django.contrib.auth.backends.ModelBackend")

        params = self.request.GET.copy()
        url = urllib.parse.unquote(params.pop("next", [""])[0])