How to use the pretalx.person.models.User.objects.filter 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 / 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 / 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 / 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])
github pretalx / pretalx / src / pretalx / orga / views / speaker.py View on Github external
def get_object(self):
        return get_object_or_404(
            User.objects.filter(
                submissions__in=Submission.all_objects.filter(event=self.request.event)
            )
            .order_by("id")
            .distinct(),
            pk=self.kwargs["pk"],
        )
github pretalx / pretalx / src / pretalx / person / forms.py View on Github external
def _clean_register(self, data):
        if data.get("register_password") != data.get("register_password_repeat"):
            self.add_error(
                "register_password_repeat",
                ValidationError(phrases.base.passwords_differ),
            )

        if User.objects.filter(email__iexact=data.get("register_email")).exists():
            self.add_error(
                "register_email",
                ValidationError(
                    _(
                        "We already have a user with that email address. Did you already register "
                        "before and just need to log in?"
github djangocon / 2019.djangocon.eu / dceu2019 / src / dceu2019 / apps / ticketholders / management / commands / email_ticketholders.py View on Github external
if options['registered']:
            users = users.exclude(Q(password__startswith='!') | Q(password__isnull=True))

        users = users.distinct()

        emails = set()

        if options['users']:
            self.stdout.write(self.style.WARNING("Sending to {} users".format(users.count())))
            for u in users:
                emails.add(u.email.lower())
        else:
            self.stdout.write(self.style.WARNING("Not sending to any users"))

        # ALWAYS keep active staff in the loop
        for admin in User.objects.filter(is_active=True, is_staff=True):
            emails.add(admin.email.lower())

        no_unsubscribe = emails.copy()

        if options['newsletter']:
            self.stdout.write(self.style.WARNING("Sending to newsletter recipients as well"))
            for subscriber in models.Subscription.objects.filter(confirmed=True):
                emails.add(subscriber.email.lower())

        if options['test']:
            self.stdout.write(self.style.WARNING("Sending just a test to: {}".format(options['test'])))
            no_unsubscribe = set()
            emails = set()
            emails.add(options['test'])

        email_template.populate_recipients(emails)