|
|
|
|
@ -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)) |
|
|
|
|
|
|
|
|
|
|