How to use the pretalx.person.models.User.objects 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 / 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 / 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 / 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 / schedule / utils.py View on Github external
event=event, code=code, defaults={"submission_type": sub_type}
    )
    sub.submission_type = sub_type
    sub.track = track
    sub.title = talk.find("title").text
    sub.description = talk.find("description").text
    if talk.find("subtitle").text:
        sub.description = talk.find("subtitle").text + "\n" + (sub.description or "")
    sub.abstract = talk.find("abstract").text
    sub.content_locale = talk.find("language").text or "en"
    sub.do_not_record = optout
    sub.state = SubmissionStates.CONFIRMED
    sub.save()

    for person in talk.find("persons").findall("person"):
        user = User.objects.filter(name=person.text[:60]).first()
        if not user:
            user = User(name=person.text, email=f"{person.text}@localhost")
            user.save()
            SpeakerProfile.objects.create(user=user, event=event)
        sub.speakers.add(user)

    slot, _ = TalkSlot.objects.get_or_create(
        submission=sub, schedule=event.wip_schedule, is_visible=True
    )
    slot.room = room
    slot.is_visible = True
    slot.start = start
    slot.end = end
    slot.save()
github pretalx / pretalx / src / pretalx / cfp / flow.py View on Github external
def done(self, request):
        if not getattr(request.user, "is_authenticated", False):
            form = self.get_form(from_storage=True)
            form.is_valid()
            uid = form.save()
            request.user = User.objects.filter(pk=uid).first()
        if not request.user or not request.user.is_active:
            raise ValidationError(
                _(
                    "There was an error when logging in. Please contact the organiser for further help."
                ),
            )
        login(
            request, request.user, backend="django.contrib.auth.backends.ModelBackend"
        )
github pretalx / pretalx / src / pretalx / orga / management / commands / import_schedule.py View on Github external
can_change_organiser_settings=True,
                can_change_event_settings=True,
                can_change_submissions=True,
            ).first()
            if not team:
                team = Team.objects.create(
                    name=str(event.name) + " Organisers",
                    organiser=event.organiser,
                    all_events=True,
                    can_create_events=True,
                    can_change_teams=True,
                    can_change_organiser_settings=True,
                    can_change_event_settings=True,
                    can_change_submissions=True,
                )
            for user in User.objects.filter(is_administrator=True):
                team.members.add(user)
            team.save()

        self.stdout.write(self.style.SUCCESS(process_frab(root, event)))
github djangocon / 2019.djangocon.eu / dceu2019 / src / dceu2019 / apps / invoices / models.py View on Github external
try:
            ticket = TicketbutlerTicket.objects.filter(user__email__iexact=email, ticketbutler_orderid=ticketbutler_orderid).order_by('id')[0]
            # Ensure that the user is marked as active in case of previous
            # import bugs of if the user had a refund and got deactivated
            ticket.user.is_active = True
            ticket.ticketbutler_ticket_type_name = ticket_type_name
            ticket.user.save()
            ticket.save()
            return ticket
        except IndexError:
            pass

        try:
            user = User.objects.get(email=email.lower())
        except User.DoesNotExist:
            user = User.objects.create_user(email=email.lower(), name=name)

        return TicketbutlerTicket.objects.create(
            user=user,
            ticketbutler_orderid=ticketbutler_orderid,
            sprints=sprints,
            ticketbutler_ticket_type_name=ticket_type_name,
        )
github pretalx / pretalx / src / pretalx / event / models / event.py View on Github external
def submitters(self):
        """Returns a queryset of all :class:`~pretalx.person.models.user.User`
        objects who have submitted to this event.

        Ignores users who have deleted all of their submissions.
        """
        from pretalx.person.models import User

        return (
            User.objects.filter(submissions__in=self.submissions.all())
            .prefetch_related("submissions")
            .order_by("id")
            .distinct()