How to use the pretalx.person.models.User.objects.get 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 / orga / views / auth.py View on Github external
def dispatch(self, request, *args, **kwargs):
        try:
            self.user = User.objects.get(
                pw_reset_token=kwargs.get("token"),
                pw_reset_time__gte=now() - dt.timedelta(days=1),
            )
        except User.DoesNotExist:
            messages.error(self.request, phrases.cfp.auth_reset_fail)
            return redirect(reverse("orga:auth.reset"))
        return super().dispatch(request, *args, **kwargs)
github pretalx / pretalx / src / pretalx / person / forms.py View on Github external
def _clean_login(self, data):
        try:
            uname = User.objects.get(email__iexact=data.get("login_email")).email
        except User.DoesNotExist:  # We do this to avoid timing attacks
            uname = "user@invalid"

        user = authenticate(username=uname, password=data.get("login_password"))

        if user is None:
            raise ValidationError(
                _(
                    "No user account matches the entered credentials. "
                    "Are you sure that you typed your password correctly?"
                )
            )

        if not user.is_active:
            raise ValidationError(_("Sorry, your account is currently disabled."))
github pretalx / pretalx / src / pretalx / common / auth.py View on Github external
def authenticate(self, *args, token=None, **kwargs):
        if token:
            with suppress(User.DoesNotExist, MultipleObjectsReturned):
                return User.objects.get(auth_token__key__iexact=token)
        return None
github pretalx / pretalx / src / pretalx / cfp / forms / auth.py View on Github external
def clean(self):
        data = super().clean()
        try:
            user = User.objects.get(email__iexact=data.get("login_email"))
        except User.DoesNotExist:
            user = None

        data["user"] = user
        return data
github djangocon / 2019.djangocon.eu / dceu2019 / src / dceu2019 / apps / invoices / models.py View on Github external
from pretalx.person.models import User

        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 / orga / views / submission.py View on Github external
def form_valid(self, form):
        created = not self.object
        self.object = form.instance
        self._questions_form.submission = self.object
        if not self._questions_form.is_valid():
            return self.get(self.request, *self.args, **self.kwargs)
        form.instance.event = self.request.event
        form.save()
        self._questions_form.save()

        if created:
            email = form.cleaned_data["speaker"]
            try:
                speaker = User.objects.get(email__iexact=email)  # TODO: send email!
                messages.success(
                    self.request,
                    _(
                        "The submission has been created; the speaker already had an account on this system."
                    ),
                )
            except User.DoesNotExist:
                speaker = create_user_as_orga(
                    email=email,
                    name=form.cleaned_data["speaker_name"],
                    submission=form.instance,
                )
                messages.success(
                    self.request,
                    _(
                        "The submission has been created and the speaker has been invited to add an account!"
github pretalx / pretalx / src / pretalx / cfp / views / auth.py View on Github external
def dispatch(self, request, *args, **kwargs):
        try:
            self.user = User.objects.get(
                pw_reset_token=kwargs.get("token"),
                pw_reset_time__gte=now() - dt.timedelta(days=1),
            )
        except User.DoesNotExist:
            messages.error(self.request, phrases.cfp.auth_reset_fail)
            return redirect(
                reverse("cfp:event.reset", kwargs={"event": kwargs.get("event")})
            )

        return super().dispatch(request, *args, **kwargs)