chartManD commited on
Commit
79a50aa
·
1 Parent(s): 02eff64

Se establece el switch para sesion con tecnica RATA, inicio de sesion

Browse files
tecnicas/controllers/__init__.py CHANGED
@@ -12,11 +12,9 @@ from .models_controller.posicion_controller import PosicionController
12
  from .models_controller.particiapacion_controller import ParticipacionController
13
  from .models_controller.dato_controller import DatoController
14
 
15
- from .views_controller.detalles_sesion_controller import DetallesSesionController
16
  from .views_controller.login_tester_controller import LoginTesterController
17
  from .views_controller.main_tester_form_controller import MainTesterFormController
18
  from .views_controller.api_rating_controller import ApiRatingController
19
- from .views_controller.monitor_sesion_controller import MonitorSesionController
20
  from .views_controller.tester_list_controller import TesterListController
21
  from .views_controller.list_sessions_tester_controller import ListSessionsTesterController
22
 
@@ -25,3 +23,9 @@ from .views_controller.create_session.panel_tags_controller import PanelTagsCont
25
  from .views_controller.create_session.panel_codes_controller import PanelCodesController
26
  from .views_controller.create_session.panel_words_controller import PanelWordsController
27
  from .views_controller.create_session.panel_create_controller import PanelCreateController
 
 
 
 
 
 
 
12
  from .models_controller.particiapacion_controller import ParticipacionController
13
  from .models_controller.dato_controller import DatoController
14
 
 
15
  from .views_controller.login_tester_controller import LoginTesterController
16
  from .views_controller.main_tester_form_controller import MainTesterFormController
17
  from .views_controller.api_rating_controller import ApiRatingController
 
18
  from .views_controller.tester_list_controller import TesterListController
19
  from .views_controller.list_sessions_tester_controller import ListSessionsTesterController
20
 
 
23
  from .views_controller.create_session.panel_codes_controller import PanelCodesController
24
  from .views_controller.create_session.panel_words_controller import PanelWordsController
25
  from .views_controller.create_session.panel_create_controller import PanelCreateController
26
+
27
+ from .views_controller.session_management.details_controller import DetallesController
28
+ from .views_controller.session_management.details_escala_controller import DetallesEscalasController
29
+ from .views_controller.session_management.details_rata_controller import DetallesRATAController
30
+ from .views_controller.session_management.monitor_controller import MonitorController
31
+ from .views_controller.session_management.monitor_escalas_controller import MonitorEscalasController
tecnicas/controllers/models_controller/calificacion_controller.py CHANGED
@@ -1,8 +1,7 @@
1
  from django.core.exceptions import ValidationError
2
- from django.db import DatabaseError
3
  from collections import defaultdict
4
- from ...models import Calificacion, Tecnica, Posicion, Producto, Catador
5
- from ...utils import controller_error, getId
6
 
7
 
8
  class CalificacionController():
@@ -46,7 +45,7 @@ class CalificacionController():
46
  repetition = technique.repeticion
47
 
48
  if not repetition:
49
- return {"error": "sin datos calficados aun"}
50
 
51
  ratings = list(Calificacion.objects.filter(id_tecnica=technique))
52
 
 
1
  from django.core.exceptions import ValidationError
 
2
  from collections import defaultdict
3
+ from tecnicas.models import Calificacion, Tecnica, Posicion, Producto, Catador
4
+ from tecnicas.utils import controller_error, getId
5
 
6
 
7
  class CalificacionController():
 
45
  repetition = technique.repeticion
46
 
47
  if not repetition:
48
+ return controller_error("Sin datos calificados aún")
49
 
50
  ratings = list(Calificacion.objects.filter(id_tecnica=technique))
51
 
tecnicas/controllers/views_controller/main_tester_form_controller.py CHANGED
@@ -20,7 +20,7 @@ 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
  print(orders_without_tester)
25
 
26
  if not orders_without_tester:
@@ -34,13 +34,15 @@ class MainTesterFormController():
34
 
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:
 
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:
 
34
 
35
  return self.order_to_assign
36
 
37
+ def checkAndAssignOrder(self):
38
  try:
39
+ self.order_to_assign = Orden.objects.get(
40
  id_tecnica=self.session.tecnica, id_catador=self.tester)
 
41
  except Orden.DoesNotExist:
42
+ create = self.assignOrder()
43
+ if isinstance(create, dict):
44
+ return create
45
+ return self.order_to_assign
46
 
47
  def isEndedSession(self, repetition: int):
48
  try:
tecnicas/controllers/views_controller/session_management/details_controller.py ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from tecnicas.models import SesionSensorial, Presentador, Tecnica
2
+ from tecnicas.utils import controller_error
3
+
4
+
5
+ class DetallesController():
6
+ url_template = "tecnicas/manage_sesions/detalles-sesion.html"
7
+
8
+ def __init__(self, session: SesionSensorial):
9
+ self.session = session
10
+
11
+ def deleteSesorialSession(self):
12
+ technique = Tecnica.objects.get(id=self.session.tecnica.id)
13
+ technique.delete()
tecnicas/controllers/views_controller/{detalles_sesion_controller.py → session_management/details_escala_controller.py} RENAMED
@@ -11,29 +11,42 @@ Encabezados de como deben de aparecer los datos juntos
11
  | Repeticion | Codigo Producto | Catador | P1 | P2 | P3 | Pn |
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
19
- from tecnicas.controllers import DatoController
20
- from tecnicas.utils import defaultdict_to_dict
21
 
22
 
23
- class DetallesSesionController():
24
- def __init__(self, session_code: str):
25
- self.session = SesionSensorial.objects.get(codigo_sesion=session_code)
26
 
27
- def getContextForView(self):
28
- self.context = {}
29
 
30
- self.context["sesion"] = self.session
 
 
 
 
 
 
 
 
 
31
 
 
 
 
 
 
32
  self.words = PalabrasController.getWordsInTechnique(
33
  self.session.tecnica)
34
  self.context["palabras"] = [word.nombre_palabra for word in self.words]
35
 
