bornhack-website/shop/managers.py

32 lines
665 B
Python
Raw Normal View History

2016-05-06 20:33:59 +00:00
from psycopg2.extras import DateTimeTZRange
from django.db.models import QuerySet
from django.utils import timezone
class ProductQuerySet(QuerySet):
2016-05-06 20:33:59 +00:00
def available(self):
return self.filter(
available_in__contains=timezone.now(),
category__public=True
2016-05-06 20:33:59 +00:00
)
2016-06-01 09:10:06 +00:00
class OrderQuerySet(QuerySet):
def not_cancelled(self):
return self.filter(cancelled=False)
def open(self):
return self.filter(open__isnull=True)
def paid(self):
return self.filter(paid=True)
def unpaid(self):
return self.filter(paid=False)
def cancelled(self):
return self.filter(cancelled=True)