From f9c483c8d332f365f01619f3e7c2097854448a45 Mon Sep 17 00:00:00 2001 From: Robert Einsle Date: Sun, 26 Feb 2017 12:20:50 +0100 Subject: [PATCH] fix error in view.py --- billard/views.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/billard/views.py b/billard/views.py index 9601f70..553ab9c 100644 --- a/billard/views.py +++ b/billard/views.py @@ -35,16 +35,18 @@ class LocationDataDetailView(DetailView): def index(request): if request.method == 'GET': template = 'billard/index.html' + loc = None if request.is_ajax(): template = 'billard/index_ajax.html' + loc = request.session.get('loc') min_loc = Location.objects.filter(users__id=request.user.id).aggregate(Min('id'))['id__min'] - loc = None if 'loc' in request.GET: loc = request.GET['loc'] if not Location.objects.filter(users__id=request.user.id).filter(id=loc).exists(): resp = redirect('carom_index') if min_loc is not None: resp['Location'] += '?loc={}'.format(str(min_loc)) + request.session['loc'] = str(min_loc) return resp else: return render(request, template) @@ -61,6 +63,7 @@ def index(request): return render(request, template, context=context) if request.method == 'POST': loc = request.POST['location-selector'] + request.session['loc'] = str(loc) resp = redirect('carom_index') resp['Location'] += '?loc={}'.format(str(loc)) return resp