36
- def getContextWithData(self):
37
  ratings_for_repetition = []
38
 
39
  ratings = CalificacionController.getRatingsByTechnique(
@@ -66,34 +79,25 @@ class DetallesSesionController():
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:
76
- creator = Presentador.objects.get(user__username=username)
77
- session = SesionSensorial.objects.get(codigo_sesion=session_code)
78
- technique = Tecnica.objects.get(id=session.tecnica.id)
79
- except Presentador.DoesNotExist:
80
- return controller_error("no existe presentador")
81
- except SesionSensorial.DoesNotExist:
82
- return controller_error("no existe sesión sensorial")
83
- except Tecnica.DoesNotExist:
84
- return controller_error("Ha ocurrido un error al recuperar la técnica")
85
-
86
- if creator.user.username != session.creadoPor.user.username:
87
- return controller_error("solo el presentador que crea la sesión puede iniciar la repetición")
88
- elif session.activo:
89
- return controller_error("la sesión ya está activada")
90
  elif technique.repeticion == technique.repeticiones_max:
91
- return controller_error("se ha alcanzado el número de repeticiones máxima")
92
 
93
- session.activo = True
94
  technique.repeticion = technique.repeticion + 1
95
 
96
  technique.save()
97
- session.save()
98
 
99
- return session
 
 
 
 
 
11
  | Repeticion | Codigo Producto | Catador | P1 | P2 | P3 | Pn |
12
 
13
  '''
14
+ from django.http import HttpRequest
15
+ from django.shortcuts import render, redirect
16
+ from django.urls import reverse
17
+ from tecnicas.models import SesionSensorial, Presentador, Tecnica
18
+ from tecnicas.controllers import DatoController, CalificacionController, PalabrasController
19
+ from .details_controller import DetallesController
20
+ from tecnicas.utils import defaultdict_to_dict, controller_error
21
  from collections import defaultdict
 
 
22
 
23
 
24
+ class DetallesEscalasController(DetallesController):
25
+ url_template = "tecnicas/manage_sesions/detalles-sesion.html"
 
26
 
27
+ def __init__(self, session: SesionSensorial):
28
+ super().__init__(session)
29
 
30
+ def getResponse(self, request: HttpRequest, error: str = "", message: str = ""):
31
+ context = self.getContext()
32
+
33
+ if error != "" or error:
34
+ context["error"] = error
35
+ if message != "" or message:
36
+ context["message"] = message
37
+
38
+ return render(
39
+ request, self.url_template, context)
40
 
41
+ def getContext(self):
42
+ self.context = {
43
+ "use_technique": self.session.tecnica.tipo_tecnica.nombre_tecnica
44
+ }
45
+ self.context["sesion"] = self.session
46
  self.words = PalabrasController.getWordsInTechnique(
47
  self.session.tecnica)
48
  self.context["palabras"] = [word.nombre_palabra for word in self.words]
49
 
 
50
  ratings_for_repetition = []
51
 
52
  ratings = CalificacionController.getRatingsByTechnique(
 
79
 
80
  return self.context
81
 
82
+ def startRepetition(self, presenter: Presentador):
83
+ creator = presenter
84
+ technique = self.session.tecnica
85
+
86
+ if creator.user.username != self.session.creadoPor.user.username:
87
+ return self.getResponse(error="Solo el presentador que crea la sesión puede iniciar la repetición")
88
+ elif self.session.activo:
89
+ return self.getResponse(error="La sesión ya está activada")
 
 
 
 
 
 
 
 
 
 
 
 
 
90
  elif technique.repeticion == technique.repeticiones_max:
91
+ return self.getResponse(error="Se ha alcanzado el número de repeticiones máxima")
92
 
93
+ self.session.activo = True
94
  technique.repeticion = technique.repeticion + 1
95
 
96
  technique.save()
97
+ self.session.save()
98
 
99
+ parameters = {
100
+ "session_code": self.session.codigo_sesion
101
+ }
102
+ return redirect(
103
+ reverse("cata_system:monitor_sesion", kwargs=parameters))
tecnicas/controllers/views_controller/session_management/details_rata_controller.py ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from django.http import HttpRequest
2
+ from django.shortcuts import render, redirect
3
+ from tecnicas.models import SesionSensorial
4
+ from tecnicas.controllers import PalabrasController, DatoController, CalificacionController
5
+ from tecnicas.utils import defaultdict_to_dict
6
+ from .details_controller import DetallesController
7
+ from collections import defaultdict
8
+
9
+
10
+ class DetallesRATAController(DetallesController):
11
+ def __init__(self, session: SesionSensorial):
12
+ super().__init__(session)
13
+
14
+ def getResponse(self, request: HttpRequest, error: str = ""):
15
+ context = self.getContext()
16
+ if error != "" or error:
17
+ context["error"] = error
18
+ return render(
19
+ request, self.url_template, context)
20
+
21
+ def getContext(self):
22
+ self.context = {}
23
+ self.context["sesion"] = self.session
24
+ self.words = PalabrasController.getWordsInTechnique(
25
+ self.session.tecnica)
26
+ self.context["palabras"] = [word.nombre_palabra for word in self.words]
27
+
28
+ ratings_for_repetition = []
29
+
30
+ ratings = CalificacionController.getRatingsByTechnique(
31
+ technique=self.session.tecnica)
32
+
33
+ if isinstance(ratings, dict) or not ratings:
34
+ self.context["calificaciones"] = ratings_for_repetition
35
+ self.context["existen_calificaciones"] = False
36
+ return self.context
37
+
38
+ data = DatoController.getWordValuesForConvecional(
39
+ ratings=ratings, technique=self.session.tecnica)
40
+
41
+ ratings_for_repetition = defaultdict(
42
+ lambda: defaultdict(lambda: defaultdict(list)))
43
+
44
+ for item in data:
45
+ user = item["usuarioCatador"]
46
+ rep = item["repeticion"]
47
+ prod = item["producto_code"]
48
+
49
+ ratings_for_repetition[rep][user][prod].append({
50
+ "nombre_palabra": item["nombre_palabra"],
51
+ "dato_valor": item["dato_valor"]
52
+ })
53
+
54
+ self.context["calificaciones"] = defaultdict_to_dict(
55
+ ratings_for_repetition)
56
+ self.context["existen_calificaciones"] = True
tecnicas/controllers/views_controller/session_management/monitor_controller.py ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ from tecnicas.models import SesionSensorial
2
+
3
+
4
+ class MonitorController():
5
+ def __init__(self, session: SesionSensorial):
6
+ self.sensorial_session = session
7
+
8
+ def updataSession(self):
9
+ self.sensorial_session = SesionSensorial.objects.get(
10
+ codigo_sesion=self.sensorial_session.codigo_sesion)
tecnicas/controllers/views_controller/{monitor_sesion_controller.py → session_management/monitor_escalas_controller.py} RENAMED
@@ -1,61 +1,72 @@
 
 
 
1
  from tecnicas.models import SesionSensorial, EsAtributo, EsVocabulario, Producto, Calificacion
2
  from tecnicas.controllers import ParticipacionController, SesionController
3
  from tecnicas.utils import controller_error
 
4
 
5
 
6
- class MonitorSesionController():
7
- def __init__(self, session_code: str):
8
- self.code_session = session_code
9
 
10
- def defineSession(self):
11
- self.session = SesionSensorial.objects.get(
12
- codigo_sesion=self.code_session)
13
 
14
- def monitorView(self):
15
- try:
16
- self.sensorial_session = SesionSensorial.objects.select_related(
17
- "tecnica"
18
- ).only(
19
- "nombre_sesion",
20
- "tecnica__limite_catadores",
21
- ).get(codigo_sesion=self.code_session)
22
 
23
- self.participations = ParticipacionController.getParticipationsInTechinique(
24
- self.sensorial_session.tecnica)
25
- except SesionSensorial.DoesNotExist as error:
26
- return controller_error("No existe Sesión sensorial")
27
 
28
- context = {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29
  "session_name": self.sensorial_session.nombre_sesion,
30
  "max_testers": self.sensorial_session.tecnica.limite_catadores,
31
  "current_testers": len(self.participations),
32
  "active_testers": len([part for part in self.participations if part.activo]),
33
- "participations": self.participations
 
34
  }
35
 
36
- return context
37
-
38
  def getExpectedRatings(self):
39
  num_products = Producto.objects.filter(
40
- id_tecnica=self.session.tecnica).count()
41
-
42
- style_words = self.session.tecnica.id_estilo
43
-
44
  num_words: int
45
 
46
  if style_words.nombre_estilo == "atributos":
47
  num_words = EsAtributo.objects.get(
48
- id_tecnica=self.session.tecnica).palabras.count()
49
  elif style_words.nombre_estilo == "vocabulario":
50
  num_words = EsVocabulario.objects.get(
51
- id_tecnica=self.session.tecnica).id_vocabulario.palabras.count()
52
 
53
  return num_products * num_words
54
 
55
  def checkAllParticipantsEnded(self):
56
- self.defineSession()
57
-
58
- technique = self.session.tecnica
59
 
60
  expected_ratings_repetition = self.getExpectedRatings()
61
 
@@ -75,8 +86,8 @@ class MonitorSesionController():
75
  return (True, "Puedes finalizar la sesión")
76
 
77
  def finishSession(self):
78
- response = SesionController.finishRepetion(self.session)
79
  if isinstance(response, dict):
80
  return controller_error(response["error"])
81
- self.defineSession()
82
- return self.session
 
1
+ from django.http import HttpRequest
2
+ from django.shortcuts import render, redirect
3
+ from django.urls import reverse
4
  from tecnicas.models import SesionSensorial, EsAtributo, EsVocabulario, Producto, Calificacion
5
  from tecnicas.controllers import ParticipacionController, SesionController
6
  from tecnicas.utils import controller_error
7
+ from .monitor_controller import MonitorController
8
 
9
 
10
+ class MonitorEscalasController(MonitorController):
11
+ url_view = "tecnicas/manage_sesions/monitor-sesion.html"
 
12
 
13
+ def __init__(self, session: SesionController):
14
+ super().__init__(session)
 
15
 
16
+ def controlGetResponse(self, request: HttpRequest, error: str = "", message: str = ""):
17
+ self.setContext()
 
 
 
 
 
 
18
 
19
+ if error != "" or error:
20
+ self.context["error"] = error
21
+ if message != "" or message:
22
+ self.context["message"] = message
23
 
24
+ return render(request, self.url_view, self.context)
25
+
26
+ def controlPostResponseFinishSession(self, request: HttpRequest):
27
+ self.setContext()
28
+ (is_all_end, message) = self.checkAllParticipantsEnded()
29
+ if not is_all_end:
30
+ self.context["error"] = message
31
+ return render(request, "tecnicas/manage_sesions/monitor-sesion.html", self.context)
32
+ response = self.finishSession()
33
+ if isinstance(response, dict):
34
+ self.context["error"] = response["error"]
35
+ return render(request, "tecnicas/manage_sesions/monitor-sesion.html", self.context)
36
+ self.context["message"] = message
37
+ return redirect(reverse("cata_system:detalles_sesion", kwargs={"session_code": self.sensorial_session.codigo_sesion}))
38
+
39
+ def setContext(self):
40
+ self.participations = ParticipacionController.getParticipationsInTechinique(
41
+ self.sensorial_session.tecnica)
42
+
43
+ self.context = {
44
+ "code_session": self.sensorial_session.codigo_sesion,
45
  "session_name": self.sensorial_session.nombre_sesion,
46
  "max_testers": self.sensorial_session.tecnica.limite_catadores,
47
  "current_testers": len(self.participations),
48
  "active_testers": len([part for part in self.participations if part.activo]),
49
+ "participations": self.participations,
50
+ "use_technique": self.sensorial_session.tecnica.tipo_tecnica.nombre_tecnica
51
  }
52
 
 
 
53
  def getExpectedRatings(self):
54
  num_products = Producto.objects.filter(
55
+ id_tecnica=self.sensorial_session.tecnica).count()
56
+ style_words = self.sensorial_session.tecnica.id_estilo
 
 
57
  num_words: int
58
 
59
  if style_words.nombre_estilo == "atributos":
60
  num_words = EsAtributo.objects.get(
61
+ id_tecnica=self.sensorial_session.tecnica).palabras.count()
62
  elif style_words.nombre_estilo == "vocabulario":
63
  num_words = EsVocabulario.objects.get(
64
+ id_tecnica=self.sensorial_session.tecnica).id_vocabulario.palabras.count()
65
 
66
  return num_products * num_words
67
 
68
  def checkAllParticipantsEnded(self):
69
+ technique = self.sensorial_session.tecnica
 
 
70
 
71
  expected_ratings_repetition = self.getExpectedRatings()
72
 
 
86
  return (True, "Puedes finalizar la sesión")
87
 
88
  def finishSession(self):
89
+ response = SesionController.finishRepetion(self.sensorial_session)
90
  if isinstance(response, dict):
91
  return controller_error(response["error"])
92
+ self.updataSession()
93
+ return self.sensorial_session
tecnicas/templates/tecnicas/main-panel.html CHANGED
@@ -33,6 +33,10 @@
33
  </section>
34
  </header>
35
 
 
 
 
 
36
  <article class="w-full flex flex-col gap-7 items-center min-sm:mt-7 mt-4 bg-surface-card rounded-lg shadow-lg">
37
  <article
38
  class="w-5xl max-lg:w-3xl max-md:w-auto p-8 flex flex-col justify-around items-center gap-4 flex-wrap text-3xl max-sm:text-2xl">
 
33
  </section>
34
  </header>
35
 
36
+ {% if error %}
37
+ {% include "./components/error-message.html" with message=error %}
38
+ {% endif %}
39
+
40
  <article class="w-full flex flex-col gap-7 items-center min-sm:mt-7 mt-4 bg-surface-card rounded-lg shadow-lg">
41
  <article
42
  class="w-5xl max-lg:w-3xl max-md:w-auto p-8 flex flex-col justify-around items-center gap-4 flex-wrap text-3xl max-sm:text-2xl">
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 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
@@ -17,28 +17,20 @@
17
  </a>
18
  </header>
19
 
20
- {% if error %}
21
- <article class=" bg-red-600 p-4 text-white rounded-xl ct-notification-error">
22
- <p class="block font-sans text-white text-xl antialiased font-bold uppercase tracking-wider text-center">
23
- {{ error }}
24
- </p>
25
- </article>
26
- {% endif %}
27
-
28
  {% if message %}
29
- <article class="bg-green-600 p-4 text-white rounded-xl ct-notification-error">
30
- <p class="block font-sans text-white text-xl antialiased font-bold uppercase tracking-wider text-center">
31
- {{ message }}
32
- </p>
33
- </article>
34
  {% endif %}
35
 
36
  <p class="text-black font-bold text-2xl border-b-2">
37
  Información general
38
  </p>
39
  <article
40
- class="text-black rounded-xl grid grid-cols-2 max-sm:grid-cols-1 gap-3 max-sm:gap-1 *:bg-surface-card *:flex *:flex-wrap *:items-center *:justify-center *:max-sm:justify-normal *:gap-x-2 *:p-4 *:rounded-2xl text-xl max-sm:text-base">
41
- <section class="col-span-2 max-sm:col-span-1">
 
42
  <p class="font-bold">
43
  Código:
44
  </p>
@@ -47,7 +39,8 @@
47
  </p>
48
  </section>
49
 
50
- <section class="col-span-2 max-sm:col-span-1">
 
51
  <p class="font-bold">
52
  Nombre:
53
  </p>
@@ -60,7 +53,8 @@
60
  </p>
61
  </section>
62
 
63
- <section>
 
64
  <p class="font-bold">
65
  Fecha creación:
66
  </p>
@@ -69,7 +63,8 @@
69
  </p>
70
  </section>
71
 
72
- <section>
 
73
  <p class="font-bold">
74
  Estado:
75
  </p>
@@ -82,7 +77,8 @@
82
  </p>
83
  </section>
84
 
85
- <section>
 
86
  <p class="font-bold">
87
  Estilo palabras:
88
  </p>
@@ -91,7 +87,18 @@
91
  </p>
92
  </section>
93
 
94
- <section>
 
 
 
 
 
 
 
 
 
 
 
95
  <p class="font-bold">
96
  Técnica:
97
  </p>
@@ -100,7 +107,18 @@
100
  </p>
101
  </section>
102
 
103
- <section>
 
 
 
 
 
 
 
 
 
 
 
104
  <p class="font-bold">
105
  Rep. Hechas:
106
  </p>
@@ -108,8 +126,8 @@
108
  {{ sesion.tecnica.repeticion }}
109
  </p>
110
  </section>
111
-
112
- <section>
113
  <p class="font-bold">
114
  Rep. Max:
115
  </p>
@@ -117,8 +135,23 @@
117
  {{ sesion.tecnica.repeticiones_max }}
118
  </p>
119
  </section>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
120
 
121
- <section class="col-span-2 max-sm:col-span-1">
 
122
  <p class="font-bold">
123
  Instrucciones:
124
  </p>
@@ -192,8 +225,7 @@
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"
 
5
 
6
  {% block content %}
7
  <article class="cts-container-main">
8
+ <article class="cts-wrap-content relative max-w-4xl">
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
 
17
  </a>
18
  </header>
19
 
 
 
 
 
 
 
 
 
20
  {% if message %}
21
+ {% include "../components/error-message.html" with message=message %}
22
+ {% endif %}
23
+ {% if error %}
24
+ {% include "../components/error-message.html" with message=error %}
 
25
  {% endif %}
26
 
27
  <p class="text-black font-bold text-2xl border-b-2">
28
  Información general
29
  </p>
30
  <article
31
+ class="text-black rounded-xl grid grid-cols-2 max-sm:grid-cols-1 gap-3 max-sm:gap-1 text-xl max-sm:text-base">
32
+ <section
33
+ class="col-span-2 max-sm:col-span-1 bg-surface-ligt flex flex-wrap items-center justify-center max-sm:justify-normal gap-x-2 p-4 rounded-2xl">
34
  <p class="font-bold">
35
  Código:
36
  </p>
 
39
  </p>
40
  </section>
41
 
42
+ <section
43
+ class="col-span-2 max-sm:col-span-1 bg-surface-card flex flex-wrap items-center justify-center max-sm:justify-normal gap-x-2 p-4 rounded-2xl">
44
  <p class="font-bold">
45
  Nombre:
46
  </p>
 
53
  </p>
54
  </section>
55
 
56
+ <section
57
+ class="bg-surface-card flex flex-wrap items-center justify-center max-sm:justify-normal gap-x-2 p-4 rounded-2xl">
58
  <p class="font-bold">
59
  Fecha creación:
60
  </p>
 
63
  </p>
64
  </section>
65
 
66
+ <section
67
+ class="bg-surface-card flex flex-wrap items-center justify-center max-sm:justify-normal gap-x-2 p-4 rounded-2xl">
68
  <p class="font-bold">
69
  Estado:
70
  </p>
 
77
  </p>
78
  </section>
79
 
80
+ <section
81
+ class="bg-surface-card flex flex-wrap items-center justify-center max-sm:justify-normal gap-x-2 p-4 rounded-2xl">
82
  <p class="font-bold">
83
  Estilo palabras:
84
  </p>
 
87
  </p>
88
  </section>
89
 
90
+ <section
91
+ class="bg-surface-card flex flex-wrap items-center justify-center max-sm:justify-normal gap-x-2 p-4 rounded-2xl">
92
+ <p class="font-bold">
93
+ Tipo Escala:
94
+ </p>
95
+ <p class="font-sans text-lg max-sm:text-base font-normal uppercase">
96
+ {{ sesion.tecnica.escala_tecnica }}
97
+ </p>
98
+ </section>
99
+
100
+ <section
101
+ class="bg-surface-ligt flex flex-wrap items-center justify-center max-sm:justify-normal gap-x-2 p-4 rounded-2xl">
102
  <p class="font-bold">
103
  Técnica:
104
  </p>
 
107
  </p>
108
  </section>
109
 
110
+ {% if use_technique == "escalas" %}
111
+ <section
112
+ class="bg-surface-card flex flex-wrap items-center justify-center max-sm:justify-normal gap-x-2 p-4 rounded-2xl">
113
+ <p class="font-bold">
114
+ Catadores Max:
115
+ </p>
116
+ <p class="font-sans text-lg max-sm:text-base font-normal">
117
+ {{ sesion.tecnica.limite_catadores }}
118
+ </p>
119
+ </section>
120
+ <section
121
+ class="bg-surface-card flex flex-wrap items-center justify-center max-sm:justify-normal gap-x-2 p-4 rounded-2xl">
122
  <p class="font-bold">
123
  Rep. Hechas:
124
  </p>
 
126
  {{ sesion.tecnica.repeticion }}
127
  </p>
128
  </section>
129
+ <section
130
+ class="bg-surface-card flex flex-wrap items-center justify-center max-sm:justify-normal gap-x-2 p-4 rounded-2xl">
131
  <p class="font-bold">
132
  Rep. Max:
133
  </p>
 
135
  {{ sesion.tecnica.repeticiones_max }}
136
  </p>
137
  </section>
138
+ {% else %}
139
+ <section
140
+ class="bg-surface-card flex flex-wrap items-center justify-center max-sm:justify-normal gap-x-2 p-4 rounded-2xl">
141
+ <p class="font-sans">
142
+ Pueden ingresar tantos catadores como se desee
143
+ </p>
144
+ </section>
145
+ <section
146
+ class="col-span-2 max-sm:col-span-1 bg-surface-card flex flex-wrap items-center justify-center max-sm:justify-normal gap-x-2 p-4 rounded-2xl">
147
+ <p class="font-sans">
148
+ La técnica usada solo puede realizarse una vez, hay una única repetición
149
+ </p>
150
+ </section>
151
+ {% endif %}
152
 
153
+ <section
154
+ class="col-span-2 max-sm:col-span-1 bg-surface-card flex flex-wrap items-center justify-center max-sm:justify-normal gap-x-2 p-4 rounded-2xl">
155
  <p class="font-bold">
156
  Instrucciones:
157
  </p>
 
225
  ¿Estás seguro de continuar?
226
  </p>
227
  <div class="flex max-sm:flex-col gap-4 justify-center">
228
+ <button class="cts-btn-general cts-btn-error btn-push" onclick="deleteSession()">
 
229
  Estoy seguro
230
  </button>
231
  <button class="cts-btn-general cts-btn-primary btn-push"
tecnicas/templates/tecnicas/manage_sesions/monitor-sesion.html CHANGED
@@ -10,14 +10,6 @@
10
  <h1 class="text-3xl font-bold text-black">Sesión sensorial en curso</h1>
11
  </header>
12
 
13
- {% if error %}
14
- <article class="bg-red-600 p-4 text-white rounded-xl ct-notification-error">
15
- <p class="block font-sans text-white text-xl antialiased font-bold uppercase tracking-wider text-center">
16
- {{ error }}
17
- </p>
18
- </article>
19
- {% endif %}
20
-
21
  <section class="flex flex-col sm:flex-row justify-between items-center gap-10">
22
  <p class="text-xl text-center bg-surface-card p-4 text-black rounded-lg shadow-lg">
23
  Código de sesión:<br>
@@ -41,6 +33,10 @@
41
  {% csrf_token %}
42
  </form>
43
 
 
 
 
 
44
  {% if message %}
45
  {% include "../components/error-message.html" with message=message %}
46
  {% endif %}
@@ -63,12 +59,20 @@
63
  <h2 class="text-xl font-semibold">Participantes</h2>
64
  </div>
65
  <section class="flex flex-wrap justify-around items-center">
 
66
  <div class="flex flex-col sm:flex-row sm:items-center sm:gap-2">
67
  <span class="font-semibold">Máximo:</span>
68
  <span>{{ max_testers }}</span>
69
  </div>
 
70
  <div class="flex flex-col sm:flex-row sm:items-center sm:gap-2">
71
- <span class="font-semibold">Actuales:</span>
 
 
 
 
 
 
72
  <span>{{ current_testers }}</span>
73
  </div>
74
  <div class="flex flex-col sm:flex-row sm:items-center sm:gap-2">
 
10
  <h1 class="text-3xl font-bold text-black">Sesión sensorial en curso</h1>
11
  </header>
12
 
 
 
 
 
 
 
 
 
13
  <section class="flex flex-col sm:flex-row justify-between items-center gap-10">
14
  <p class="text-xl text-center bg-surface-card p-4 text-black rounded-lg shadow-lg">
15
  Código de sesión:<br>
 
33
  {% csrf_token %}
34
  </form>
35
 
36
+ {% if error %}
37
+ {% include "../components/error-message.html" with message=error %}
38
+ {% endif %}
39
+
40
  {% if message %}
41
  {% include "../components/error-message.html" with message=message %}
42
  {% endif %}
 
59
  <h2 class="text-xl font-semibold">Participantes</h2>
60
  </div>
61
  <section class="flex flex-wrap justify-around items-center">
62
+ {% if use_technique == "escalas" %}
63
  <div class="flex flex-col sm:flex-row sm:items-center sm:gap-2">
64
  <span class="font-semibold">Máximo:</span>
65
  <span>{{ max_testers }}</span>
66
  </div>
67
+ {% endif %}
68
  <div class="flex flex-col sm:flex-row sm:items-center sm:gap-2">
69
+ <span class="font-semibold">
70
+ {% if use_technique == "escalas" %}
71
+ Actuales:
72
+ {% else %}
73
+ Total:
74
+ {% endif %}
75
+ </span>
76
  <span>{{ current_testers }}</span>
77
  </div>
78
  <div class="flex flex-col sm:flex-row sm:items-center sm:gap-2">
tecnicas/templates/tecnicas/manage_sesions/sesiones-panel.html CHANGED
@@ -19,10 +19,14 @@
19
  </div>
20
  </header>
21
 
 
 
 
 
22
  {% if error %}
23
  {% include "../components/error-message.html" with message=error %}
24
  {% else %}
25
-
26
  <section class="grid grid-cols-3 max-lg:grid-cols-2 max-sm:grid-cols-1 w-full gap-4 justify-center">
27
  {% for sesion in sessions %}
28
  {% include "../components/item_session.html" with sesion=sesion %}
@@ -39,13 +43,13 @@
39
  </a>
40
  {% endif %}
41
  <button class="join-item btn bg-btn-secondary">Page {{ num_page }}</button>
42
- {% if not last_page %}
43
- <a href="{% url 'cata_system:panel_sesiones' page=num_page|add:1 %}"class="w-fit">
44
  <button class="join-item btn bg-btn-secondary py-1">
45
  <img class="h-full" src="{% static 'img/greater-than.svg' %}" alt="mayor que">
46
  </button>
47
- </a>
48
- {% endif %}
49
  </div>
50
  </section>
51
  {% endif %}
 
19
  </div>
20
  </header>
21
 
22
+ {% if message %}
23
+ {% include "../components/error-message.html" with message=message %}
24
+ {% endif %}
25
+
26
  {% if error %}
27
  {% include "../components/error-message.html" with message=error %}
28
  {% else %}
29
+
30
  <section class="grid grid-cols-3 max-lg:grid-cols-2 max-sm:grid-cols-1 w-full gap-4 justify-center">
31
  {% for sesion in sessions %}
32
  {% include "../components/item_session.html" with sesion=sesion %}
 
43
  </a>
44
  {% endif %}
45
  <button class="join-item btn bg-btn-secondary">Page {{ num_page }}</button>
46
+ {% if not last_page %}
47
+ <a href="{% url 'cata_system:panel_sesiones' page=num_page|add:1 %}" class="w-fit">
48
  <button class="join-item btn bg-btn-secondary py-1">
49
  <img class="h-full" src="{% static 'img/greater-than.svg' %}" alt="mayor que">
50
  </button>
51
+ </a>
52
+ {% endif %}
53
  </div>
54
  </section>
55
  {% endif %}
tecnicas/utils/__init__.py CHANGED
@@ -3,5 +3,6 @@ from .code_generate import generarCodigos
3
  from .personal_errors import general_error, controller_error
4
  from .shuffle_arrays import shuffleArray
5
  from .general_controllers import getId
 
6
  from .to_dict import defaultdict_to_dict
7
  from .delete_data_session import deleteDataSession
 
3
  from .personal_errors import general_error, controller_error
4
  from .shuffle_arrays import shuffleArray
5
  from .general_controllers import getId
6
+ from .general_controllers import noValidTechnique
7
  from .to_dict import defaultdict_to_dict
8
  from .delete_data_session import deleteDataSession
tecnicas/utils/general_controllers.py CHANGED
@@ -1,3 +1,8 @@
 
 
 
 
 
1
  def getId(value: object | int) -> int | None:
2
  if isinstance(value, int):
3
  return value
@@ -7,3 +12,12 @@ def getId(value: object | int) -> int | None:
7
  return value.pk
8
 
9
  return None
 
 
 
 
 
 
 
 
 
 
1
+ from django.shortcuts import redirect
2
+ from django.urls import reverse
3
+ from urllib.parse import urlencode
4
+
5
+
6
  def getId(value: object | int) -> int | None:
7
  if isinstance(value, int):
8
  return value
 
12
  return value.pk
13
 
14
  return None
15
+
16
+
17
+ def noValidTechnique(params: dict, query_params: dict, name_view: str):
18
+ if query_params:
19
+ query_string = urlencode(query_params)
20
+ url_redireccion = f"{reverse({name_view}, kwargs=params)}?{query_string}"
21
+ else:
22
+ url_redireccion = f"{reverse({name_view}, kwargs=params)}"
23
+ return redirect(url_redireccion)
tecnicas/views/sessions_management/session_details.py CHANGED
@@ -1,33 +1,58 @@
1
- from django.http import HttpRequest
2
- from django.shortcuts import render, redirect
3
  from django.urls import reverse
4
- from ...controllers import DetallesSesionController
 
 
5
 
6
 
7
  def sessionDetails(req: HttpRequest, session_code: str):
8
- controller_view = DetallesSesionController(session_code)
9
- context = controller_view.getContextForView()
10
-
11
  if req.method == "GET":
12
- context = controller_view.getContextWithData()
13
- return render(req, "tecnicas/manage_sesions/detalles-sesion.html", context)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
  elif req.method == "POST":
15
- if req.POST["action"] == "start_session":
16
- response = DetallesSesionController.startRepetition(
17
- session_code=session_code, username=req.user.username)
18
- if isinstance(response, dict):
19
- context = controller_view.getContextWithData()
20
- context["error"] = response["error"]
21
- return render(req, "tecnicas/manage_sesions/detalles-sesion.html", context)
22
-
23
- parameters = {
24
- "session_code": controller_view.session.codigo_sesion
25
- }
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)
 
 
 
 
1
+ from django.http import HttpRequest, JsonResponse
2
+ from django.shortcuts import redirect
3
  from django.urls import reverse
4
+ from tecnicas.models import SesionSensorial
5
+ from tecnicas.utils import noValidTechnique
6
+ from ...controllers import DetallesEscalasController
7
 
8
 
9
  def sessionDetails(req: HttpRequest, session_code: str):
 
 
 
10
  if req.method == "GET":
11
+ if "message" in req.GET:
12
+ message = req.GET.get("message")
13
+ else:
14
+ message = ""
15
+
16
+ sensorial_session = SesionSensorial.objects.get(
17
+ codigo_sesion=session_code)
18
+ use_techinique = sensorial_session.tecnica.tipo_tecnica.nombre_tecnica
19
+
20
+ if use_techinique == "escalas" or use_techinique == "rata":
21
+ controller_view = DetallesEscalasController(
22
+ session=sensorial_session)
23
+ response = controller_view.getResponse(
24
+ request=req, message=message)
25
+ else:
26
+ response = noValidTechnique(
27
+ params={"page": 1},
28
+ query_params={
29
+ "message": "Al parecer la sesión usa una técnica que aun no se ha implementado para ver detalles"
30
+ },
31
+ name_view="cata_system:panel_sesiones"
32
+ )
33
+
34
+ return response
35
  elif req.method == "POST":
36
+ sensorial_session = SesionSensorial.objects.get(
37
+ codigo_sesion=session_code)
38
+ use_techinique = sensorial_session.tecnica.tipo_tecnica.nombre_tecnica
39
+
40
+ if use_techinique == "escalas" or use_techinique == "rata":
41
+ controller_view = DetallesEscalasController(sensorial_session)
42
+
43
+ if req.POST["action"] == "start_session":
44
+ response = controller_view.startRepetition(
45
+ presenter=req.user.user_presentador)
46
+ elif req.POST.get("action") == "delete_session":
47
+ controller_view.deleteSesorialSession()
48
+ response = redirect(
49
+ reverse("cata_system:panel_sesiones", kwargs={"page": 1}))
50
+ else:
51
+ response = controller_view.getResponse(
52
+ error="No se reconoce la acción a realizar")
53
  else:
54
+ response = noValidTechnique()
55
+
56
+ return response
57
+ else:
58
+ return JsonResponse({"error": "Método no permitido"})
tecnicas/views/sessions_management/session_monitor.py CHANGED
@@ -7,38 +7,57 @@ Para finalizar la sesion se debe realizar lo siguiente
7
  from django.http import HttpRequest, JsonResponse
8
  from django.shortcuts import render, redirect
9
  from django.urls import reverse
10
- from tecnicas.controllers import MonitorSesionController
11
- from tecnicas.utils import general_error
 
12
 
13
 
14
  def sessionMonitor(req: HttpRequest, session_code: str):
15
- controll_view = MonitorSesionController(session_code)
16
- context = controll_view.monitorView()
17
-
18
  if req.method == "GET":
19
- if "error" in context:
20
- return render(req, "tecnicas/manage_sesions/monitor-sesion.html", context)
 
21
 
22
- context["code_session"] = session_code
23
- return render(req, "tecnicas/manage_sesions/monitor-sesion.html", context)
 
 
 
 
 
 
 
 
 
 
 
 
 
24
  elif req.method == "POST":
25
- action = req.POST["action"]
26
- if action == "finish_session":
27
- return actionFinishSession(context=context, session_code=session_code, controll_view=controll_view, req=req)
 
 
 
 
 
 
 
 
 
 
28
  else:
29
- return general_error("No se ha especificado la acción")
 
 
 
 
 
 
 
 
 
 
30
  else:
31
  return JsonResponse({"error": "Método no permitido"})
32
-
33
-
34
- def actionFinishSession(context: dict, session_code: str, controll_view: MonitorSesionController, req: HttpRequest):
35
- context["code_session"] = session_code
36
- (is_all_end, message) = controll_view.checkAllParticipantsEnded()
37
- context["message"] = message
38
- if not is_all_end:
39
- return render(req, "tecnicas/manage_sesions/monitor-sesion.html", context)
40
- response = controll_view.finishSession()
41
- if isinstance(response, dict):
42
- context["message"] = response["error"]
43
- return render(req, "tecnicas/manage_sesions/monitor-sesion.html", context)
44
- return redirect(reverse("cata_system:detalles_sesion", kwargs={"session_code": session_code}))
 
7
  from django.http import HttpRequest, JsonResponse
8
  from django.shortcuts import render, redirect
9
  from django.urls import reverse
10
+ from tecnicas.models import SesionSensorial
11
+ from tecnicas.controllers import MonitorEscalasController
12
+ from tecnicas.utils import noValidTechnique
13
 
14
 
15
  def sessionMonitor(req: HttpRequest, session_code: str):
 
 
 
16
  if req.method == "GET":
17
+ sensorial_session = SesionSensorial.objects.get(
18
+ codigo_sesion=session_code)
19
+ use_techinique = sensorial_session.tecnica.tipo_tecnica.nombre_tecnica
20
 
21
+ if use_techinique == "escalas" or use_techinique == "rata":
22
+ controll_view = MonitorEscalasController(sensorial_session)
23
+ response = controll_view.controlGetResponse(request=req)
24
+ else:
25
+ response = noValidTechnique(
26
+ params={
27
+ "session_code": session_code,
28
+ },
29
+ query_params={
30
+ "message": "Aun no se puede monitorear sesiones con esta técnica"
31
+ },
32
+ name_view="cata_system:detalles_sesion"
33
+ )
34
+
35
+ return response
36
  elif req.method == "POST":
37
+ sensorial_session = SesionSensorial.objects.get(
38
+ codigo_sesion=session_code)
39
+ use_techinique = sensorial_session.tecnica.tipo_tecnica.nombre_tecnica
40
+
41
+ if use_techinique == "escalas":
42
+ controll_view = MonitorEscalasController(sensorial_session)
43
+ action = req.POST["action"]
44
+ if action == "finish_session":
45
+ response = controll_view.controlPostResponseFinishSession(
46
+ request=req)
47
+ else:
48
+ response = controll_view.controlGetResponse(
49
+ request=req, error="No se ha definido la acción a realizar")
50
  else:
51
+ response = noValidTechnique(
52
+ params={
53
+ "session_code": session_code,
54
+ },
55
+ query_params={
56
+ "message": "La técnica usada en la sesión aun no se implementa para esta función"
57
+ },
58
+ name_view="cata_system:detalles_sesion"
59
+ )
60
+
61
+ return response
62
  else:
63
  return JsonResponse({"error": "Método no permitido"})
 
 
 
 
 
 
 
 
 
 
 
 
 
tecnicas/views/sessions_management/sessions_panel.py CHANGED
@@ -1,22 +1,27 @@
1
- from django.http import HttpRequest
2
  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
- 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)
 
 
 
1
+ from django.http import HttpRequest, JsonResponse
2
  from django.shortcuts import render
3
+ from tecnicas.controllers import SesionController
4
 
5
 
6
  def sesionsPanel(req: HttpRequest, page: int):
7
  context = {"num_page": page}
8
 
9
+ if req.method == "GET":
10
+ response = SesionController.getSessionsSavesByCretor(
11
+ user_name=req.user.username, page=page)
12
 
13
+ if isinstance(response, dict):
14
+ context["error"] = response["error"]
15
+ return render(req, "tecnicas/manage_sesions/sesiones-panel.html", context=context)
16
+
17
+ (sessions_in_page, is_last_page, current_page) = response
18
 
19
+ context["sessions"] = sessions_in_page
20
+ context["last_page"] = is_last_page
21
+ context["num_paginas"] = current_page
22
+ if "message" in req.GET:
23
+ context["message"] = req.GET.get("message")
24
 
25
+ return render(req, "tecnicas/manage_sesions/sesiones-panel.html", context=context)
26
+ else:
27
+ return JsonResponse({"message": "Método no permitido"})
tecnicas/views/tester_forms/init_tester_form.py CHANGED
@@ -1,11 +1,12 @@
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):
8
- session = SesionController.getSessionByCodePanelTester(code_sesion)
9
 
10
  context = {
11
  "session": session
@@ -17,16 +18,20 @@ def initTesterForm(req: HttpRequest, code_sesion: str):
17
  template_url = "tecnicas/forms_tester/init_session.html"
18
 
19
  if req.method == "GET":
20
- order = view_controller.checkAssignOrder()
21
 
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"
29
- context["has_ended"] = True
30
 
31
  return render(req, template_url, context)
32
  elif req.method == "POST":
@@ -35,26 +40,13 @@ def initTesterForm(req: HttpRequest, code_sesion: str):
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):
49
- context["error"] = order["error"]
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(
@@ -67,11 +59,3 @@ def initTesterForm(req: HttpRequest, code_sesion: str):
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)
 
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 MainTesterFormController, ParticipacionController
5
+ from tecnicas.models import SesionSensorial
6
 
7
 
8
  def initTesterForm(req: HttpRequest, code_sesion: str):
9
+ session = SesionSensorial.objects.get(codigo_sesion=code_sesion)
10
 
11
  context = {
12
  "session": session
 
18
  template_url = "tecnicas/forms_tester/init_session.html"
19
 
20
  if req.method == "GET":
21
+ order = view_controller.checkAndAssignOrder()
22
 
23
+ if isinstance(order, dict):
24
+ context["error"] = order["error"]
25
+ return render(req, template_url, context)
26
+
27
+ is_end = view_controller.isEndedSession(
28
+ repetition=session.tecnica.repeticion)
29
+
30
+ req.session["id_order"] = order.id
31
+ context["has_ended"] = is_end
32
 
33
+ if is_end:
34
+ context["message"] = "El catador ha terminado de realizar su evaluación, espere instrucciones del presentador"
 
35
 
36
  return render(req, template_url, context)
37
  elif req.method == "POST":
 
40
  "code_sesion": code_sesion
41
  }
42
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
43
  update_participation = ParticipacionController.enterSession(
44
  tester=req.user.user_catador, session=session)
45
  if isinstance(update_participation, dict):
46
  context["error"] = update_participation["error"]
47
  return render(req, template_url, context)
48
 
49
+ req.session["id_participation"] = update_participation.id
50
  return redirect(reverse("cata_system:session_convencional", kwargs=parameters))
51
  elif req.POST["action"] == "exit_session":
52
  response = ParticipacionController.outSession(
 
59
  return render(req, template_url, context)
60
  else:
61
  return JsonResponse({"error": "metodo no permitido"})