Norberto Montalvo García commited on
Commit
7f9ab19
·
unverified ·
2 Parent(s): 45882dadf77b9b

Merge pull request #20 from CascoArcilla/HU9

Browse files

Correcciones varios por implementar User con Catador

Files changed (26) hide show
  1. tecnicas/controllers/models_controller/calificacion_controller.py +1 -1
  2. tecnicas/controllers/models_controller/dato_controller.py +1 -1
  3. tecnicas/controllers/models_controller/particiapacion_controller.py +7 -5
  4. tecnicas/controllers/models_controller/sesion_controller.py +8 -4
  5. tecnicas/controllers/views_controller/detalles_sesion_controller.py +5 -1
  6. tecnicas/controllers/views_controller/list_sessions_tester_controller.py +1 -1
  7. tecnicas/controllers/views_controller/main_tester_form_controller.py +7 -8
  8. tecnicas/middlewares/presenter_middleware.py +2 -3
  9. tecnicas/middlewares/tester_middleware.py +1 -26
  10. tecnicas/static/js/create-session.js +2 -2
  11. tecnicas/static/js/details-session.js +9 -15
  12. tecnicas/static/js/showHiddenElement.js +9 -0
  13. tecnicas/templates/tecnicas/components/table-convencional.html +0 -1
  14. tecnicas/templates/tecnicas/forms_tester/convencional.html +1 -1
  15. tecnicas/templates/tecnicas/forms_tester/main_panel_tester.html +14 -2
  16. tecnicas/templates/tecnicas/forms_tester/sessions_list_tester.html +3 -6
  17. tecnicas/templates/tecnicas/manage_sesions/detalles-sesion.html +34 -5
  18. tecnicas/templates/tecnicas/manage_sesions/monitor-sesion.html +3 -3
  19. tecnicas/urls.py +1 -1
  20. tecnicas/views/apis/rating_word.py +2 -2
  21. tecnicas/views/sessions_management/session_details.py +2 -1
  22. tecnicas/views/sessions_management/sessions_panel.py +8 -13
  23. tecnicas/views/tester_forms/convencional_scales.py +15 -12
  24. tecnicas/views/tester_forms/init_tester_form.py +19 -7
  25. tecnicas/views/tester_forms/login_session.py +1 -9
  26. tecnicas/views/tester_forms/panel_main_tester.py +8 -1
tecnicas/controllers/models_controller/calificacion_controller.py CHANGED
@@ -84,7 +84,7 @@ class CalificacionController():
84
  elif id_tester is not None:
85
  filters["id_catador__id"] = id_tester
86
  elif user_tester is not None:
87
- filters["id_catador__usuarioCatador"] = user_tester
88
 
89
  ratings = list(Calificacion.objects.filter(**filters).select_related(
90
  "id_producto",
 
84
  elif id_tester is not None:
85
  filters["id_catador__id"] = id_tester
86
  elif user_tester is not None:
87
+ filters["id_catador__user__username"] = user_tester
88
 
89
  ratings = list(Calificacion.objects.filter(**filters).select_related(
90
  "id_producto",
tecnicas/controllers/models_controller/dato_controller.py CHANGED
@@ -89,7 +89,7 @@ class DatoController():
89
  producto_code=F(
90
  "id_dato__id_calificacion__id_producto__codigoProducto"),
91
  usuarioCatador=F(
92
- "id_dato__id_calificacion__id_catador__usuarioCatador"),
93
  dato_valor=F("valor")
94
  )
95
  )
 
89
  producto_code=F(
90
  "id_dato__id_calificacion__id_producto__codigoProducto"),
91
  usuarioCatador=F(
92
+ "id_dato__id_calificacion__id_catador__user__username"),
93
  dato_valor=F("valor")
94
  )
95
  )
tecnicas/controllers/models_controller/particiapacion_controller.py CHANGED
@@ -1,12 +1,13 @@
1
- from ...models import Participacion, Tecnica, SesionSensorial
2
  from ...utils import controller_error
3
 
4
 
5
  class ParticipacionController():
6
  @staticmethod
7
- def enterSession(id_participation: int):
8
  try:
9
- participation = Participacion.objects.get(id=id_participation)
 
10
  participation.finalizado = False
11
  participation.activo = True
12
  participation.save()
@@ -26,9 +27,10 @@ class ParticipacionController():
26
  return controller_error("No se ha encontrado la participación")
27
 
28
  @staticmethod
29
- def outSession(id_participation: int):
30
  try:
31
- participation = Participacion.objects.get(id=id_participation)
 
32
  participation.activo = False
33
  participation.save()
34
  return participation
 
1
+ from ...models import Participacion, Tecnica, SesionSensorial, Catador
2
  from ...utils import controller_error
3
 
4
 
5
  class ParticipacionController():
6
  @staticmethod
7
+ def enterSession(tester: Catador, session: SesionSensorial):
8
  try:
9
+ participation = Participacion.objects.get(
10
+ catador=tester, tecnica=session.tecnica)
11
  participation.finalizado = False
12
  participation.activo = True
13
  participation.save()
 
27
  return controller_error("No se ha encontrado la participación")
28
 
29
  @staticmethod
30
+ def outSession(tester: Catador, session: SesionSensorial):
31
  try:
32
+ participation = Participacion.objects.get(
33
+ catador=tester, tecnica=session.tecnica)
34
  participation.activo = False
35
  participation.save()
36
  return participation
tecnicas/controllers/models_controller/sesion_controller.py CHANGED
@@ -49,7 +49,7 @@ class SesionController():
49
  try:
50
  creator = Presentador.objects.get(user__username=user_name)
51
  except Presentador.DoesNotExist:
52
- return controller_error("presentador invalido")
53
 
