def get_queryset(self): base = Billet.objects.filter( order__event__organizer__membership__user=self.request.user) | Billet.objects.filter( order__event__membership__user=self.request.user) if 'status' in self.request.GET: status = self.request.GET.get('status', '') base = base.filter(order__in=Order.accountable_orders(), canceled=False) if status == 'accountable': pass elif status == 'validated': base = base.filter(order__in=Order.objects.filter(status=Order.STATUS_VALIDATED)) if 'event' in self.request.GET: event = self.request.GET.get('event', '') event = self.allowed_events().get(id=event) base = base.filter(order__event=event) if 'products' in self.request.GET: products = self.products_for_order() base = base.filter(product__in=products) return base
def get_queryset(self): base = Answer.objects.filter(question__in=Question.objects.filter( Q(option__event__organizer__membership__user=self.request.user) | Q(product__event__organizer__membership__user=self.request.user) | Q(option__event__membership__user=self.request.user) | Q(product__event__membership__user=self.request.user))) if 'question' in self.request.GET: question = self.request.GET.get('question', '') base = base.filter(question=question) if 'status' in self.request.GET: status = self.request.GET.get('status', '') if status == 'accountable': base = base.filter(order__in=Order.accountable_orders()) elif status == 'validated': base = base.filter(order__status=Order.STATUS_VALIDATED) elif status == 'any': base = base else: if self.action == 'list': base = base.filter(order__status=Order.STATUS_VALIDATED) return base
def get_queryset(self): base = Order.objects.filter( event__organizer__membership__user=self.request.user) | Order.objects.filter( event__membership__user=self.request.user) if 'status' in self.request.GET: status = self.request.GET.get('status', '') if status == 'accountable': base = base.filter(id__in=Order.accountable_orders()) elif status == 'validated': base = base.filter(status=Order.STATUS_VALIDATED) elif status == 'any': base = base else: if self.action == 'list': base = base.filter(status=Order.STATUS_VALIDATED) if 'search' in self.request.GET: search = self.request.GET.get('search', '').split(' ') for word in search: base = base.filter(Q(client__first_name__icontains=word) | Q(client__last_name__icontains=word) | Q(client__email__icontains=word) | Q(transaction__mercanet__transactionReference=word)) base = base.order_by('created_at').reverse() return base
def clean_old_orders(): deleted, _ = Order.objects.exclude( id__in=Order.accountable_orders()).delete() return deleted