2016-12-25 14:52:55 +00:00
|
|
|
from django.conf import settings
|
2016-05-06 20:33:59 +00:00
|
|
|
from .models import Camp
|
2016-12-25 14:52:55 +00:00
|
|
|
from django.utils import timezone
|
2016-05-06 20:33:59 +00:00
|
|
|
|
|
|
|
|
2016-12-28 23:15:13 +00:00
|
|
|
def camp(request):
|
2017-01-20 15:18:10 +00:00
|
|
|
"""
|
|
|
|
if we have a camp_slug url component then get the "current" Camp object.
|
|
|
|
Return it after adding the slug to request.session along with a "camps"
|
|
|
|
queryset containing all camps (used to build the menu and such)
|
|
|
|
"""
|
2016-12-28 23:15:13 +00:00
|
|
|
if 'camp_slug' in request.resolver_match.kwargs:
|
|
|
|
camp = Camp.objects.get(slug=request.resolver_match.kwargs['camp_slug'])
|
|
|
|
request.session['campslug'] = camp.slug
|
|
|
|
else:
|
|
|
|
request.session['campslug'] = None
|
|
|
|
camp = None
|
|
|
|
|
2016-12-25 14:52:55 +00:00
|
|
|
return {
|
2017-01-20 15:18:10 +00:00
|
|
|
'camps': Camp.objects.all().order_by('-camp'),
|
2016-12-28 23:15:13 +00:00
|
|
|
'camp': camp
|
2016-12-25 14:52:55 +00:00
|
|
|
}
|
|
|
|
|