Spaces:
Sleeping
Sleeping
Merge pull request #24 from CascoArcilla/bugsAndFixs
Browse files- tecnicas/controllers/__init__.py +8 -7
- tecnicas/controllers/views_controller/{main_tester_form_controller.py → sessions_tester/init_session_tester_controller.py} +94 -20
- tecnicas/controllers/views_controller/{login_tester_controller.py → sessions_tester/login_session_tester_controller.py} +1 -1
- tecnicas/templates/tecnicas/components/item_session_tester.html +1 -1
- tecnicas/templates/tecnicas/forms_tester/init_session.html +8 -24
- tecnicas/views/tester_forms/init_tester_form.py +24 -39
- tecnicas/views/tester_forms/login_session.py +5 -5
tecnicas/controllers/__init__.py
CHANGED
|
@@ -12,12 +12,6 @@ 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.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 |
-
|
| 21 |
from .views_controller.create_session.panel_basic_controller import PanelBasicController
|
| 22 |
from .views_controller.create_session.panel_tags_controller import PanelTagsController
|
| 23 |
from .views_controller.create_session.panel_codes_controller import PanelCodesController
|
|
@@ -28,4 +22,11 @@ from .views_controller.session_management.details_controller import DetallesCont
|
|
| 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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
from .models_controller.particiapacion_controller import ParticipacionController
|
| 13 |
from .models_controller.dato_controller import DatoController
|
| 14 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
from .views_controller.create_session.panel_basic_controller import PanelBasicController
|
| 16 |
from .views_controller.create_session.panel_tags_controller import PanelTagsController
|
| 17 |
from .views_controller.create_session.panel_codes_controller import PanelCodesController
|
|
|
|
| 22 |
from .views_controller.session_management.details_escala_controller import DetallesEscalasController
|
| 23 |
from .views_controller.session_management.details_rata_controller import DetallesRATAController
|
| 24 |
from .views_controller.session_management.monitor_controller import MonitorController
|
| 25 |
+
from .views_controller.session_management.monitor_escalas_controller import MonitorEscalasController
|
| 26 |
+
|
| 27 |
+
from .views_controller.sessions_tester.login_session_tester_controller import LoginSessionTesterController
|
| 28 |
+
from .views_controller.sessions_tester.init_session_tester_controller import InitSessionTesterController
|
| 29 |
+
|
| 30 |
+
from .views_controller.api_rating_controller import ApiRatingController
|
| 31 |
+
from .views_controller.tester_list_controller import TesterListController
|
| 32 |
+
from .views_controller.list_sessions_tester_controller import ListSessionsTesterController
|
tecnicas/controllers/views_controller/{main_tester_form_controller.py → sessions_tester/init_session_tester_controller.py}
RENAMED
|
@@ -1,28 +1,98 @@
|
|
| 1 |
-
from tecnicas.models import Catador, SesionSensorial, Orden, Participacion, Producto, EsAtributo, Calificacion, EsVocabulario
|
| 2 |
-
from ...utils import controller_error, shuffleArray
|
| 3 |
from django.db import transaction
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
|
| 5 |
|
| 6 |
-
class
|
| 7 |
tester: Catador
|
| 8 |
session: SesionSensorial
|
| 9 |
order: Orden | dict
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
|
| 19 |
def assignOrder(self):
|
| 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")
|
| 28 |
|
|
@@ -44,15 +114,16 @@ class MainTesterFormController():
|
|
| 44 |
return create
|
| 45 |
return self.order_to_assign
|
| 46 |
|
| 47 |
-
def
|
| 48 |
try:
|
| 49 |
participation = Participacion.objects.get(
|
| 50 |
catador=self.tester, tecnica=self.session.tecnica)
|
|
|
|
| 51 |
|
| 52 |
# ////////////////////////////////////////////////////////////// #
|
| 53 |
#
|
| 54 |
-
#
|
| 55 |
-
#
|
| 56 |
# Ha terminado la repeticion
|
| 57 |
#
|
| 58 |
# ////////////////////////////////////////////////////////////// #
|
|
@@ -61,7 +132,8 @@ class MainTesterFormController():
|
|
| 61 |
num_products = Producto.objects.filter(
|
| 62 |
id_tecnica=self.session.tecnica).count()
|
| 63 |
|
| 64 |
-
|
|
|
|
| 65 |
|
| 66 |
num_words: int
|
| 67 |
|
|
@@ -72,12 +144,14 @@ class MainTesterFormController():
|
|
| 72 |
num_words = EsVocabulario.objects.get(
|
| 73 |
id_tecnica=self.session.tecnica).id_vocabulario.palabras.count()
|
| 74 |
|
|
|
|
|
|
|
| 75 |
num_ratings_now = Calificacion.objects.filter(
|
| 76 |
-
id_tecnica=
|
| 77 |
|
| 78 |
-
|
| 79 |
|
| 80 |
-
return
|
| 81 |
else:
|
| 82 |
return participation.finalizado
|
| 83 |
except Participacion.DoesNotExist:
|
|
|
|
|
|
|
|
|
|
| 1 |
from django.db import transaction
|
| 2 |
+
from django.http import HttpRequest
|
| 3 |
+
from django.shortcuts import render, redirect
|
| 4 |
+
from django.urls import reverse
|
| 5 |
+
from tecnicas.models import Catador, SesionSensorial, Orden, Participacion, Producto, EsAtributo, Calificacion, EsVocabulario
|
| 6 |
+
from tecnicas.controllers import ParticipacionController
|
| 7 |
+
from tecnicas.utils import controller_error, shuffleArray
|
| 8 |
|
| 9 |
|
| 10 |
+
class InitSessionTesterController():
|
| 11 |
tester: Catador
|
| 12 |
session: SesionSensorial
|
| 13 |
order: Orden | dict
|
| 14 |
+
current_direction = "tecnicas/forms_tester/init_session.html"
|
| 15 |
+
escalas_direction = "cata_system:session_convencional"
|
| 16 |
+
|
| 17 |
+
def __init__(self, sensorial_session: SesionSensorial, user_tester: Catador):
|
| 18 |
+
self.tester = user_tester
|
| 19 |
+
self.session = sensorial_session
|
| 20 |
+
|
| 21 |
+
def controllGetEscalas(self, request: HttpRequest):
|
| 22 |
+
context = {
|
| 23 |
+
"session": self.session,
|
| 24 |
+
"type_technique": self.session.tecnica.tipo_tecnica.nombre_tecnica
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
+
order = self.checkAndAssignOrder()
|
| 28 |
+
if isinstance(order, dict):
|
| 29 |
+
context["error"] = order["error"]
|
| 30 |
+
return render(request, self.current_direction, context)
|
| 31 |
+
|
| 32 |
+
is_end = self.isEndedSessionEscalas()
|
| 33 |
+
|
| 34 |
+
request.session["id_order"] = order.id
|
| 35 |
+
context["has_ended"] = is_end
|
| 36 |
+
|
| 37 |
+
if is_end:
|
| 38 |
+
context["message"] = "El catador ha terminado de realizar su evaluación, espere instrucciones del presentador"
|
| 39 |
+
|
| 40 |
+
return render(request, self.current_direction, context)
|
| 41 |
+
|
| 42 |
+
def controllPostEscalas(self, request: HttpRequest):
|
| 43 |
+
context = {
|
| 44 |
+
"session": self.session,
|
| 45 |
+
"type_technique": self.session.tecnica.tipo_tecnica.nombre_tecnica
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
if request.POST["action"] == "start_posting":
|
| 49 |
+
parameters = {
|
| 50 |
+
"code_sesion": self.session.codigo_sesion
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
is_end = self.isEndedSessionEscalas()
|
| 54 |
+
if is_end:
|
| 55 |
+
context["message"] = "El catador ha terminado de realizar su evaluación, espere instrucciones del presentador"
|
| 56 |
+
return render(request, self.current_direction, context)
|
| 57 |
+
|
| 58 |
+
update_participation = ParticipacionController.enterSession(
|
| 59 |
+
tester=request.user.user_catador, session=self.session)
|
| 60 |
+
if isinstance(update_participation, dict):
|
| 61 |
+
context["error"] = update_participation["error"]
|
| 62 |
+
return render(request, self.current_direction, context)
|
| 63 |
+
|
| 64 |
+
request.session["id_participation"] = update_participation.id
|
| 65 |
+
return redirect(reverse(self.escalas_direction, kwargs=parameters))
|
| 66 |
+
elif request.POST["action"] == "exit_session":
|
| 67 |
+
response = ParticipacionController.outSession(
|
| 68 |
+
tester=request.user.user_catador, session=self.session)
|
| 69 |
+
if isinstance(response, dict):
|
| 70 |
+
context["error"] = response["error"]
|
| 71 |
+
return render(request, self.current_direction, context)
|
| 72 |
+
else:
|
| 73 |
+
context["error"] = "Acción sin especificar"
|
| 74 |
+
return render(request, self.current_direction, context)
|
| 75 |
+
|
| 76 |
+
def controllGetRATA(self, request: HttpRequest):
|
| 77 |
+
context = {
|
| 78 |
+
"session": self.session,
|
| 79 |
+
"type_technique": self.session.tecnica.tipo_tecnica.nombre_tecnica
|
| 80 |
+
}
|
| 81 |
+
|
| 82 |
+
is_end = self.isEndedSessionEscalas()
|
| 83 |
+
|
| 84 |
+
context["has_ended"] = is_end
|
| 85 |
+
|
| 86 |
+
if is_end:
|
| 87 |
+
context["message"] = "El catador ha terminado de realizar su evaluación, espere instrucciones del presentador"
|
| 88 |
+
|
| 89 |
+
return render(request, self.current_direction, context)
|
| 90 |
|
| 91 |
def assignOrder(self):
|
| 92 |
with transaction.atomic():
|
| 93 |
orders_without_tester = list(Orden.objects.select_for_update().filter(
|
| 94 |
id_tecnica=self.session.tecnica, id_catador=None))
|
| 95 |
|
|
|
|
|
|
|
| 96 |
if not orders_without_tester:
|
| 97 |
return controller_error("Las ordenes se han acabado")
|
| 98 |
|
|
|
|
| 114 |
return create
|
| 115 |
return self.order_to_assign
|
| 116 |
|
| 117 |
+
def isEndedSessionEscalas(self):
|
| 118 |
try:
|
| 119 |
participation = Participacion.objects.get(
|
| 120 |
catador=self.tester, tecnica=self.session.tecnica)
|
| 121 |
+
self.session.refresh_from_db()
|
| 122 |
|
| 123 |
# ////////////////////////////////////////////////////////////// #
|
| 124 |
#
|
| 125 |
+
# numero_calificaciones_esperadas = num_productos * num_palabras
|
| 126 |
+
# Si numero_calificaciones_esperadas ss igual a numero_calificaciones_actuales en la repetcion R
|
| 127 |
# Ha terminado la repeticion
|
| 128 |
#
|
| 129 |
# ////////////////////////////////////////////////////////////// #
|
|
|
|
| 132 |
num_products = Producto.objects.filter(
|
| 133 |
id_tecnica=self.session.tecnica).count()
|
| 134 |
|
| 135 |
+
technique = self.session.tecnica
|
| 136 |
+
style_words = technique.id_estilo.nombre_estilo
|
| 137 |
|
| 138 |
num_words: int
|
| 139 |
|
|
|
|
| 144 |
num_words = EsVocabulario.objects.get(
|
| 145 |
id_tecnica=self.session.tecnica).id_vocabulario.palabras.count()
|
| 146 |
|
| 147 |
+
expected_ratings_repetition = num_products * num_words
|
| 148 |
+
|
| 149 |
num_ratings_now = Calificacion.objects.filter(
|
| 150 |
+
id_tecnica=technique, id_catador=self.tester, num_repeticion=technique.repeticion).count()
|
| 151 |
|
| 152 |
+
is_end = num_ratings_now >= expected_ratings_repetition
|
| 153 |
|
| 154 |
+
return is_end
|
| 155 |
else:
|
| 156 |
return participation.finalizado
|
| 157 |
except Participacion.DoesNotExist:
|
tecnicas/controllers/views_controller/{login_tester_controller.py → sessions_tester/login_session_tester_controller.py}
RENAMED
|
@@ -6,7 +6,7 @@ from tecnicas.models import Catador, SesionSensorial, Participacion
|
|
| 6 |
from tecnicas.utils import controller_error
|
| 7 |
|
| 8 |
|
| 9 |
-
class
|
| 10 |
tester: Catador
|
| 11 |
session: SesionSensorial
|
| 12 |
taster_participation: Participacion
|
|
|
|
| 6 |
from tecnicas.utils import controller_error
|
| 7 |
|
| 8 |
|
| 9 |
+
class LoginSessionTesterController():
|
| 10 |
tester: Catador
|
| 11 |
session: SesionSensorial
|
| 12 |
taster_participation: Participacion
|
tecnicas/templates/tecnicas/components/item_session_tester.html
CHANGED
|
@@ -10,7 +10,7 @@
|
|
| 10 |
|
| 11 |
<article class="text-sm space-y-1">
|
| 12 |
<p><span class="font-semibold">Código:</span> {{ session.codigo_sesion }}</p>
|
| 13 |
-
<p><span class="font-semibold">Técnica:</span> {{ session.tecnica.tipo_tecnica }}</p>
|
| 14 |
<p><span class="font-semibold">Fecha:</span> {{ session.fechaCreacion }}</p>
|
| 15 |
<p>
|
| 16 |
<span class="font-semibold">Finazliado:</span>
|
|
|
|
| 10 |
|
| 11 |
<article class="text-sm space-y-1">
|
| 12 |
<p><span class="font-semibold">Código:</span> {{ session.codigo_sesion }}</p>
|
| 13 |
+
<p class="uppercase"><span class="font-semibold">Técnica:</span> {{ session.tecnica.tipo_tecnica }}</p>
|
| 14 |
<p><span class="font-semibold">Fecha:</span> {{ session.fechaCreacion }}</p>
|
| 15 |
<p>
|
| 16 |
<span class="font-semibold">Finazliado:</span>
|
tecnicas/templates/tecnicas/forms_tester/init_session.html
CHANGED
|
@@ -19,30 +19,15 @@
|
|
| 19 |
</article>
|
| 20 |
|
| 21 |
{% if error %}
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
<article class="bg-red-600 p-4 text-white rounded-xl ct-notification-error">
|
| 25 |
-
<p class="block font-sans text-white text-xl antialiased font-bold uppercase tracking-wider text-center">
|
| 26 |
-
{{ error }}
|
| 27 |
-
</p>
|
| 28 |
-
</article>
|
| 29 |
{% endif %}
|
| 30 |
-
|
| 31 |
{% if message %}
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
<article class="bg-surface-alter-card p-4 rounded-xl max-w-2xl">
|
| 35 |
-
<p class="block text-xl antialiased font-bold text-center">
|
| 36 |
-
{{ message }}
|
| 37 |
-
</p>
|
| 38 |
-
</article>
|
| 39 |
{% endif %}
|
| 40 |
-
|
| 41 |
<hr>
|
| 42 |
|
| 43 |
<article
|
| 44 |
class="rounded-xl grid grid-cols-1 gap-3 text-center *:bg-surface-card *:flex *:flex-wrap *:items-center *:justify-center *:gap-x-2 *:p-4 *:rounded-2xl">
|
| 45 |
-
{% if session %}
|
| 46 |
<section>
|
| 47 |
<p class="text-xl font-bold">
|
| 48 |
Código:
|
|
@@ -68,16 +53,22 @@
|
|
| 68 |
</p>
|
| 69 |
</section>
|
| 70 |
|
|
|
|
| 71 |
<section>
|
| 72 |
<p class="text-xl font-medium">
|
| 73 |
Esta sesión usa el estilo de palabras
|
| 74 |
“<span class="uppercase">{{ session.tecnica.id_estilo }}</span>”
|
| 75 |
</p>
|
| 76 |
</section>
|
|
|
|
| 77 |
|
| 78 |
<section>
|
| 79 |
<p class="text-xl font-medium">
|
|
|
|
| 80 |
Repetición número {{ session.tecnica.repeticion }}
|
|
|
|
|
|
|
|
|
|
| 81 |
</p>
|
| 82 |
</section>
|
| 83 |
|
|
@@ -86,13 +77,6 @@
|
|
| 86 |
{{ session.tecnica.instrucciones }}
|
| 87 |
</p>
|
| 88 |
</section>
|
| 89 |
-
{% else %}
|
| 90 |
-
<section>
|
| 91 |
-
<p class="text-xl font-medium">
|
| 92 |
-
Ha ocurrido un error en renderizar esta vista
|
| 93 |
-
</p>
|
| 94 |
-
</section>
|
| 95 |
-
{% endif %}
|
| 96 |
</article>
|
| 97 |
|
| 98 |
<hr>
|
|
|
|
| 19 |
</article>
|
| 20 |
|
| 21 |
{% if error %}
|
| 22 |
+
{% include "../components/error-message.html" with message=error %}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
{% endif %}
|
|
|
|
| 24 |
{% if message %}
|
| 25 |
+
{% include "../components/error-message.html" with message=message %}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
{% endif %}
|
|
|
|
| 27 |
<hr>
|
| 28 |
|
| 29 |
<article
|
| 30 |
class="rounded-xl grid grid-cols-1 gap-3 text-center *:bg-surface-card *:flex *:flex-wrap *:items-center *:justify-center *:gap-x-2 *:p-4 *:rounded-2xl">
|
|
|
|
| 31 |
<section>
|
| 32 |
<p class="text-xl font-bold">
|
| 33 |
Código:
|
|
|
|
| 53 |
</p>
|
| 54 |
</section>
|
| 55 |
|
| 56 |
+
{% if type_technique == "escalas" or type_technique == "rata" or type_technique == "cata" %}
|
| 57 |
<section>
|
| 58 |
<p class="text-xl font-medium">
|
| 59 |
Esta sesión usa el estilo de palabras
|
| 60 |
“<span class="uppercase">{{ session.tecnica.id_estilo }}</span>”
|
| 61 |
</p>
|
| 62 |
</section>
|
| 63 |
+
{% endif %}
|
| 64 |
|
| 65 |
<section>
|
| 66 |
<p class="text-xl font-medium">
|
| 67 |
+
{% if type_technique == "escalas" %}
|
| 68 |
Repetición número {{ session.tecnica.repeticion }}
|
| 69 |
+
{% else %}
|
| 70 |
+
Única repetición
|
| 71 |
+
{% endif %}
|
| 72 |
</p>
|
| 73 |
</section>
|
| 74 |
|
|
|
|
| 77 |
{{ session.tecnica.instrucciones }}
|
| 78 |
</p>
|
| 79 |
</section>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 80 |
</article>
|
| 81 |
|
| 82 |
<hr>
|
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 tecnicas.controllers import
|
| 5 |
from tecnicas.models import SesionSensorial
|
| 6 |
|
| 7 |
|
|
@@ -12,50 +12,35 @@ def initTesterForm(req: HttpRequest, code_sesion: str):
|
|
| 12 |
"session": session
|
| 13 |
}
|
| 14 |
|
| 15 |
-
|
| 16 |
-
code_sesion, req.user.username)
|
| 17 |
-
|
| 18 |
template_url = "tecnicas/forms_tester/init_session.html"
|
| 19 |
|
| 20 |
-
|
| 21 |
-
|
| 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 |
-
|
| 34 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
|
| 36 |
-
return
|
| 37 |
elif req.method == "POST":
|
| 38 |
-
if
|
| 39 |
-
|
| 40 |
-
|
|
|
|
|
|
|
| 41 |
}
|
|
|
|
|
|
|
| 42 |
|
| 43 |
-
|
| 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(
|
| 53 |
-
tester=req.user.user_catador, session=session)
|
| 54 |
-
if isinstance(response, dict):
|
| 55 |
-
context["error"] = response["error"]
|
| 56 |
-
return render(req, template_url, context)
|
| 57 |
-
else:
|
| 58 |
-
context["error"] = "Acción sin especificar"
|
| 59 |
-
return render(req, template_url, context)
|
| 60 |
else:
|
| 61 |
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 InitSessionTesterController, ParticipacionController
|
| 5 |
from tecnicas.models import SesionSensorial
|
| 6 |
|
| 7 |
|
|
|
|
| 12 |
"session": session
|
| 13 |
}
|
| 14 |
|
| 15 |
+
type_technique = session.tecnica.tipo_tecnica.nombre_tecnica
|
|
|
|
|
|
|
| 16 |
template_url = "tecnicas/forms_tester/init_session.html"
|
| 17 |
|
| 18 |
+
view_controller = InitSessionTesterController(
|
| 19 |
+
sensorial_session=session, user_tester=req.user.user_catador)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
+
if req.method == "GET":
|
| 22 |
+
if type_technique == "escalas":
|
| 23 |
+
response = view_controller.controllGetEscalas(request=req)
|
| 24 |
+
elif type_technique == "rata":
|
| 25 |
+
response = view_controller.controllGetRATA(request=req)
|
| 26 |
+
else:
|
| 27 |
+
context = {
|
| 28 |
+
"error": "La técnica usada en esta sesión o ha sido implementada para ingresar a ella"
|
| 29 |
+
}
|
| 30 |
+
response = render(
|
| 31 |
+
req, template_url, context)
|
| 32 |
|
| 33 |
+
return response
|
| 34 |
elif req.method == "POST":
|
| 35 |
+
if type_technique == "escalas" or type_technique == "rata":
|
| 36 |
+
response = view_controller.controllPostEscalas(request=req)
|
| 37 |
+
else:
|
| 38 |
+
context = {
|
| 39 |
+
"error": "Esta opción aun no esta disponible para la técnica usada por la sesión"
|
| 40 |
}
|
| 41 |
+
response = render(
|
| 42 |
+
req, template_url, context)
|
| 43 |
|
| 44 |
+
return response
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
else:
|
| 46 |
return JsonResponse({"error": "metodo no permitido"})
|
tecnicas/views/tester_forms/login_session.py
CHANGED
|
@@ -2,7 +2,7 @@ from django.http import HttpRequest, JsonResponse
|
|
| 2 |
from django.shortcuts import render, redirect
|
| 3 |
from django.urls import reverse
|
| 4 |
from tecnicas.utils import general_error
|
| 5 |
-
from tecnicas.controllers import
|
| 6 |
|
| 7 |
|
| 8 |
def loginSessionTester(req: HttpRequest):
|
|
@@ -14,7 +14,7 @@ def loginSessionTester(req: HttpRequest):
|
|
| 14 |
if not tester_user or not session_code:
|
| 15 |
return general_error("Se esperan credenciales")
|
| 16 |
|
| 17 |
-
login_controller =
|
| 18 |
|
| 19 |
existCredentials = login_controller.existCredential(
|
| 20 |
tester_user, session_code)
|
|
@@ -28,12 +28,12 @@ def loginSessionTester(req: HttpRequest):
|
|
| 28 |
type_technique = session.tecnica.tipo_tecnica.nombre_tecnica
|
| 29 |
|
| 30 |
if type_technique == "escalas":
|
| 31 |
-
response = login_controller.validateEntryEscalas()
|
| 32 |
elif type_technique == "rata":
|
| 33 |
-
response = login_controller.validateEntryRATA()
|
| 34 |
else:
|
| 35 |
context = {
|
| 36 |
-
"error": "La técnica usada en esta sesión o ha sido implementada para ingresar a ella"
|
| 37 |
}
|
| 38 |
response = render(
|
| 39 |
req, "tecnicas/forms_tester/login_session.html", context)
|
|
|
|
| 2 |
from django.shortcuts import render, redirect
|
| 3 |
from django.urls import reverse
|
| 4 |
from tecnicas.utils import general_error
|
| 5 |
+
from tecnicas.controllers import LoginSessionTesterController
|
| 6 |
|
| 7 |
|
| 8 |
def loginSessionTester(req: HttpRequest):
|
|
|
|
| 14 |
if not tester_user or not session_code:
|
| 15 |
return general_error("Se esperan credenciales")
|
| 16 |
|
| 17 |
+
login_controller = LoginSessionTesterController()
|
| 18 |
|
| 19 |
existCredentials = login_controller.existCredential(
|
| 20 |
tester_user, session_code)
|
|
|
|
| 28 |
type_technique = session.tecnica.tipo_tecnica.nombre_tecnica
|
| 29 |
|
| 30 |
if type_technique == "escalas":
|
| 31 |
+
response = login_controller.validateEntryEscalas(request=req)
|
| 32 |
elif type_technique == "rata":
|
| 33 |
+
response = login_controller.validateEntryRATA(request=req)
|
| 34 |
else:
|
| 35 |
context = {
|
| 36 |
+
"error": "La técnica usada en esta sesión es invalida o no ha sido implementada para ingresar a ella"
|
| 37 |
}
|
| 38 |
response = render(
|
| 39 |
req, "tecnicas/forms_tester/login_session.html", context)
|