chartManD commited on
Commit
18e250b
·
1 Parent(s): 75904b0

Se plasma la informacion recabada en detalles para sesiones con Sort

Browse files
tecnicas/controllers/views_controller/session_management/details/details_sort_controller.py CHANGED
@@ -1,5 +1,5 @@
1
  from .details_controller import DetallesController
2
- from tecnicas.models import SesionSensorial
3
 
4
 
5
  class DetallesSortController(DetallesController):
@@ -29,4 +29,60 @@ class DetallesSortController(DetallesController):
29
  "finished": finished
30
  }
31
 
 
 
 
 
 
32
  return self.context
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  from .details_controller import DetallesController
2
+ from tecnicas.models import SesionSensorial, GrupoProducto, Producto, Participacion
3
 
4
 
5
  class DetallesSortController(DetallesController):
 
29
  "finished": finished
30
  }
31
 
32
+ self.context["data_groups"] = {
33
+ "data": self.setDataSort(),
34
+ "testers": self.setHeaders()
35
+ }
36
+
37
  return self.context
38
+
39
+ def setDataSort(self):
40
+ data = []
41
+ technique = self.session.tecnica
42
+
43
+ products = Producto.objects.filter(id_tecnica=technique)
44
+
45
+ groups = list(GrupoProducto.objects.filter(
46
+ tecnica=technique
47
+ ))
48
+
49
+ if len(groups):
50
+ self.context["there_data"] = True
51
+ else:
52
+ self.context["there_data"] = False
53
+ return []
54
+
55
+ for product in products:
56
+ product_data = {
57
+ "codigo_producto": product.codigoProducto,
58
+ "palabras": dict(list())
59
+ }
60
+
61
+ data_words = dict(list())
62
+
63
+ for group in groups:
64
+ if product in group.productos.all():
65
+ catador_username = group.catador.user.username
66
+
67
+ words_group = set()
68
+ for word in group.palabras.all():
69
+ words_group.add(word.nombre_palabra)
70
+
71
+ data_words[catador_username] = list(
72
+ set(data_words.get(catador_username, list())) | words_group)
73
+
74
+ product_data["palabras"] = data_words
75
+
76
+ data.append(product_data)
77
+
78
+ return data
79
+
80
+ def setHeaders(self):
81
+ participacions = list(Participacion.objects.filter(
82
+ tecnica=self.session.tecnica
83
+ ).only("catador").select_related("catador__user"))
84
+
85
+ testers = [
86
+ participacion.catador.user.username for participacion in participacions]
87
+
88
+ return testers
tecnicas/templates/tecnicas/components/table-sort.html ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {% load custom_filters %}
2
+ <section>
3
+ <div class="overflow-x-auto rounded-lg border border-surface-general">
4
+ <table class="min-w-max w-full text-sm text-center border-collapse">
5
+ <thead class="bg-surface-sweet text-black font-semibold">
6
+ <tr>
7
+ <th class="py-2 px-3 border border-surface-general">Producto</th>
8
+ {% for tester in data_groups.testers %}
9
+ <th class="py-2 px-3 border border-surface-general">
10
+ Consumidor {{ forloop.counter }}: {{ tester }}
11
+ </th>
12
+ {% endfor %}
13
+ </tr>
14
+ </thead>
15
+ <tbody class="bg-surface-ligt divide-y divide-gray-200 text-black">
16
+ {% for data_words in data_groups.data %}
17
+ <tr>
18
+ <td class="py-2 px-3 border border-surface-general font-medium">{{ data_words.codigo_producto }}</td>
19
+ {% for tester in data_groups.testers %}
20
+ <td class="py-2 px-3 border border-surface-general font-medium">
21
+ {% for word in data_words.palabras|get_item:tester %}
22
+ {{word}}
23
+ {% if not forloop.last %}
24
+ ;
25
+ {% endif %}
26
+ {% endfor %}
27
+ </td>
28
+ {% endfor %}
29
+ </tr>
30
+ {% endfor %}
31
+ </tbody>
32
+ </table>
33
+ </div>
34
+ </section>
tecnicas/templates/tecnicas/manage_sesions/details-session-sort.html CHANGED
@@ -186,7 +186,11 @@
186
  Datos obtenidos
187
  </p>
188
 
189
- {% include "../components/error-message.html" with message='Sin datos por mostrar aún' %}
 
 
 
 
190
 
191
  <form action="" method="post" class="form-action-session hidden">
192
  <input type="hidden" name="action" class="action-option">
 
186
  Datos obtenidos
187
  </p>
188
 
189
+ {% if there_data %}
190
+ {% include "../components/table-sort.html" with data_groups=data_groups %}
191
+ {% else %}
192
+ {% include "../components/error-message.html" with message='Sin datos por mostrar aún' %}
193
+ {% endif %}
194
 
195
  <form action="" method="post" class="form-action-session hidden">
196
  <input type="hidden" name="action" class="action-option">