How to use the pretix.base.models.OrderPosition.objects.filter function in pretix

To help you get started, we’ve selected a few pretix 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 pretix / pretix / src / pretix / base / exporters / orderlist.py View on Github external
def _get_all_tax_rates(self, qs):
        tax_rates = set(
            a for a
            in OrderFee.objects.filter(
                order__event=self.event
            ).values_list('tax_rate', flat=True).distinct().order_by()
        )
        tax_rates |= set(
            a for a
            in OrderPosition.objects.filter(
                order__event=self.event
            ).values_list('tax_rate', flat=True).distinct().order_by()
        )
        tax_rates = sorted(tax_rates)
        return tax_rates
github pretix / pretix / src / pretix / plugins / pretixdroid / views.py View on Github external
def get(self, request, **kwargs):

        cqs = Checkin.objects.filter(
            position__order__event=self.event, position__subevent=self.subevent,
            position__order__status__in=[Order.STATUS_PAID] + ([Order.STATUS_PENDING] if
                                                               self.config.list.include_pending else []),
            list=self.config.list
        )
        pqs = OrderPosition.objects.filter(
            order__event=self.event,
            order__status__in=[Order.STATUS_PAID] + ([Order.STATUS_PENDING] if self.config.list.include_pending else
                                                     []),
            subevent=self.subevent,
        )
        if not self.config.list.all_products:
            pqs = pqs.filter(item__in=self.config.list.limit_products.values_list('id', flat=True))

        ev = self.subevent or self.event
        response = {
            'version': API_VERSION,
            'event': {
                'name': str(ev.name),
                'list': self.config.list.name,
                'slug': self.event.slug,
                'organizer': {
github pretix / pretix / src / pretix / base / models / items.py View on Github external
def count_paid_orders(self):
        from pretix.base.models import Order, OrderPosition

        return OrderPosition.objects.filter(
            self._position_lookup, order__status=Order.STATUS_PAID, order__event=self.event, subevent=self.subevent
        ).count()
github pretix / pretix / src / pretix / control / views / search.py View on Github external
def get_context_data(self, **kwargs):
        ctx = super().get_context_data()
        ctx['filter_form'] = self.filter_form

        # Only compute this annotations for this page (query optimization)
        s = OrderPosition.objects.filter(
            order=OuterRef('pk')
        ).order_by().values('order').annotate(k=Count('id')).values('k')
        annotated = {
            o['pk']: o
            for o in
            Order.objects.using(settings.DATABASE_REPLICA).filter(
                pk__in=[o.pk for o in ctx['orders']]
            ).annotate(
                pcnt=Subquery(s, output_field=IntegerField())
            ).values(
                'pk', 'pcnt',
            )
        }

        for o in ctx['orders']:
            if o.pk not in annotated:
github pretix / pretix / src / pretix / base / models / items.py View on Github external
def count_pending_orders(self) -> dict:
        from pretix.base.models import Order, OrderPosition

        # This query has beeen benchmarked against a Count('id', distinct=True) aggregate and won by a small margin.
        return OrderPosition.objects.filter(
            self._position_lookup, order__status=Order.STATUS_PENDING, order__event=self.event, subevent=self.subevent
        ).count()