Commit cba88b9cfc2d1ed7f6ebb2af37b204fb9e96f113

Authored by Gustavo
1 parent 4738fbd2

Started code to display user performance in the bulletin template

Showing 1 changed file with 24 additions and 1 deletions   Show diff stats
bulletin/views.py
@@ -8,7 +8,7 @@ from django.http import JsonResponse @@ -8,7 +8,7 @@ from django.http import JsonResponse
8 8
9 from amadeus.permissions import has_subject_permissions, has_resource_permissions 9 from amadeus.permissions import has_subject_permissions, has_resource_permissions
10 from .utils import brodcast_dificulties 10 from .utils import brodcast_dificulties
11 -from goals.models import Goals,GoalItem 11 +from goals.models import Goals,GoalItem,MyGoals
12 12
13 import xlwt 13 import xlwt
14 import time 14 import time
@@ -153,6 +153,29 @@ class InsideView(LoginRequiredMixin, LogMixin, generic.DetailView): @@ -153,6 +153,29 @@ class InsideView(LoginRequiredMixin, LogMixin, generic.DetailView):
153 153
154 self.request.session['log_id'] = Log.objects.latest('id').id 154 self.request.session['log_id'] = Log.objects.latest('id').id
155 155
  156 +
  157 + topic = self.object.topic
  158 +
  159 + meta_geral = Goals.objects.get(topic=topic)
  160 + metas = GoalItem.objects.filter(goal = meta_geral)
  161 + metas_pessoais = []
  162 + '''
  163 + for m in metas:
  164 + if MyGoals.objects.filter(item = m).exists():
  165 + metas_pessoais.append(MyGoals.objects.get(item = m))
  166 + '''
  167 +
  168 + itens_da_meta = sorted(list(metas), key = lambda met: met.id)
  169 + metas_pessoais = sorted(list(metas_pessoais), key = lambda me: me.id)
  170 + lista_metas = [{'description':geral.description, 'desejada':geral.ref_value} for geral in itens_da_meta ]
  171 + '''
  172 + for x in range(0,len(metas_pessoais)):
  173 + lista_metas[x]['estabelecida'] = metas_pessoais[x].value
  174 + print(metas_pessoais)
  175 + print(lista_metas)
  176 + '''
  177 + context['metas'] = lista_metas
  178 +
156 return context 179 return context
157 180
158 class CreateView(LoginRequiredMixin, LogMixin, generic.edit.CreateView): 181 class CreateView(LoginRequiredMixin, LogMixin, generic.edit.CreateView):