bornhack-website/shop/context_processors.py

23 lines
571 B
Python
Raw Normal View History

2016-05-30 22:58:11 +00:00
from django.conf import settings
def current_order(request):
if request.user.is_authenticated():
order = None
2016-05-15 22:09:00 +00:00
orders = request.user.orders.filter(open__isnull=False)
if orders:
order = orders[0]
return {'current_order': order}
return {}
2016-05-30 22:58:11 +00:00
def user_has_tickets(request):
has_tickets = False
if hasattr(request.user, 'orders') and request.user.orders.filter(
2016-05-30 22:58:11 +00:00
tickets__product__category__pk=settings.TICKET_CATEGORY_ID
).exists():
has_tickets = True
return {'has_tickets': has_tickets}