54
  queryset = (
55
  SesionSensorial.objects
@@ -75,10 +75,14 @@ class SesionController():
75
  sessions_in_page = paginator.page(page)
76
  except PageNotAnInteger:
77
  return controller_error("índice inválido")
78
- except EmptyPage:
79
- return controller_error("sin registros de sesiones")
80
 
81
- return (sessions_in_page, not sessions_in_page.number < paginator.num_pages)
 
 
 
 
 
 
82
 
83
  @staticmethod
84
  def getSessionByCodePanelTester(code: str):
 
49
  try:
50
  creator = Presentador.objects.get(user__username=user_name)
51
  except Presentador.DoesNotExist:
52
+ return controller_error("Presentador invalido")
53
 
54
  queryset = (
55
  SesionSensorial.objects
 
75
  sessions_in_page = paginator.page(page)
76
  except PageNotAnInteger:
77
  return controller_error("índice inválido")
 
 
78
 
79
+ if not sessions_in_page.object_list:
80
+ return controller_error("Sin registros de sesiones")
81
+
82
+ current_page = sessions_in_page.number
83
+ is_last_page = not current_page < paginator.num_pages
84
+
85
+ return (sessions_in_page, is_last_page, current_page)
86
 
87
  @staticmethod
88
  def getSessionByCodePanelTester(code: str):
tecnicas/controllers/views_controller/detalles_sesion_controller.py CHANGED
@@ -12,7 +12,7 @@ Encabezados de como deben de aparecer los datos juntos
12
 
13
  '''
14
 
15
- from ...models import SesionSensorial, Presentador, Tecnica, Palabra
16
  from .. import CalificacionController, PalabrasController
17
  from ...utils import controller_error
18
  from collections import defaultdict
@@ -66,6 +66,10 @@ class DetallesSesionController():
66
 
67
  return self.context
68
 
 
 
 
 
69
  @staticmethod
70
  def startRepetition(session_code: str, username: str):
71
  try:
 
12
 
13
  '''
14
 
15
+ from ...models import SesionSensorial, Presentador, Tecnica
16
  from .. import CalificacionController, PalabrasController
17
  from ...utils import controller_error
18
  from collections import defaultdict
 
66
 
67
  return self.context
68
 
69
+ def deleteSesorialSession(self):
70
+ technique = Tecnica.objects.get(id=self.session.tecnica.id)
71
+ technique.delete()
72
+
73
  @staticmethod
74
  def startRepetition(session_code: str, username: str):
75
  try:
tecnicas/controllers/views_controller/list_sessions_tester_controller.py CHANGED
@@ -68,7 +68,7 @@ class ListSessionsTesterController():
68
  return controller_error("índice inválido")
69
 
70
  if not sessions_in_page.object_list:
71
- return controller_error("Sin registros de Catadores")
72
 
73
  current_page = sessions_in_page.number
74
  is_last_page = not current_page < paginator.num_pages
 
68
  return controller_error("índice inválido")
69
 
70
  if not sessions_in_page.object_list:
71
+ return controller_error("Sin registros de Participaciones")
72
 
73
  current_page = sessions_in_page.number
74
  is_last_page = not current_page < paginator.num_pages
tecnicas/controllers/views_controller/main_tester_form_controller.py CHANGED
@@ -20,6 +20,8 @@ class MainTesterFormController():
20
  with transaction.atomic():
21
  orders_without_tester = list(Orden.objects.select_for_update().filter(
22
  id_tecnica=self.session.tecnica, id_catador=None))
 
 
23
 
24
  if not orders_without_tester:
25
  return controller_error("Las ordenes se han acabado")
@@ -33,20 +35,17 @@ class MainTesterFormController():
33
  return self.order_to_assign
34
 
35
  def checkAssignOrder(self):
36
- if not self.tester or not self.session:
37
- return controller_error("Atributos no establecidos")
38
-
39
  try:
40
- res_order = Orden.objects.get(
41
  id_tecnica=self.session.tecnica, id_catador=self.tester)
42
- self.order = res_order
43
  return self.order
44
  except Orden.DoesNotExist:
45
  return controller_error("Catador sin orden")
46
 
47
- def isEndedSession(self, id_participation: int, repetition: int):
48
  try:
49
- participation = Participacion.objects.get(id=id_participation)
 
50
 
51
  # ////////////////////////////////////////////////////////////// #
52
  #
@@ -76,7 +75,7 @@ class MainTesterFormController():
76
 
77
  expected_ratings_repetition = num_products * num_words
78
 
79
- return num_ratings_now >= expected_ratings_repetition
80
  else:
81
  return participation.finalizado
82
  except Participacion.DoesNotExist:
 
20
  with transaction.atomic():
21
  orders_without_tester = list(Orden.objects.select_for_update().filter(
22
  id_tecnica=self.session.tecnica, id_catador=None))
23
+
24
+ print(orders_without_tester)
25
 
26
  if not orders_without_tester:
27
  return controller_error("Las ordenes se han acabado")
 
35
  return self.order_to_assign
36
 
37
  def checkAssignOrder(self):
 
 
 
38
  try:
39
+ self.order = Orden.objects.get(
40
  id_tecnica=self.session.tecnica, id_catador=self.tester)
 
41
  return self.order
42
  except Orden.DoesNotExist:
43
  return controller_error("Catador sin orden")
44
 
45
+ def isEndedSession(self, repetition: int):
46
  try:
47
+ participation = Participacion.objects.get(
48
+ catador=self.tester, tecnica=self.session.tecnica)
49
 
50
  # ////////////////////////////////////////////////////////////// #
51
  #
 
75
 
76
  expected_ratings_repetition = num_products * num_words
77
 
78
+ return num_ratings_now >= expected_ratings_repetition
79
  else:
80
  return participation.finalizado
81
  except Participacion.DoesNotExist:
tecnicas/middlewares/presenter_middleware.py CHANGED
@@ -1,18 +1,17 @@
1
- from django.core.exceptions import PermissionDenied
2
-
3
  class PresenterAccessMiddleware:
4
  def __init__(self, get_response):
5
  self.get_response = get_response
6
 
7
  def __call__(self, request):
8
  path = request.path_info
9
-
10
  if path.startswith('/cata/presenter/'):
11
  if not request.user.is_authenticated:
12
  from django.shortcuts import redirect
13
  return redirect("cata_system:autenticacion")
14
 
15
  if not hasattr(request.user, 'user_presentador'):
 
16
  return redirect("cata_system:autenticacion")
17
 
18
  return self.get_response(request)
 
 
 
1
  class PresenterAccessMiddleware:
2
  def __init__(self, get_response):
3
  self.get_response = get_response
4
 
5
  def __call__(self, request):
6
  path = request.path_info
7
+
8
  if path.startswith('/cata/presenter/'):
9
  if not request.user.is_authenticated:
10
  from django.shortcuts import redirect
11
  return redirect("cata_system:autenticacion")
12
 
13
  if not hasattr(request.user, 'user_presentador'):
14
+ from django.shortcuts import redirect
15
  return redirect("cata_system:autenticacion")
16
 
17
  return self.get_response(request)
tecnicas/middlewares/tester_middleware.py CHANGED
@@ -15,32 +15,7 @@ class TesterAccessMiddleware:
15
  return redirect("cata_system:catador_login")
16
 
17
  if not hasattr(request.user, 'user_catador'):
 
18
  return redirect("cata_system:catador_login")
19
 
20
  return self.get_response(request)
21
-
22
- # from django.http import HttpRequest
23
-
24
-
25
- # class LoginTesterMiddleware():
26
- # def __init__(self, get_response):
27
- # self.get_response = get_response
28
-
29
- # def __call__(self, req: HttpRequest):
30
- # base_url_protected = "/cata/testers/"
31
-
32
- # if req.path.startswith(base_url_protected):
33
- # if not "cata_username" in req.session:
34
- # id_participacion = req.COOKIES.get("id_participacion")
35
- # if id_participacion:
36
- # from tecnicas.controllers import ParticipacionController
37
- # ParticipacionController.outSession(id_participacion)
38
- # from django.shortcuts import redirect
39
- # from django.urls import reverse
40
- # response = redirect(reverse("cata_system:catador_login"))
41
- # response.delete_cookie("id_participacion")
42
- # return response
43
-
44
- # response = self.get_response(req)
45
-
46
- # return response
 
15
  return redirect("cata_system:catador_login")
16
 
17
  if not hasattr(request.user, 'user_catador'):
18
+ from django.shortcuts import redirect
19
  return redirect("cata_system:catador_login")
20
 
21
  return self.get_response(request)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tecnicas/static/js/create-session.js CHANGED
@@ -90,7 +90,7 @@ function renderElementsResponse({
90
  ];
91
 
92
  const aIndex = document.createElement("a");
93
- aIndex.href = "/cata";
94
  aIndex.textContent = "Volver al inicio";
95
 
96
  aIndex.classList.add(
@@ -99,7 +99,7 @@ function renderElementsResponse({
99
  );
100
 
101
  const aDetails = document.createElement("a");
102
- aDetails.href = `/cata/detalles-sesion/${sessionId}`;
103
  aDetails.textContent = "Ver detalles la sesion";
104
 
105
  aDetails.classList.add(
 
90
  ];
91
 
92
  const aIndex = document.createElement("a");
93
+ aIndex.href = "/cata/presenter/";
94
  aIndex.textContent = "Volver al inicio";
95
 
96
  aIndex.classList.add(
 
99
  );
100
 
101
  const aDetails = document.createElement("a");
102
+ aDetails.href = `/cata/presenter/detalles-sesion/${sessionId}`;
103
  aDetails.textContent = "Ver detalles la sesion";
104
 
105
  aDetails.classList.add(
tecnicas/static/js/details-session.js CHANGED
@@ -4,23 +4,17 @@ const notificationError = document.querySelector(".ct-notification-error");
4
  if (notificationError) {
5
  setTimeout(function () {
6
  notificationError.classList.add("hidden");
7
- }, 2000);
8
  }
9
 
10
  function startRepetition() {
11
- const inputAction = document.createElement("input");
12
- inputAction.type = "hidden";
13
- inputAction.name = "action";
14
- inputAction.value = "start_session";
15
-
16
- const inputUser = document.createElement("input");
17
- inputUser.type = "hidden";
18
- inputUser.name = "username";
19
- inputUser.value = "aguBido";
20
-
21
- actionForm.appendChild(inputAction);
22
- actionForm.appendChild(inputUser);
23
-
24
- actionForm.classList.remove("hidden");
25
  actionForm.submit();
26
  }
 
 
 
 
 
 
 
4
  if (notificationError) {
5
  setTimeout(function () {
6
  notificationError.classList.add("hidden");
7
+ }, 3000);
8
  }
9
 
10
  function startRepetition() {
11
+ const input = actionForm.querySelector(".action-option")
12
+ input.value = "start_session";
 
 
 
 
 
 
 
 
 
 
 
 
13
  actionForm.submit();
14
  }
15
+
16
+ function deleteSession() {
17
+ const input = actionForm.querySelector(".action-option")
18
+ input.value = "delete_session";
19
+ actionForm.submit();
20
+ }
tecnicas/static/js/showHiddenElement.js ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ function hiddenWarningDialog(styleClass) {
2
+ const element = document.querySelector(`.${styleClass}`)
3
+ element.classList.add("hidden")
4
+ }
5
+
6
+ function showWarningDialog(styleClass) {
7
+ const element = document.querySelector(`.${styleClass}`)
8
+ element.classList.remove("hidden")
9
+ }
tecnicas/templates/tecnicas/components/table-convencional.html CHANGED
@@ -23,7 +23,6 @@
23
  {% with match=None %}
24
  {% for valor in valores %}
25
  {% if valor.nombre_palabra == palabra %}
26
- {{ palabra }} <br>
27
  {{ valor.dato_valor }}
28
  {% with match=True %}{% endwith %}
29
  {% endif %}
 
23
  {% with match=None %}
24
  {% for valor in valores %}
25
  {% if valor.nombre_palabra == palabra %}
 
26
  {{ valor.dato_valor }}
27
  {% with match=True %}{% endwith %}
28
  {% endif %}
tecnicas/templates/tecnicas/forms_tester/convencional.html CHANGED
@@ -45,7 +45,7 @@
45
  </header>
46
 
47
  <article class="hidden">
48
- <form action="{% url 'cata_system:catador_main' %}" method="post" class="form-actions">
49
  {% csrf_token %}
50
  <input type="hidden" name="action" class="action-input">
51
  </form>
 
45
  </header>
46
 
47
  <article class="hidden">
48
+ <form action="{% url 'cata_system:catador_init_session' code_sesion=session.codigo_sesion %}" method="post" class="form-actions">
49
  {% csrf_token %}
50
  <input type="hidden" name="action" class="action-input">
51
  </form>
tecnicas/templates/tecnicas/forms_tester/main_panel_tester.html CHANGED
@@ -1,4 +1,5 @@
1
  {% extends 'tecnicas/layouts/base.html' %}
 
2
 
3
  {% block title %}Panel Principal Tester{% endblock %}
4
 
@@ -11,7 +12,8 @@
11
  <div class="flex flex-col md:flex-row md:items-center md:justify-between gap-3">
12
  <h2 class="card-title text-2xl font-semibold">Información del Usuario</h2>
13
 
14
- <button class="cts-btn-general-compress px-4 py-2 cts-btn-error btn-push">
 
15
  Salir del Sistema
16
  </button>
17
  </div>
@@ -55,7 +57,8 @@
55
  ➕ Nueva sesión
56
  </button>
57
  </a>
58
- <a href="{% url 'cata_system:catador_list_sessions' num_page=1 %}" class="w-fit max-sm:w-full grow">
 
59
  <button class="cts-btn-general-compress px-4 py-2 cts-btn-primary btn-push w-full">
60
  🔍 Ver sesiones
61
  </button>
@@ -63,6 +66,15 @@
63
  </article>
64
  </div>
65
  </div>
 
 
 
 
 
66
  </article>
67
  </article>
 
 
 
 
68
  {% endblock %}
 
1
  {% extends 'tecnicas/layouts/base.html' %}
2
+ {% load static %}
3
 
4
  {% block title %}Panel Principal Tester{% endblock %}
5
 
 
12
  <div class="flex flex-col md:flex-row md:items-center md:justify-between gap-3">
13
  <h2 class="card-title text-2xl font-semibold">Información del Usuario</h2>
14
 
15
+ <button class="cts-btn-general-compress px-4 py-2 cts-btn-error btn-push"
16
+ onclick="exit_sesion('cts-action-form')">
17
  Salir del Sistema
18
  </button>
19
  </div>
 
57
  ➕ Nueva sesión
58
  </button>
59
  </a>
60
+ <a href="{% url 'cata_system:catador_list_sessions' num_page=1 %}"
61
+ class="w-fit max-sm:w-full grow">
62
  <button class="cts-btn-general-compress px-4 py-2 cts-btn-primary btn-push w-full">
63
  🔍 Ver sesiones
64
  </button>
 
66
  </article>
67
  </div>
68
  </div>
69
+
70
+ <form action="" method="post" class="hidden cts-action-form">
71
+ <input type="hidden" name="action" class="action-input">
72
+ {% csrf_token %}
73
+ </form>
74
  </article>
75
  </article>
76
+ {% endblock %}
77
+
78
+ {% block extra_js %}
79
+ <script src="{% static 'js/actions-form.js' %}"></script>
80
  {% endblock %}
tecnicas/templates/tecnicas/forms_tester/sessions_list_tester.html CHANGED
@@ -23,11 +23,7 @@
23
 
24
  {% if error %}
25
  {% include "../components/error-message.html" with message=error %}
26
- {% endif %}
27
- {% if message %}
28
- {% include "../components/error-message.html" with message=message %}
29
- {% endif %}
30
-
31
  <div class="space-y-4">
32
  <h3 class="text-xl font-semibold">Sesiones en las que ha participado</h3>
33
  <div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4">
@@ -42,7 +38,7 @@
42
 
43
  <section class="flex justify-center items-center gap-2">
44
  <div class="join space-x-2">
45
- {% if page != 1 %}
46
  <a href="{% url 'cata_system:catador_list_sessions' num_page=page|add:-1 %}" class="w-fit">
47
  <button class="join-item btn bg-btn-secondary py-1 text-2xl">
48
  ⏮️
@@ -59,6 +55,7 @@
59
  {% endif %}
60
  </div>
61
  </section>
 
62
  </div>
63
  </article>
64
  </article>
 
23
 
24
  {% if error %}
25
  {% include "../components/error-message.html" with message=error %}
26
+ {% else %}
 
 
 
 
27
  <div class="space-y-4">
28
  <h3 class="text-xl font-semibold">Sesiones en las que ha participado</h3>
29
  <div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4">
 
38
 
39
  <section class="flex justify-center items-center gap-2">
40
  <div class="join space-x-2">
41
+ {% if page > 1 %}
42
  <a href="{% url 'cata_system:catador_list_sessions' num_page=page|add:-1 %}" class="w-fit">
43
  <button class="join-item btn bg-btn-secondary py-1 text-2xl">
44
  ⏮️
 
55
  {% endif %}
56
  </div>
57
  </section>
58
+ {% endif %}
59
  </div>
60
  </article>
61
  </article>
tecnicas/templates/tecnicas/manage_sesions/detalles-sesion.html CHANGED
@@ -5,7 +5,7 @@
5
 
6
  {% block content %}
7
  <article class="cts-container-main">
8
- <article class="cts-wrap-content">
9
  <header class="text-center flex-row max-sm:flex-col w-full flex justify-around items-center flex-wrap gap-10">
10
  <h1 class="text-black rounded-xl font-bold text-2xl bg-surface-card shadow-lg p-4 flex-1">
11
  Detalles de la sesión
@@ -167,9 +167,9 @@
167
  </button>
168
  </a>
169
  {% endif %}
170
-
171
  <button
172
- class="flex-1 uppercase text-lg cts-btn-general cts-btn-error btn-push flex flex-col justify-center items-center gap-2">
 
173
  borrar
174
  <figure class="w-10">
175
  <img src="{% static 'img/basura.svg' %}" alt="bote de basura" class="invert">
@@ -177,6 +177,34 @@
177
  </button>
178
  </article>
179
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
180
  <p class="text-black font-bold text-2xl border-b-2">
181
  Datos obtenidos
182
  </p>
@@ -184,8 +212,7 @@
184
  {% if existen_calificaciones %}
185
  <article class="bg-surface-card p-4 max-sm:px-2 text-black rounded">
186
  {% for repeticion, catadores in calificaciones.items %}
187
- {% include "../components/table-convencional.html" with repeticion=repeticion catadores=catadores
188
- palabras=palabras %}
189
  {% endfor %}
190
  </article>
191
  {% else %}
@@ -193,6 +220,7 @@
193
  {% endif %}
194
 
195
  <form action="" method="post" class="form-action-session hidden">
 
196
  {% csrf_token %}
197
  </form>
198
  </article>
@@ -201,4 +229,5 @@
201
 
202
  {% block extra_js %}
203
  <script src="{% static 'js/details-session.js' %}"></script>
 
204
  {% endblock %}
 
5
 
6
  {% block content %}
7
  <article class="cts-container-main">
8
+ <article class="cts-wrap-content relative">
9
  <header class="text-center flex-row max-sm:flex-col w-full flex justify-around items-center flex-wrap gap-10">
10
  <h1 class="text-black rounded-xl font-bold text-2xl bg-surface-card shadow-lg p-4 flex-1">
11
  Detalles de la sesión
 
167
  </button>
168
  </a>
169
  {% endif %}
 
170
  <button
171
+ class="flex-1 uppercase text-lg cts-btn-general cts-btn-error btn-push flex flex-col justify-center items-center gap-2"
172
+ onclick="showWarningDialog('cts-warnig-dialog')">
173
  borrar
174
  <figure class="w-10">
175
  <img src="{% static 'img/basura.svg' %}" alt="bote de basura" class="invert">
 
177
  </button>
178
  </article>
179
 
180
+ <section
181
+ class="absolute w-full h-full flex justify-center items-center bg-surface-alter-card/70 top-0 left-0 p-6 rounded-xl cts-warnig-dialog hidden">
182
+ <article class="bg-surface-card p-4 space-y-6 rounded-xl">
183
+ <h2 class="text-4xl text-black text-center">
184
+ ¡¡¡Cuidado!!!
185
+ </h2>
186
+ <p class="text-2xl text-black text-center">
187
+ Esta acción no es reversible, si la continua también borrara todos los datos recopilados
188
+ relacionados a esta sesión y no podrá volver a recuperarlos
189
+ </p>
190
+ <section class="text-black font-bold text-xl space-y-4">
191
+ <p class="text-center">
192
+ ¿Estás seguro de continuar?
193
+ </p>
194
+ <div class="flex max-sm:flex-col gap-4 justify-center">
195
+ <button class="cts-btn-general cts-btn-error btn-push"
196
+ onclick="deleteSession()">
197
+ Estoy seguro
198
+ </button>
199
+ <button class="cts-btn-general cts-btn-primary btn-push"
200
+ onclick="hiddenWarningDialog('cts-warnig-dialog')">
201
+ No, cancelar
202
+ </button>
203
+ </div>
204
+ </section>
205
+ </article>
206
+ </section>
207
+
208
  <p class="text-black font-bold text-2xl border-b-2">
209
  Datos obtenidos
210
  </p>
 
212
  {% if existen_calificaciones %}
213
  <article class="bg-surface-card p-4 max-sm:px-2 text-black rounded">
214
  {% for repeticion, catadores in calificaciones.items %}
215
+ {% include "../components/table-convencional.html" with repeticion=repeticion catadores=catadores palabras=palabras %}
 
216
  {% endfor %}
217
  </article>
218
  {% else %}
 
220
  {% endif %}
221
 
222
  <form action="" method="post" class="form-action-session hidden">
223
+ <input type="hidden" name="action" class="action-option">
224
  {% csrf_token %}
225
  </form>
226
  </article>
 
229
 
230
  {% block extra_js %}
231
  <script src="{% static 'js/details-session.js' %}"></script>
232
+ <script src="{% static 'js/showHiddenElement.js' %}"></script>
233
  {% endblock %}
tecnicas/templates/tecnicas/manage_sesions/monitor-sesion.html CHANGED
@@ -91,10 +91,10 @@
91
  <ul class="divide-y divide-gray-400 max-sm:w-full text-black">
92
  {% for parti in participations %}
93
  <li class="grid grid-cols-4 text-center bg-surface-card py-2 [&_>*]:px-2">
94
- <p class="border-r border-gray-400">{{ parti.catador.usuarioCatador }}</p>
95
  <p class="border-r border-gray-400">
96
- {{ parti.catador.nombre }}
97
- {{ parti.catador.apellido}}
98
  </p>
99
 
100
  {% if parti.activo %}
 
91
  <ul class="divide-y divide-gray-400 max-sm:w-full text-black">
92
  {% for parti in participations %}
93
  <li class="grid grid-cols-4 text-center bg-surface-card py-2 [&_>*]:px-2">
94
+ <p class="border-r border-gray-400">{{ parti.catador.user.username }}</p>
95
  <p class="border-r border-gray-400">
96
+ {{ parti.catador.user.first_name }}
97
+ {{ parti.catador.user.last_name}}
98
  </p>
99
 
100
  {% if parti.activo %}
tecnicas/urls.py CHANGED
@@ -94,7 +94,7 @@ urlpatterns = [
94
  views.initTesterForm,
95
  name="catador_init_session"),
96
 
97
- path("testers/en-session/convencional",
98
  views.convencionalScales,
99
  name="session_convencional"),
100
 
 
94
  views.initTesterForm,
95
  name="catador_init_session"),
96
 
97
+ path("testers/init-session/<str:code_sesion>/convencional",
98
  views.convencionalScales,
99
  name="session_convencional"),
100
 
tecnicas/views/apis/rating_word.py CHANGED
@@ -44,9 +44,9 @@ def reatingWord(req: HttpRequest):
44
 
45
  view_controller = ApiRatingController(
46
  rating_controller=CalificacionController(
47
- technique=req.session["id_techniqe"],
48
  product=received_id_product,
49
- tester=req.session["id_cata"]
50
  ),
51
  data_controller=DatoController(
52
  word=received_id_word,
 
44
 
45
  view_controller = ApiRatingController(
46
  rating_controller=CalificacionController(
47
+ technique=req.session["id_technique"],
48
  product=received_id_product,
49
+ tester=req.user.user_catador
50
  ),
51
  data_controller=DatoController(
52
  word=received_id_word,
tecnicas/views/sessions_management/session_details.py CHANGED
@@ -26,7 +26,8 @@ def sessionDetails(req: HttpRequest, session_code: str):
26
 
27
  return redirect(reverse("cata_system:monitor_sesion", kwargs=parameters))
28
  elif req.POST.get("action") == "delete_session":
29
- pass
 
30
  else:
31
  context["error"] = "no se reconoce la accion a realizar"
32
  return render(req, "tecnicas/manage_sesions/detalles-sesion.html", context)
 
26
 
27
  return redirect(reverse("cata_system:monitor_sesion", kwargs=parameters))
28
  elif req.POST.get("action") == "delete_session":
29
+ controller_view.deleteSesorialSession()
30
+ return redirect(reverse("cata_system:panel_sesiones", kwargs={"page": 1}))
31
  else:
32
  context["error"] = "no se reconoce la accion a realizar"
33
  return render(req, "tecnicas/manage_sesions/detalles-sesion.html", context)
tecnicas/views/sessions_management/sessions_panel.py CHANGED
@@ -3,25 +3,20 @@ from django.shortcuts import render
3
  from ...controllers import SesionController
4
 
5
 
6
- def sesionsPanel(req:HttpRequest, page: int):
7
  context = {"num_page": page}
8
 
9
- (sessions_in_page, last_page) = SesionController.getSessionsSavesByCretor(
10
  user_name=req.user.username, page=page)
11
 
12
- if isinstance(sessions_in_page, dict):
13
- context["error"] = sessions_in_page["error"]
14
  return render(req, "tecnicas/manage_sesions/sesiones-panel.html", context=context)
 
 
15
 
16
  context["sessions"] = sessions_in_page
17
- context["last_page"] = last_page
18
-
19
- number_pages = SesionController.getNumberSessionsByCreator(
20
- user_name=req.user.username)
21
- if isinstance(number_pages, dict):
22
- context["num_paginas"] = sessions_in_page["error"]
23
- return render(req, "tecnicas/manage_sesions/sesiones-panel.html", context=context)
24
-
25
- context["num_paginas"] = number_pages
26
 
27
  return render(req, "tecnicas/manage_sesions/sesiones-panel.html", context=context)
 
3
  from ...controllers import SesionController
4
 
5
 
6
+ def sesionsPanel(req: HttpRequest, page: int):
7
  context = {"num_page": page}
8
 
9
+ response = SesionController.getSessionsSavesByCretor(
10
  user_name=req.user.username, page=page)
11
 
12
+ if isinstance(response, dict):
13
+ context["error"] = response["error"]
14
  return render(req, "tecnicas/manage_sesions/sesiones-panel.html", context=context)
15
+
16
+ (sessions_in_page, is_last_page, current_page) = response
17
 
18
  context["sessions"] = sessions_in_page
19
+ context["last_page"] = is_last_page
20
+ context["num_paginas"] = current_page
 
 
 
 
 
 
 
21
 
22
  return render(req, "tecnicas/manage_sesions/sesiones-panel.html", context=context)
tecnicas/views/tester_forms/convencional_scales.py CHANGED
@@ -1,8 +1,3 @@
1
- from django.http import HttpRequest
2
- from django.shortcuts import redirect, render
3
- from django.urls import reverse
4
- from ...controllers import SesionController, PosicionController, CalificacionController, ParticipacionController, PalabrasController, EscalaController, DatoController
5
-
6
  '''
7
  **** Esta vista para sesion con tecnica convencional de escalas, al entrar debe:
8
  **** ****
@@ -59,19 +54,25 @@ from ...controllers import SesionController, PosicionController, CalificacionCon
59
  - Cata longitud debe poser una marca y solo estas seran las unicas posibles respuestas
60
  - Cata segmento en el que se divide debe tener la etiqueda correspondiente por debajo
61
  '''
 
 
 
 
62
 
63
 
64
- def convencionalScales(req: HttpRequest):
65
  if not "id_order" in req.session:
66
  return redirect(reverse("cata_system:catador_main"))
67
 
68
- session = SesionController.getSessionByCode(req.session["code_session"])
69
  technique = session.tecnica
70
 
71
  context = {
72
  "session": session
73
  }
74
 
 
 
75
  if req.method == "GET":
76
  positions = PosicionController.getPostionsInOrder(
77
  id_order=req.session["id_order"])
@@ -82,8 +83,8 @@ def convencionalScales(req: HttpRequest):
82
 
83
  next_position = CalificacionController.checkProducsWithoutRating(
84
  positions=sorted_positions,
85
- user_cata=req.session["cata_username"],
86
- id_technique=req.session["id_techniqe"],
87
  repetition=session.tecnica.repeticion,
88
  technique=technique,
89
  num_words=len(words)
@@ -103,7 +104,7 @@ def convencionalScales(req: HttpRequest):
103
  technique=technique,
104
  product=next_position.id_producto,
105
  repetition=technique.repeticion,
106
- user_tester=req.session["cata_username"]
107
  )
108
 
109
  if isinstance(ratings_product, dict):
@@ -112,11 +113,13 @@ def convencionalScales(req: HttpRequest):
112
  elif not ratings_product:
113
  context["words"] = words
114
  else:
115
- recoreded_data = DatoController.getRerecordedData(ratings=ratings_product)
 
116
  if not recoreded_data:
117
  context["words"] = words
118
  else:
119
- words_to_use = PalabrasController.getWordsWithoutData(recoreded_data=recoreded_data, words=words)
 
120
  context["words"] = words_to_use
121
 
122
  scale = EscalaController.getScaleByTechnique(technique=technique)
 
 
 
 
 
 
1
  '''
2
  **** Esta vista para sesion con tecnica convencional de escalas, al entrar debe:
3
  **** ****
 
54
  - Cata longitud debe poser una marca y solo estas seran las unicas posibles respuestas
55
  - Cata segmento en el que se divide debe tener la etiqueda correspondiente por debajo
56
  '''
57
+ from django.http import HttpRequest
58
+ from django.shortcuts import redirect, render
59
+ from django.urls import reverse
60
+ from ...controllers import SesionController, PosicionController, CalificacionController, ParticipacionController, PalabrasController, EscalaController, DatoController
61
 
62
 
63
+ def convencionalScales(req: HttpRequest, code_sesion: str):
64
  if not "id_order" in req.session:
65
  return redirect(reverse("cata_system:catador_main"))
66
 
67
+ session = SesionController.getSessionByCode(code_sesion)
68
  technique = session.tecnica
69
 
70
  context = {
71
  "session": session
72
  }
73
 
74
+ req.session["id_technique"] = session.tecnica.id
75
+
76
  if req.method == "GET":
77
  positions = PosicionController.getPostionsInOrder(
78
  id_order=req.session["id_order"])
 
83
 
84
  next_position = CalificacionController.checkProducsWithoutRating(
85
  positions=sorted_positions,
86
+ user_cata=req.user.username,
87
+ id_technique=session.tecnica.id,
88
  repetition=session.tecnica.repeticion,
89
  technique=technique,
90
  num_words=len(words)
 
104
  technique=technique,
105
  product=next_position.id_producto,
106
  repetition=technique.repeticion,
107
+ user_tester=req.user.username
108
  )
109
 
110
  if isinstance(ratings_product, dict):
 
113
  elif not ratings_product:
114
  context["words"] = words
115
  else:
116
+ recoreded_data = DatoController.getRerecordedData(
117
+ ratings=ratings_product)
118
  if not recoreded_data:
119
  context["words"] = words
120
  else:
121
+ words_to_use = PalabrasController.getWordsWithoutData(
122
+ recoreded_data=recoreded_data, words=words)
123
  context["words"] = words_to_use
124
 
125
  scale = EscalaController.getScaleByTechnique(technique=technique)
tecnicas/views/tester_forms/init_tester_form.py CHANGED
@@ -1,7 +1,7 @@
1
  from django.http import HttpRequest, JsonResponse
2
  from django.shortcuts import render, redirect
3
  from django.urls import reverse
4
- from ...controllers import SesionController, MainTesterFormController, ParticipacionController
5
 
6
 
7
  def initTesterForm(req: HttpRequest, code_sesion: str):
@@ -22,7 +22,7 @@ def initTesterForm(req: HttpRequest, code_sesion: str):
22
  if not isinstance(order, dict):
23
  req.session["id_order"] = order.id
24
  is_end = view_controller.isEndedSession(
25
- id_participation=req.session["id_participation"], repetition=session.tecnica.repeticion)
26
 
27
  if is_end:
28
  context["message"] = "El catador ha terminado de realizar su evaluación, espere instrucciones del presentador"
@@ -31,14 +31,18 @@ def initTesterForm(req: HttpRequest, code_sesion: str):
31
  return render(req, template_url, context)
32
  elif req.method == "POST":
33
  if req.POST["action"] == "start_posting":
 
 
 
 
34
  if "id_order" in req.session:
35
  update_participation = ParticipacionController.enterSession(
36
- id_participation=req.session["id_participation"])
37
  if isinstance(update_participation, dict):
38
  context["error"] = update_participation["error"]
39
  return render(req, template_url, context)
40
 
41
- return redirect(reverse("cata_system:session_convencional"))
42
 
43
  order = view_controller.assignOrder()
44
  if isinstance(order, dict):
@@ -46,15 +50,15 @@ def initTesterForm(req: HttpRequest, code_sesion: str):
46
  return render(req, template_url, context)
47
 
48
  update_participation = ParticipacionController.enterSession(
49
- id_participation=req.session["id_participation"])
50
  if isinstance(update_participation, dict):
51
  context["error"] = update_participation["error"]
52
  return render(req, template_url, context)
53
 
54
- return redirect(reverse("cata_system:session_convencional"))
55
  elif req.POST["action"] == "exit_session":
56
  response = ParticipacionController.outSession(
57
- req.session["id_participation"])
58
  if isinstance(response, dict):
59
  context["error"] = response["error"]
60
  return render(req, template_url, context)
@@ -63,3 +67,11 @@ def initTesterForm(req: HttpRequest, code_sesion: str):
63
  return render(req, template_url, context)
64
  else:
65
  return JsonResponse({"error": "metodo no permitido"})
 
 
 
 
 
 
 
 
 
1
  from django.http import HttpRequest, JsonResponse
2
  from django.shortcuts import render, redirect
3
  from django.urls import reverse
4
+ from tecnicas.controllers import SesionController, MainTesterFormController, ParticipacionController
5
 
6
 
7
  def initTesterForm(req: HttpRequest, code_sesion: str):
 
22
  if not isinstance(order, dict):
23
  req.session["id_order"] = order.id
24
  is_end = view_controller.isEndedSession(
25
+ repetition=session.tecnica.repeticion)
26
 
27
  if is_end:
28
  context["message"] = "El catador ha terminado de realizar su evaluación, espere instrucciones del presentador"
 
31
  return render(req, template_url, context)
32
  elif req.method == "POST":
33
  if req.POST["action"] == "start_posting":
34
+ parameters = {
35
+ "code_sesion": code_sesion
36
+ }
37
+
38
  if "id_order" in req.session:
39
  update_participation = ParticipacionController.enterSession(
40
+ tester=req.user.user_catador, session=session)
41
  if isinstance(update_participation, dict):
42
  context["error"] = update_participation["error"]
43
  return render(req, template_url, context)
44
 
45
+ return redirect(reverse("cata_system:session_convencional", kwargs=parameters))
46
 
47
  order = view_controller.assignOrder()
48
  if isinstance(order, dict):
 
50
  return render(req, template_url, context)
51
 
52
  update_participation = ParticipacionController.enterSession(
53
+ tester=req.user.user_catador, session=session)
54
  if isinstance(update_participation, dict):
55
  context["error"] = update_participation["error"]
56
  return render(req, template_url, context)
57
 
58
+ return redirect(reverse("cata_system:session_convencional", kwargs=parameters))
59
  elif req.POST["action"] == "exit_session":
60
  response = ParticipacionController.outSession(
61
+ tester=req.user.user_catador, session=session)
62
  if isinstance(response, dict):
63
  context["error"] = response["error"]
64
  return render(req, template_url, context)
 
67
  return render(req, template_url, context)
68
  else:
69
  return JsonResponse({"error": "metodo no permitido"})
70
+
71
+ # req.session["cata_username"] = tester_user
72
+ # req.session["id_cata"] = tester.id
73
+ # req.session["code_session"] = session_code
74
+ # req.session["id_techniqe"] = session.tecnica.id
75
+ # req.session["id_participation"] = taster_participation.id
76
+
77
+ # response.set_cookie('id_participacion', taster_participation.id, max_age=60*60*24)
tecnicas/views/tester_forms/login_session.py CHANGED
@@ -33,15 +33,7 @@ def loginSessionTester(req: HttpRequest):
33
  params = {
34
  "code_sesion": session_code
35
  }
36
-
37
  return redirect(reverse("cata_system:catador_init_session", kwargs=params))
38
  else:
39
  return JsonResponse({"message": "Método no valido"})
40
-
41
- # req.session["cata_username"] = tester_user
42
- # req.session["id_cata"] = tester.id
43
- # req.session["code_session"] = session_code
44
- # req.session["id_techniqe"] = session.tecnica.id
45
- # req.session["id_participation"] = taster_participation.id
46
-
47
- # response.set_cookie('id_participacion', taster_participation.id, max_age=60*60*24)
 
33
  params = {
34
  "code_sesion": session_code
35
  }
36
+
37
  return redirect(reverse("cata_system:catador_init_session", kwargs=params))
38
  else:
39
  return JsonResponse({"message": "Método no valido"})
 
 
 
 
 
 
 
 
tecnicas/views/tester_forms/panel_main_tester.py CHANGED
@@ -1,5 +1,6 @@
 
1
  from django.http import HttpRequest, JsonResponse
2
- from django.shortcuts import render
3
 
4
 
5
  def mainPanelTester(req: HttpRequest):
@@ -13,5 +14,11 @@ def mainPanelTester(req: HttpRequest):
13
  "birthday": req.user.user_catador.nacimiento
14
  }
15
  return render(req, "tecnicas/forms_tester/main_panel_tester.html", view_context)
 
 
 
 
 
 
16
  else:
17
  return JsonResponse({"message": "Método no permitido"})
 
1
+ from django.contrib.auth import logout
2
  from django.http import HttpRequest, JsonResponse
3
+ from django.shortcuts import render, redirect
4
 
5
 
6
  def mainPanelTester(req: HttpRequest):
 
14
  "birthday": req.user.user_catador.nacimiento
15
  }
16
  return render(req, "tecnicas/forms_tester/main_panel_tester.html", view_context)
17
+ elif req.method == "POST":
18
+ if req.POST["action"] == "exit_session":
19
+ logout(req)
20
+ return redirect("cata_system:catador_login")
21
+ else:
22
+ return JsonResponse({"message": "Acción no definida"})
23
  else:
24
  return JsonResponse({"message": "Método no permitido"})