def checkin_widget(sender, subevent=None, **kwargs): size_qs = OrderPosition.objects.filter(order__event=sender, order__status='p') checked_qs = OrderPosition.objects.filter(order__event=sender, order__status='p', checkins__isnull=False) # if this setting is False, we check only items for admission if not sender.settings.ticket_download_nonadm: size_qs = size_qs.filter(item__admission=True) checked_qs = checked_qs.filter(item__admission=True) widgets = [] qs = sender.checkin_lists.filter(subevent=subevent) qs = CheckinList.annotate_with_numbers(qs, sender) for cl in qs: widgets.append({ 'content': NUM_WIDGET.format( num='{}/{}'.format(cl.checkin_count, cl.position_count), text=_('Checked in – {list}').format(list=escape(cl.name))), 'display_size': 'small', 'priority': 50, 'url': reverse('control:event.orders.checkinlists.show', kwargs={ 'event': sender.slug, 'organizer': sender.organizer.slug, 'list': cl.pk }) }) return widgets
def get_queryset(self): qs = self.request.event.checkin_lists.prefetch_related("limit_products") qs = CheckinList.annotate_with_numbers(qs, self.request.event) if self.request.GET.get("subevent", "") != "": s = self.request.GET.get("subevent", "") qs = qs.filter(subevent_id=s) return qs
def get_queryset(self): qs = self.request.event.checkin_lists.prefetch_related("limit_products") qs = CheckinList.annotate_with_numbers(qs, self.request.event) if self.request.GET.get("subevent", "") != "": s = self.request.GET.get("subevent", "") qs = qs.filter(subevent_id=s) return qs
def get_form_kwargs(self): kwargs = super().get_form_kwargs() if self.copy_from: i = modelcopy(self.copy_from) i.pk = None kwargs['instance'] = i else: kwargs['instance'] = CheckinList(event=self.request.event) return kwargs
def checkin_widget(sender, subevent=None, **kwargs): widgets = [] qs = sender.checkin_lists.filter(subevent=subevent) qs = CheckinList.annotate_with_numbers(qs, sender) for cl in qs: widgets.append({ 'content': NUM_WIDGET.format(num='{}/{}'.format(cl.checkin_count, cl.position_count), text=_('Checked in – {list}').format(list=escape(cl.name))), 'display_size': 'small', 'priority': 50, 'url': reverse('control:event.orders.checkinlists.show', kwargs={ 'event': sender.slug, 'organizer': sender.organizer.slug, 'list': cl.pk }) }) return widgets
def checkin_widget(sender, subevent=None, **kwargs): widgets = [] qs = sender.checkin_lists.filter(subevent=subevent) qs = CheckinList.annotate_with_numbers(qs, sender) for cl in qs: widgets.append({ 'content': NUM_WIDGET.format(num='{}/{}'.format(cl.checkin_count, cl.position_count), text=_('Checked in – {list}').format(list=escape(cl.name))), 'display_size': 'small', 'priority': 50, 'url': reverse('control:event.orders.checkinlists.show', kwargs={ 'event': sender.slug, 'organizer': sender.organizer.slug, 'list': cl.pk }) }) return widgets
def get_context_data(self, **kwargs): ctx = super().get_context_data(**kwargs) clists = list(ctx['checkinlists']) # Optimization: Fetch expensive columns for this page only annotations = { a['pk']: a for a in CheckinList.annotate_with_numbers(CheckinList.objects.filter(pk__in=[l.pk for l in clists]), self.request.event).values( 'pk', 'checkin_count', 'position_count', 'percent' ) } for cl in clists: if cl.subevent: cl.subevent.event = self.request.event # re-use same event object to make sure settings are cached cl.checkin_count = annotations.get(cl.pk, {}).get('checkin_count', 0) cl.position_count = annotations.get(cl.pk, {}).get('position_count', 0) cl.percent = annotations.get(cl.pk, {}).get('percent', 0) ctx['checkinlists'] = clists return ctx
def clean(self): d = super().clean() CheckinList.validate_rules(d.get('rules')) return d