diff --git a/choose/templates/vote.html b/choose/templates/vote.html
index 24702c1..e11f92f 100644
--- a/choose/templates/vote.html
+++ b/choose/templates/vote.html
@@ -7,7 +7,7 @@
{% if not voted %}
-
+
{% endif %}
diff --git a/choose/views.py b/choose/views.py
index 66dc93c..8983eca 100644
--- a/choose/views.py
+++ b/choose/views.py
@@ -40,7 +40,7 @@ def list_of_teas():
tt.preferred.pic.href)
dic[tt.category.name][tt.name]['ms'] = [tt.preferred.m * x for x in range(0, 11)]
- return {'categories': dic}
+ return dic
def list_of_choices(request):
@@ -48,7 +48,7 @@ def list_of_choices(request):
voted = False
my_choice = Choice.objects.filter(users__in=[request.user]).first()
if my_choice is not None:
- voted =True
+ voted = True
json.loads(my_choice.choice)
arr.append({'voted': [user.username for user in my_choice.votes.all()],
'chosed': [user.username for user in my_choice.users.all()],
@@ -69,9 +69,17 @@ def list_of_choices(request):
return {'choices': arr, 'voted': voted}
+def get_my_choice(request):
+ my_choice = Choice.objects.filter(users__in=[request.user]).first()
+ if my_choice is None:
+ return {}
+ else:
+ return {tea_id: str(mass) for tea_id, mass in json.loads(my_choice.choice).items()}
+
+
@login_requiered
def choose(request):
- context = list_of_teas()
+ context = {'categories': list_of_teas(), 'teas': get_my_choice(request)}
template = loader.get_template('choose.html')
return HttpResponse(template.render(context, request))