From cba88b9cfc2d1ed7f6ebb2af37b204fb9e96f113 Mon Sep 17 00:00:00 2001 From: Gustavo Date: Mon, 31 Jul 2017 22:52:25 -0300 Subject: [PATCH] Started code to display user performance in the bulletin template --- bulletin/views.py | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/bulletin/views.py b/bulletin/views.py index 26c1481..613784c 100644 --- a/bulletin/views.py +++ b/bulletin/views.py @@ -8,7 +8,7 @@ from django.http import JsonResponse from amadeus.permissions import has_subject_permissions, has_resource_permissions from .utils import brodcast_dificulties -from goals.models import Goals,GoalItem +from goals.models import Goals,GoalItem,MyGoals import xlwt import time @@ -153,6 +153,29 @@ class InsideView(LoginRequiredMixin, LogMixin, generic.DetailView): self.request.session['log_id'] = Log.objects.latest('id').id + + topic = self.object.topic + + meta_geral = Goals.objects.get(topic=topic) + metas = GoalItem.objects.filter(goal = meta_geral) + metas_pessoais = [] + ''' + for m in metas: + if MyGoals.objects.filter(item = m).exists(): + metas_pessoais.append(MyGoals.objects.get(item = m)) + ''' + + itens_da_meta = sorted(list(metas), key = lambda met: met.id) + metas_pessoais = sorted(list(metas_pessoais), key = lambda me: me.id) + lista_metas = [{'description':geral.description, 'desejada':geral.ref_value} for geral in itens_da_meta ] + ''' + for x in range(0,len(metas_pessoais)): + lista_metas[x]['estabelecida'] = metas_pessoais[x].value + print(metas_pessoais) + print(lista_metas) + ''' + context['metas'] = lista_metas + return context class CreateView(LoginRequiredMixin, LogMixin, generic.edit.CreateView): -- libgit2 0.21.2