bornhack-website/src/shop/context_processors.py
2017-01-31 23:26:45 +01:00

24 lines
576 B
Python

from django.conf import settings
def current_order(request):
if request.user.is_authenticated():
order = None
orders = request.user.orders.filter(open__isnull=False)
if orders:
order = orders[0]
return {'current_order': order}
return {}
def user_has_tickets(request):
has_tickets = False
if hasattr(request.user, 'orders') and request.user.orders.filter(
tickets__product__category__name=settings.TICKET_CATEGORY_NAME
).exists():
has_tickets = True
return {'has_tickets': has_tickets}