Spaces:
Running
Running
Merge pull request #21 from CascoArcilla/HU3
Browse files- tecnicas/constants.py +6 -0
- tecnicas/controllers/__init__.py +7 -1
- tecnicas/controllers/models_controller/escala_controller.py +2 -2
- tecnicas/controllers/models_controller/ordenes_controller.py +7 -7
- tecnicas/controllers/models_controller/palabras_controller.py +1 -1
- tecnicas/controllers/models_controller/sesion_controller.py +5 -5
- tecnicas/controllers/models_controller/tecnica_controller.py +2 -2
- tecnicas/controllers/views_controller/create_session/panel_basic_controller.py +42 -0
- tecnicas/controllers/views_controller/create_session/panel_codes_controller.py +74 -0
- tecnicas/controllers/views_controller/create_session/panel_create_controller.py +157 -0
- tecnicas/controllers/views_controller/create_session/panel_tags_controller.py +71 -0
- tecnicas/controllers/views_controller/create_session/panel_words_controller.py +49 -0
- tecnicas/forms/sesion_basic_form.py +9 -23
- tecnicas/forms/sesion_tags_form.py +25 -15
- tecnicas/static/js/panel-basic.js +76 -4
- tecnicas/templates/tecnicas/create_sesion/configuracion-panel-basic.html +16 -2
- tecnicas/templates/tecnicas/create_sesion/configuracion-panel-tags.html +11 -23
- tecnicas/templates/tecnicas/create_sesion/seleccion-tecnica.html +1 -1
- tecnicas/utils/__init__.py +2 -1
- tecnicas/utils/delete_data_session.py +10 -0
- tecnicas/views/sessions_config/configuration_panel_basic.py +25 -44
- tecnicas/views/sessions_config/configuration_panel_codes.py +24 -48
- tecnicas/views/sessions_config/configuration_panel_tags.py +25 -37
- tecnicas/views/sessions_config/configuration_panel_words.py +24 -35
- tecnicas/views/sessions_config/create_session.py +28 -164
- tecnicas/views/sessions_config/seleccion_tecnica.py +1 -2
tecnicas/constants.py
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FORMS_TO_CREATE_SESSION = [
|
| 2 |
+
"form_basic",
|
| 3 |
+
"form_tags",
|
| 4 |
+
"form_codes",
|
| 5 |
+
"form_words"
|
| 6 |
+
]
|
tecnicas/controllers/__init__.py
CHANGED
|
@@ -18,4 +18,10 @@ from .views_controller.main_tester_form_controller import MainTesterFormControll
|
|
| 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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
|
| 23 |
+
from .views_controller.create_session.panel_basic_controller import PanelBasicController
|
| 24 |
+
from .views_controller.create_session.panel_tags_controller import PanelTagsController
|
| 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
|
tecnicas/controllers/models_controller/escala_controller.py
CHANGED
|
@@ -26,7 +26,7 @@ class EscalaController():
|
|
| 26 |
self.scale.save()
|
| 27 |
return self.scale
|
| 28 |
except DatabaseError as error:
|
| 29 |
-
return controller_error("
|
| 30 |
|
| 31 |
def deleteScale(self):
|
| 32 |
self.scale.delete()
|
|
@@ -67,7 +67,7 @@ class EscalaController():
|
|
| 67 |
return self.tags_relation
|
| 68 |
except DatabaseError as error:
|
| 69 |
self.deleteRelationshipsWithLabels()
|
| 70 |
-
return controller_error("
|
| 71 |
|
| 72 |
@staticmethod
|
| 73 |
def getScaleByTechnique(technique: Tecnica = None, id_technique: int = None):
|
|
|
|
| 26 |
self.scale.save()
|
| 27 |
return self.scale
|
| 28 |
except DatabaseError as error:
|
| 29 |
+
return controller_error("Error al guardar la escala")
|
| 30 |
|
| 31 |
def deleteScale(self):
|
| 32 |
self.scale.delete()
|
|
|
|
| 67 |
return self.tags_relation
|
| 68 |
except DatabaseError as error:
|
| 69 |
self.deleteRelationshipsWithLabels()
|
| 70 |
+
return controller_error("Error en guardar la relación etiqueta escala")
|
| 71 |
|
| 72 |
@staticmethod
|
| 73 |
def getScaleByTechnique(technique: Tecnica = None, id_technique: int = None):
|
tecnicas/controllers/models_controller/ordenes_controller.py
CHANGED
|
@@ -25,13 +25,13 @@ class OrdenesController():
|
|
| 25 |
|
| 26 |
def saveOrders(self):
|
| 27 |
if not self.orders:
|
| 28 |
-
return controller_error("
|
| 29 |
try:
|
| 30 |
for order in self.orders:
|
| 31 |
order.save()
|
| 32 |
return self.orders
|
| 33 |
except DatabaseError as error:
|
| 34 |
-
return controller_error("
|
| 35 |
|
| 36 |
def setPositions(self):
|
| 37 |
codes_ids_products = {}
|
|
@@ -40,21 +40,21 @@ class OrdenesController():
|
|
| 40 |
codes_expect = list(codes_ids_products.keys())
|
| 41 |
|
| 42 |
if len(self.orders) != len(self.raw_list_orders):
|
| 43 |
-
return controller_error("
|
| 44 |
|
| 45 |
self.positions = []
|
| 46 |
for index, order in enumerate(self.raw_list_orders):
|
| 47 |
received_codes_order = list(order.keys())
|
| 48 |
|
| 49 |
if set(received_codes_order) != set(codes_expect):
|
| 50 |
-
return controller_error("
|
| 51 |
|
| 52 |
for name, position_index in order.items():
|
| 53 |
list_product_use = [product for product in self.products
|
| 54 |
if product.codigoProducto == name]
|
| 55 |
|
| 56 |
if len(list_product_use) != 1:
|
| 57 |
-
return controller_error("
|
| 58 |
|
| 59 |
product_use = list_product_use[0]
|
| 60 |
new_position = Posicion(
|
|
@@ -67,13 +67,13 @@ class OrdenesController():
|
|
| 67 |
|
| 68 |
def savePositions(self):
|
| 69 |
if not self.positions:
|
| 70 |
-
return controller_error("
|
| 71 |
try:
|
| 72 |
for position in self.positions:
|
| 73 |
position.save()
|
| 74 |
return self.positions
|
| 75 |
except DatabaseError as error:
|
| 76 |
-
return controller_error("
|
| 77 |
|
| 78 |
@staticmethod
|
| 79 |
def getOrderById(id: int):
|
|
|
|
| 25 |
|
| 26 |
def saveOrders(self):
|
| 27 |
if not self.orders:
|
| 28 |
+
return controller_error("No se han establecido las órdenes para guardar")
|
| 29 |
try:
|
| 30 |
for order in self.orders:
|
| 31 |
order.save()
|
| 32 |
return self.orders
|
| 33 |
except DatabaseError as error:
|
| 34 |
+
return controller_error("Error al guardar las ordenes")
|
| 35 |
|
| 36 |
def setPositions(self):
|
| 37 |
codes_ids_products = {}
|
|
|
|
| 40 |
codes_expect = list(codes_ids_products.keys())
|
| 41 |
|
| 42 |
if len(self.orders) != len(self.raw_list_orders):
|
| 43 |
+
return controller_error("El número de ordenes guardados no coinciden con los recibidos")
|
| 44 |
|
| 45 |
self.positions = []
|
| 46 |
for index, order in enumerate(self.raw_list_orders):
|
| 47 |
received_codes_order = list(order.keys())
|
| 48 |
|
| 49 |
if set(received_codes_order) != set(codes_expect):
|
| 50 |
+
return controller_error("Las ordenes mandadas no contienen los productos esperados")
|
| 51 |
|
| 52 |
for name, position_index in order.items():
|
| 53 |
list_product_use = [product for product in self.products
|
| 54 |
if product.codigoProducto == name]
|
| 55 |
|
| 56 |
if len(list_product_use) != 1:
|
| 57 |
+
return controller_error("No pueden existir dos productos que ocupen la misma posición de un orden")
|
| 58 |
|
| 59 |
product_use = list_product_use[0]
|
| 60 |
new_position = Posicion(
|
|
|
|
| 67 |
|
| 68 |
def savePositions(self):
|
| 69 |
if not self.positions:
|
| 70 |
+
return controller_error("No se han establecido posiciones para guarguar")
|
| 71 |
try:
|
| 72 |
for position in self.positions:
|
| 73 |
position.save()
|
| 74 |
return self.positions
|
| 75 |
except DatabaseError as error:
|
| 76 |
+
return controller_error("Error al guardar las posiciones")
|
| 77 |
|
| 78 |
@staticmethod
|
| 79 |
def getOrderById(id: int):
|
tecnicas/controllers/models_controller/palabras_controller.py
CHANGED
|
@@ -17,7 +17,7 @@ class PalabrasController():
|
|
| 17 |
self.words = []
|
| 18 |
searched_words = list(Palabra.objects.filter(id__in=self.ids_words))
|
| 19 |
if not len(searched_words):
|
| 20 |
-
return controller_error("
|
| 21 |
self.words = searched_words
|
| 22 |
return self.words
|
| 23 |
|
|
|
|
| 17 |
self.words = []
|
| 18 |
searched_words = list(Palabra.objects.filter(id__in=self.ids_words))
|
| 19 |
if not len(searched_words):
|
| 20 |
+
return controller_error("No se han encontrado registros")
|
| 21 |
self.words = searched_words
|
| 22 |
return self.words
|
| 23 |
|
tecnicas/controllers/models_controller/sesion_controller.py
CHANGED
|
@@ -18,9 +18,9 @@ class SesionController():
|
|
| 18 |
|
| 19 |
def setSession(self):
|
| 20 |
if not self.presenter:
|
| 21 |
-
return controller_error("
|
| 22 |
elif not self.technique:
|
| 23 |
-
return controller_error("
|
| 24 |
|
| 25 |
self.sensorial_session = SesionSensorial(
|
| 26 |
tecnica=self.technique,
|
|
@@ -34,13 +34,13 @@ class SesionController():
|
|
| 34 |
|
| 35 |
def saveSession(self):
|
| 36 |
if not self.sensorial_session:
|
| 37 |
-
return controller_error("
|
| 38 |
|
| 39 |
try:
|
| 40 |
self.sensorial_session.save()
|
| 41 |
return self.sensorial_session
|
| 42 |
except DatabaseError as error:
|
| 43 |
-
return controller_error("Error al crear la
|
| 44 |
|
| 45 |
@staticmethod
|
| 46 |
def getSessionsSavesByCretor(user_name: str, page: int):
|
|
@@ -122,7 +122,7 @@ class SesionController():
|
|
| 122 |
|
| 123 |
return number_sessions/9
|
| 124 |
except Presentador.DoesNotExist:
|
| 125 |
-
return controller_error("
|
| 126 |
|
| 127 |
@staticmethod
|
| 128 |
def finishRepetion(session: SesionSensorial | str):
|
|
|
|
| 18 |
|
| 19 |
def setSession(self):
|
| 20 |
if not self.presenter:
|
| 21 |
+
return controller_error("Se requiere presentador para crear sesión")
|
| 22 |
elif not self.technique:
|
| 23 |
+
return controller_error("Se requiere técnica para crear sesión")
|
| 24 |
|
| 25 |
self.sensorial_session = SesionSensorial(
|
| 26 |
tecnica=self.technique,
|
|
|
|
| 34 |
|
| 35 |
def saveSession(self):
|
| 36 |
if not self.sensorial_session:
|
| 37 |
+
return controller_error("No se ha definido la sesión a guardar")
|
| 38 |
|
| 39 |
try:
|
| 40 |
self.sensorial_session.save()
|
| 41 |
return self.sensorial_session
|
| 42 |
except DatabaseError as error:
|
| 43 |
+
return controller_error("Error al crear la sesión sensorial")
|
| 44 |
|
| 45 |
@staticmethod
|
| 46 |
def getSessionsSavesByCretor(user_name: str, page: int):
|
|
|
|
| 122 |
|
| 123 |
return number_sessions/9
|
| 124 |
except Presentador.DoesNotExist:
|
| 125 |
+
return controller_error("Presentador invalido")
|
| 126 |
|
| 127 |
@staticmethod
|
| 128 |
def finishRepetion(session: SesionSensorial | str):
|
tecnicas/controllers/models_controller/tecnica_controller.py
CHANGED
|
@@ -15,7 +15,7 @@ class TecnicaController():
|
|
| 15 |
|
| 16 |
def setTechniqueFromBasicData(self, basic):
|
| 17 |
self.technique = Tecnica(
|
| 18 |
-
tipo_tecnica=TipoTecnica.objects.get(
|
| 19 |
id_estilo=EstiloPalabra.objects.get(id=basic["estilo_palabras"]),
|
| 20 |
repeticiones_max=basic["numero_repeticiones"] or 0,
|
| 21 |
limite_catadores=basic["numero_catadores"],
|
|
@@ -30,7 +30,7 @@ class TecnicaController():
|
|
| 30 |
self.technique.save()
|
| 31 |
return self.technique
|
| 32 |
except DatabaseError:
|
| 33 |
-
return controller_error("No se ha podido guardar la
|
| 34 |
|
| 35 |
def deleteTechnique(self):
|
| 36 |
self.technique.delete()
|
|
|
|
| 15 |
|
| 16 |
def setTechniqueFromBasicData(self, basic):
|
| 17 |
self.technique = Tecnica(
|
| 18 |
+
tipo_tecnica=TipoTecnica.objects.get(nombre_tecnica=basic["name_tecnica"]),
|
| 19 |
id_estilo=EstiloPalabra.objects.get(id=basic["estilo_palabras"]),
|
| 20 |
repeticiones_max=basic["numero_repeticiones"] or 0,
|
| 21 |
limite_catadores=basic["numero_catadores"],
|
|
|
|
| 30 |
self.technique.save()
|
| 31 |
return self.technique
|
| 32 |
except DatabaseError:
|
| 33 |
+
return controller_error("No se ha podido guardar la técnica")
|
| 34 |
|
| 35 |
def deleteTechnique(self):
|
| 36 |
self.technique.delete()
|
tecnicas/controllers/views_controller/create_session/panel_basic_controller.py
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from tecnicas.forms import SesionBasicForm
|
| 2 |
+
from django.http import HttpRequest
|
| 3 |
+
from django.shortcuts import redirect, render
|
| 4 |
+
from django.urls import reverse
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
class PanelBasicController():
|
| 8 |
+
def __init__(self):
|
| 9 |
+
pass
|
| 10 |
+
|
| 11 |
+
@staticmethod
|
| 12 |
+
def controllGetEscalas(request: HttpRequest):
|
| 13 |
+
form_sesion = SesionBasicForm()
|
| 14 |
+
response = render(
|
| 15 |
+
request, "tecnicas/create_sesion/configuracion-panel-basic.html", {"form_sesion": form_sesion})
|
| 16 |
+
return response
|
| 17 |
+
|
| 18 |
+
@staticmethod
|
| 19 |
+
def controllPostEscalas(request: HttpRequest, name_tecnica: str):
|
| 20 |
+
try:
|
| 21 |
+
form = SesionBasicForm(request.POST)
|
| 22 |
+
|
| 23 |
+
if form.is_valid():
|
| 24 |
+
values = {}
|
| 25 |
+
for name, value in form.cleaned_data.items():
|
| 26 |
+
if name == "estilo_palabras" or name == "tipo_escala":
|
| 27 |
+
values[name] = value.id
|
| 28 |
+
else:
|
| 29 |
+
values[name] = value
|
| 30 |
+
|
| 31 |
+
values["name_tecnica"] = name_tecnica
|
| 32 |
+
request.session['form_basic'] = values
|
| 33 |
+
response = redirect(
|
| 34 |
+
reverse("cata_system:panel_configuracion_tags"))
|
| 35 |
+
else:
|
| 36 |
+
response = render(request, "tecnicas/create_sesion/configuracion-panel-basic.html", {
|
| 37 |
+
"form_sesion": form, "error": "Información no valida"})
|
| 38 |
+
except KeyError:
|
| 39 |
+
response = redirect(reverse(
|
| 40 |
+
"cata_system:seleccion_tecnica") + "?error=error en datos de configuracion")
|
| 41 |
+
|
| 42 |
+
return response
|
tecnicas/controllers/views_controller/create_session/panel_codes_controller.py
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from django.http import HttpRequest
|
| 2 |
+
from django.shortcuts import redirect, render
|
| 3 |
+
from django.urls import reverse
|
| 4 |
+
from tecnicas.forms import CodesForm
|
| 5 |
+
from tecnicas.utils import generarCodigos
|
| 6 |
+
import json
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
class PanelCodesController():
|
| 10 |
+
def __init__(self):
|
| 11 |
+
pass
|
| 12 |
+
|
| 13 |
+
@staticmethod
|
| 14 |
+
def controllGetEscalas(request: HttpRequest, data):
|
| 15 |
+
(
|
| 16 |
+
num_products,
|
| 17 |
+
num_tester
|
| 18 |
+
) = PanelCodesController.defineInfoConvencional(data)
|
| 19 |
+
|
| 20 |
+
codes_products = generarCodigos(num_products)
|
| 21 |
+
|
| 22 |
+
form_codes = CodesForm(codes=codes_products)
|
| 23 |
+
|
| 24 |
+
context_codes_form = {
|
| 25 |
+
"form_codes": form_codes,
|
| 26 |
+
"num_tester": num_tester
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
return render(request, "tecnicas/create_sesion/configuracion-panel-codes.html", context_codes_form)
|
| 30 |
+
|
| 31 |
+
@staticmethod
|
| 32 |
+
def controllPostEscalas(request: HttpRequest, data):
|
| 33 |
+
(
|
| 34 |
+
num_products,
|
| 35 |
+
num_tester
|
| 36 |
+
) = PanelCodesController.defineInfoConvencional(data)
|
| 37 |
+
|
| 38 |
+
sorts_code = json.loads(request.POST.get("sort_codes"))
|
| 39 |
+
codes = []
|
| 40 |
+
context_codes_form = {}
|
| 41 |
+
|
| 42 |
+
for name, value in request.POST.items():
|
| 43 |
+
if name.__contains__("producto_"):
|
| 44 |
+
codes.append(value)
|
| 45 |
+
|
| 46 |
+
form_codes = CodesForm(request.POST, codes=codes)
|
| 47 |
+
|
| 48 |
+
context_codes_form = {
|
| 49 |
+
"form_codes": form_codes,
|
| 50 |
+
"num_tester": num_tester,
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
if form_codes.is_valid():
|
| 54 |
+
codes_sort = {"product_codes": []}
|
| 55 |
+
|
| 56 |
+
for name, value in form_codes.cleaned_data.items():
|
| 57 |
+
codes_sort["product_codes"].append({name: value})
|
| 58 |
+
|
| 59 |
+
codes_sort["sort_codes"] = sorts_code
|
| 60 |
+
request.session["form_codes"] = codes_sort
|
| 61 |
+
return redirect(reverse("cata_system:panel_configuracion_words"))
|
| 62 |
+
else:
|
| 63 |
+
context_codes_form["error"] = "error en los datos recibidos"
|
| 64 |
+
|
| 65 |
+
return render(request, "tecnicas/create_sesion/configuracion-panel-codes.html", context_codes_form)
|
| 66 |
+
|
| 67 |
+
@staticmethod
|
| 68 |
+
def defineInfoConvencional(data):
|
| 69 |
+
num_products = data["numero_productos"]
|
| 70 |
+
num_tester = data["numero_catadores"]
|
| 71 |
+
return (
|
| 72 |
+
num_products,
|
| 73 |
+
num_tester
|
| 74 |
+
)
|
tecnicas/controllers/views_controller/create_session/panel_create_controller.py
ADDED
|
@@ -0,0 +1,157 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from django.http import HttpRequest, JsonResponse
|
| 2 |
+
from django.db import transaction
|
| 3 |
+
from tecnicas.utils import general_error
|
| 4 |
+
from tecnicas.controllers import TecnicaController, EscalaController, ProductosController, OrdenesController, EstiloPalabrasController, PalabrasController, SesionController
|
| 5 |
+
from tecnicas.utils import deleteDataSession
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
class PanelCreateController():
|
| 9 |
+
def __init__(self):
|
| 10 |
+
pass
|
| 11 |
+
|
| 12 |
+
@staticmethod
|
| 13 |
+
def controllGetEscalas(request: HttpRequest, data):
|
| 14 |
+
pass
|
| 15 |
+
|
| 16 |
+
@staticmethod
|
| 17 |
+
def controllPostEscalas(request: HttpRequest):
|
| 18 |
+
if request.POST.get('action') == 'create_session':
|
| 19 |
+
if not request.session.get("form_tags") or not request.session.get("form_codes") or not request.session.get("form_words"):
|
| 20 |
+
deleteDataSession(request)
|
| 21 |
+
return general_error("No se ha especificado información necesaria para la creación de la sesión, por favor, vuelve a intentarlo")
|
| 22 |
+
|
| 23 |
+
with transaction.atomic():
|
| 24 |
+
# ////////////////////////////////////////////////////// #
|
| 25 |
+
#
|
| 26 |
+
# First step: Create technique and scale with their tags #
|
| 27 |
+
#
|
| 28 |
+
# ////////////////////////////////////////////////////// #
|
| 29 |
+
data_basic = request.session["form_basic"]
|
| 30 |
+
controllerTechnique = TecnicaController()
|
| 31 |
+
controllerTechnique.setTechniqueFromBasicData(basic=data_basic)
|
| 32 |
+
|
| 33 |
+
technique = controllerTechnique.saveTechnique()
|
| 34 |
+
if not technique:
|
| 35 |
+
return general_error("Error al guardar la técnica")
|
| 36 |
+
|
| 37 |
+
data_scale = {
|
| 38 |
+
"id_scale": data_basic["tipo_escala"],
|
| 39 |
+
"size": data_basic["tamano_escala"],
|
| 40 |
+
"technique": technique
|
| 41 |
+
}
|
| 42 |
+
|
| 43 |
+
controllerScale = EscalaController(data=data_scale)
|
| 44 |
+
|
| 45 |
+
scale = controllerScale.saveScale()
|
| 46 |
+
if isinstance(scale, dict):
|
| 47 |
+
return general_error(scale["error"])
|
| 48 |
+
|
| 49 |
+
dict_tags = request.session["form_tags"]
|
| 50 |
+
saved_related_tags = controllerScale.realteTags(dict_tags)
|
| 51 |
+
if "error" in saved_related_tags:
|
| 52 |
+
return general_error(saved_related_tags["error"])
|
| 53 |
+
|
| 54 |
+
# ////////////////////////////////////////////////////////// #
|
| 55 |
+
#
|
| 56 |
+
# Second step: Create orders, productos and set the position #
|
| 57 |
+
#
|
| 58 |
+
# ////////////////////////////////////////////////////////// #
|
| 59 |
+
data_codes = request.session["form_codes"]
|
| 60 |
+
|
| 61 |
+
list_codes_dict = data_codes["product_codes"]
|
| 62 |
+
|
| 63 |
+
codes = []
|
| 64 |
+
for product in list_codes_dict:
|
| 65 |
+
code = next(iter(product.values()))
|
| 66 |
+
codes.append(code)
|
| 67 |
+
|
| 68 |
+
controllerProducts = ProductosController(
|
| 69 |
+
codes=codes,
|
| 70 |
+
technique=technique
|
| 71 |
+
)
|
| 72 |
+
|
| 73 |
+
controllerProducts.setProductsNoSave()
|
| 74 |
+
saved_prodcuts = controllerProducts.saveProducts()
|
| 75 |
+
if isinstance(saved_prodcuts, dict):
|
| 76 |
+
return general_error(saved_prodcuts["error"])
|
| 77 |
+
|
| 78 |
+
raw_sort_codes = data_codes["sort_codes"]
|
| 79 |
+
controllerOrdes = OrdenesController(
|
| 80 |
+
raw_orders=raw_sort_codes,
|
| 81 |
+
list_products=saved_prodcuts,
|
| 82 |
+
technique=technique
|
| 83 |
+
)
|
| 84 |
+
|
| 85 |
+
controllerOrdes.setOrdersToSave()
|
| 86 |
+
saved_orders = controllerOrdes.saveOrders()
|
| 87 |
+
if isinstance(saved_orders, dict):
|
| 88 |
+
return general_error(saved_orders["error"])
|
| 89 |
+
|
| 90 |
+
seded_positions = controllerOrdes.setPositions()
|
| 91 |
+
if isinstance(seded_positions, dict):
|
| 92 |
+
return general_error(seded_positions["error"])
|
| 93 |
+
|
| 94 |
+
saved_postions = controllerOrdes.savePositions()
|
| 95 |
+
if isinstance(saved_postions, dict):
|
| 96 |
+
return general_error(saved_prodcuts["error"])
|
| 97 |
+
|
| 98 |
+
# /////////////////////////////////////////////////////// #
|
| 99 |
+
#
|
| 100 |
+
# Third step: Create relations technique with Words Style #
|
| 101 |
+
#
|
| 102 |
+
# /////////////////////////////////////////////////////// #
|
| 103 |
+
ids_words = request.session["form_words"]
|
| 104 |
+
words_controller = PalabrasController(ids=ids_words)
|
| 105 |
+
|
| 106 |
+
words_to_use = words_controller.setWords()
|
| 107 |
+
if isinstance(words_to_use, dict):
|
| 108 |
+
return general_error(words_to_use["error"])
|
| 109 |
+
|
| 110 |
+
style_controller = EstiloPalabrasController(
|
| 111 |
+
technique=technique, words=words_to_use)
|
| 112 |
+
|
| 113 |
+
instace_style = style_controller.createAndSaveInstaceStyle()
|
| 114 |
+
if isinstance(instace_style, dict):
|
| 115 |
+
return general_error(instace_style["error"])
|
| 116 |
+
|
| 117 |
+
words_using = style_controller.relatedWords()
|
| 118 |
+
if isinstance(words_using, dict):
|
| 119 |
+
return general_error(words_using["error"])
|
| 120 |
+
|
| 121 |
+
# //////////////////////////////////////////////////////// #
|
| 122 |
+
#
|
| 123 |
+
# Fourth step: Create session and relat with the technique #
|
| 124 |
+
#
|
| 125 |
+
# //////////////////////////////////////////////////////// #
|
| 126 |
+
session_controller = SesionController(
|
| 127 |
+
name_session=data_basic["nombre_sesion"] if data_basic["nombre_sesion"] != "" else None,
|
| 128 |
+
technique=technique,
|
| 129 |
+
creator=request.user.user_presentador
|
| 130 |
+
)
|
| 131 |
+
|
| 132 |
+
setting_session = session_controller.setSession()
|
| 133 |
+
if isinstance(setting_session, dict):
|
| 134 |
+
return general_error(setting_session["error"])
|
| 135 |
+
|
| 136 |
+
saved_session = session_controller.saveSession()
|
| 137 |
+
if isinstance(saved_session, dict):
|
| 138 |
+
return general_error(saved_session["error"])
|
| 139 |
+
|
| 140 |
+
context = {
|
| 141 |
+
"message": "sesión creada",
|
| 142 |
+
"data": {
|
| 143 |
+
"codigo_sesion": saved_session.codigo_sesion,
|
| 144 |
+
"nombre_sesion": saved_session.nombre_sesion
|
| 145 |
+
}
|
| 146 |
+
}
|
| 147 |
+
|
| 148 |
+
# ////////////////////////////////// #
|
| 149 |
+
#
|
| 150 |
+
# Final step: Delete date en session #
|
| 151 |
+
#
|
| 152 |
+
# ////////////////////////////////// #
|
| 153 |
+
|
| 154 |
+
deleteDataSession(request)
|
| 155 |
+
return JsonResponse(context)
|
| 156 |
+
else:
|
| 157 |
+
return general_error("No se ha establecido acción")
|
tecnicas/controllers/views_controller/create_session/panel_tags_controller.py
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from django.http import HttpRequest
|
| 2 |
+
from django.shortcuts import redirect, render
|
| 3 |
+
from django.urls import reverse
|
| 4 |
+
from tecnicas.forms import SesionTagsForm, EtiquetaForm
|
| 5 |
+
from tecnicas.models import TipoEscala
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
class PanelTagsController():
|
| 9 |
+
def __init__(self):
|
| 10 |
+
pass
|
| 11 |
+
|
| 12 |
+
@staticmethod
|
| 13 |
+
def controllGetEscalas(request: HttpRequest, data):
|
| 14 |
+
(
|
| 15 |
+
type_scale,
|
| 16 |
+
tamano_escala,
|
| 17 |
+
form_new_etiqueta
|
| 18 |
+
) = PanelTagsController.defineInfoScale(data)
|
| 19 |
+
|
| 20 |
+
form_etiqutas = SesionTagsForm(
|
| 21 |
+
longitud=tamano_escala, tipo_escala=type_scale.nombre_escala)
|
| 22 |
+
|
| 23 |
+
context_tags = {
|
| 24 |
+
"form_tags": form_etiqutas,
|
| 25 |
+
"form_new_tag": form_new_etiqueta
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
return render(request, "tecnicas/create_sesion/configuracion-panel-tags.html", context_tags)
|
| 29 |
+
|
| 30 |
+
@staticmethod
|
| 31 |
+
def controllPostEscalas(request: HttpRequest, data):
|
| 32 |
+
(
|
| 33 |
+
type_scale,
|
| 34 |
+
tamano_escala,
|
| 35 |
+
form_new_etiqueta
|
| 36 |
+
) = PanelTagsController.defineInfoScale(data)
|
| 37 |
+
|
| 38 |
+
values = {}
|
| 39 |
+
form = SesionTagsForm(request.POST, longitud=tamano_escala,
|
| 40 |
+
tipo_escala=type_scale.nombre_escala)
|
| 41 |
+
|
| 42 |
+
context_tags = {
|
| 43 |
+
"form_tags": form,
|
| 44 |
+
"form_new_tag": form_new_etiqueta
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
if form.is_valid():
|
| 48 |
+
for name, value in form.cleaned_data.items():
|
| 49 |
+
values[name] = value.id
|
| 50 |
+
|
| 51 |
+
request.session["form_tags"] = values
|
| 52 |
+
response = redirect(
|
| 53 |
+
reverse("cata_system:panel_configuracion_codes"))
|
| 54 |
+
else:
|
| 55 |
+
context_tags["error"] = "ha ocurrido un error"
|
| 56 |
+
response = render(
|
| 57 |
+
request, "tecnicas/create_sesion/configuracion-panel-tags.html", context_tags)
|
| 58 |
+
|
| 59 |
+
return response
|
| 60 |
+
|
| 61 |
+
@staticmethod
|
| 62 |
+
def defineInfoScale(data):
|
| 63 |
+
type_scale = TipoEscala.objects.get(pk=data["tipo_escala"])
|
| 64 |
+
tamano_escala = data["tamano_escala"]
|
| 65 |
+
form_new_etiqueta = EtiquetaForm()
|
| 66 |
+
|
| 67 |
+
return (
|
| 68 |
+
type_scale,
|
| 69 |
+
tamano_escala,
|
| 70 |
+
form_new_etiqueta
|
| 71 |
+
)
|
tecnicas/controllers/views_controller/create_session/panel_words_controller.py
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from django.http import HttpRequest
|
| 2 |
+
from tecnicas.forms import WordForm
|
| 3 |
+
from django.shortcuts import render, redirect
|
| 4 |
+
from django.urls import reverse
|
| 5 |
+
from tecnicas.models import Palabra
|
| 6 |
+
import json
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
class PanelWordsController():
|
| 10 |
+
def __init__(self):
|
| 11 |
+
pass
|
| 12 |
+
|
| 13 |
+
@staticmethod
|
| 14 |
+
def controllGetEscalas(request: HttpRequest):
|
| 15 |
+
form = WordForm()
|
| 16 |
+
context = {
|
| 17 |
+
"form_word": form
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
return render(request, "tecnicas/create_sesion/configuracion-panel-words.html", context)
|
| 21 |
+
|
| 22 |
+
@staticmethod
|
| 23 |
+
def controllPostEscalas(request: HttpRequest):
|
| 24 |
+
form = WordForm()
|
| 25 |
+
context = {
|
| 26 |
+
"form_word": form
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
if not request.POST.get("words"):
|
| 30 |
+
return render(request, "tecnicas/create_sesion/configuracion-panel-words.html", context)
|
| 31 |
+
|
| 32 |
+
words = json.loads(request.POST.get("words"))
|
| 33 |
+
context["words"] = words
|
| 34 |
+
|
| 35 |
+
ids_words = [word["id"] for word in words]
|
| 36 |
+
|
| 37 |
+
if len(ids_words) != len(set(ids_words)):
|
| 38 |
+
context["error"] = "existen palabras duplicadas"
|
| 39 |
+
return render(request, "tecnicas/create_sesion/configuracion-panel-words.html", context)
|
| 40 |
+
|
| 41 |
+
exist_words = Palabra.objects.filter(
|
| 42 |
+
id__in=ids_words).count() == len(ids_words)
|
| 43 |
+
|
| 44 |
+
if not exist_words:
|
| 45 |
+
context["error"] = "algunas palabras no existen"
|
| 46 |
+
return render(request, "tecnicas/create_sesion/configuracion-panel-words.html", context)
|
| 47 |
+
|
| 48 |
+
request.session["form_words"] = ids_words
|
| 49 |
+
return redirect(reverse("cata_system:creando_sesion"))
|
tecnicas/forms/sesion_basic_form.py
CHANGED
|
@@ -5,7 +5,8 @@ from ..models import EstiloPalabra
|
|
| 5 |
|
| 6 |
|
| 7 |
class SesionBasicForm(forms.Form):
|
| 8 |
-
|
|
|
|
| 9 |
|
| 10 |
nombre_sesion = forms.CharField(max_length=255, widget=forms.TextInput(attrs={
|
| 11 |
"class": "bg-surface-ligt border-b-1 text-center w-full p-1",
|
|
@@ -28,36 +29,28 @@ class SesionBasicForm(forms.Form):
|
|
| 28 |
"placeholder": "Solo números"
|
| 29 |
}), required=True)
|
| 30 |
|
| 31 |
-
tamano_escala = forms.IntegerField(widget=forms.NumberInput(attrs={
|
| 32 |
-
"class": "bg-surface-ligt p-1 border-b-1 text-center w-full",
|
| 33 |
-
}), required=True, min_value=5)
|
| 34 |
-
|
| 35 |
instrucciones = forms.CharField(max_length=255, widget=forms.TextInput(attrs={
|
| 36 |
"class": "bg-surface-ligt border-b-1 text-center w-full p-1",
|
| 37 |
"placeholder": "Este campo es opcional"
|
| 38 |
}), required=False)
|
| 39 |
|
| 40 |
-
def __init__(self, *args,
|
| 41 |
super().__init__(*args, **kwargs)
|
| 42 |
|
| 43 |
self.fields['estilo_palabras'] = forms.ModelChoiceField(queryset=EstiloPalabra.objects.all(), widget=forms.RadioSelect(attrs={
|
| 44 |
-
|
| 45 |
}), required=True, initial=EstiloPalabra.objects.first())
|
| 46 |
|
| 47 |
self.fields['tipo_escala'] = forms.ModelChoiceField(queryset=TipoEscala.objects.all(), widget=forms.RadioSelect(attrs={
|
| 48 |
"class": "uppercase text-lg tracking-wider font-medium p-2 px-4 active:px-5 transition-all rounded-xl bg-blue-500 text-white",
|
| 49 |
}), required=True, initial=TipoEscala.objects.first())
|
| 50 |
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
|
| 55 |
def clean(self):
|
| 56 |
data_clean = super().clean()
|
| 57 |
-
|
| 58 |
-
sizes_estruturada = [5, 7, 9]
|
| 59 |
-
sizes_continua = [9, 12, 15]
|
| 60 |
-
|
| 61 |
escala = data_clean.get("tipo_escala")
|
| 62 |
|
| 63 |
if escala and not isinstance(escala, TipoEscala):
|
|
@@ -70,14 +63,7 @@ class SesionBasicForm(forms.Form):
|
|
| 70 |
|
| 71 |
tamano_escala = data_clean.get("tamano_escala")
|
| 72 |
|
| 73 |
-
if escala.nombre_escala == "estructurada" and not
|
| 74 |
self.add_error("tamano_escala", "El tamaño de la escala no aplica")
|
| 75 |
-
elif escala.nombre_escala == "continua" and not
|
| 76 |
self.add_error("tamano_escala", "El tamaño de la escala no aplica")
|
| 77 |
-
|
| 78 |
-
id_tecnica = data_clean.get("id_tecnica")
|
| 79 |
-
|
| 80 |
-
try:
|
| 81 |
-
tecnica = TipoTecnica.objects.get(pk=id_tecnica)
|
| 82 |
-
except (ValueError, TipoTecnica.DoesNotExist):
|
| 83 |
-
return data_clean
|
|
|
|
| 5 |
|
| 6 |
|
| 7 |
class SesionBasicForm(forms.Form):
|
| 8 |
+
sizes_structure = [5, 7, 9]
|
| 9 |
+
sizes_continue = [9, 13, 15]
|
| 10 |
|
| 11 |
nombre_sesion = forms.CharField(max_length=255, widget=forms.TextInput(attrs={
|
| 12 |
"class": "bg-surface-ligt border-b-1 text-center w-full p-1",
|
|
|
|
| 29 |
"placeholder": "Solo números"
|
| 30 |
}), required=True)
|
| 31 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
instrucciones = forms.CharField(max_length=255, widget=forms.TextInput(attrs={
|
| 33 |
"class": "bg-surface-ligt border-b-1 text-center w-full p-1",
|
| 34 |
"placeholder": "Este campo es opcional"
|
| 35 |
}), required=False)
|
| 36 |
|
| 37 |
+
def __init__(self, *args, **kwargs):
|
| 38 |
super().__init__(*args, **kwargs)
|
| 39 |
|
| 40 |
self.fields['estilo_palabras'] = forms.ModelChoiceField(queryset=EstiloPalabra.objects.all(), widget=forms.RadioSelect(attrs={
|
| 41 |
+
"class": "uppercase text-lg tracking-wider font-medium p-2 px-4 active:px-5 transition-all rounded-xl bg-blue-500 text-white",
|
| 42 |
}), required=True, initial=EstiloPalabra.objects.first())
|
| 43 |
|
| 44 |
self.fields['tipo_escala'] = forms.ModelChoiceField(queryset=TipoEscala.objects.all(), widget=forms.RadioSelect(attrs={
|
| 45 |
"class": "uppercase text-lg tracking-wider font-medium p-2 px-4 active:px-5 transition-all rounded-xl bg-blue-500 text-white",
|
| 46 |
}), required=True, initial=TipoEscala.objects.first())
|
| 47 |
|
| 48 |
+
self.fields['tamano_escala'] = forms.IntegerField(widget=forms.HiddenInput(attrs={
|
| 49 |
+
"class": "cts-size-input",
|
| 50 |
+
}), required=True)
|
| 51 |
|
| 52 |
def clean(self):
|
| 53 |
data_clean = super().clean()
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
escala = data_clean.get("tipo_escala")
|
| 55 |
|
| 56 |
if escala and not isinstance(escala, TipoEscala):
|
|
|
|
| 63 |
|
| 64 |
tamano_escala = data_clean.get("tamano_escala")
|
| 65 |
|
| 66 |
+
if escala.nombre_escala == "estructurada" and not self.sizes_structure.__contains__(tamano_escala):
|
| 67 |
self.add_error("tamano_escala", "El tamaño de la escala no aplica")
|
| 68 |
+
elif escala.nombre_escala == "continua" and not self.sizes_continue.__contains__(tamano_escala):
|
| 69 |
self.add_error("tamano_escala", "El tamaño de la escala no aplica")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tecnicas/forms/sesion_tags_form.py
CHANGED
|
@@ -1,25 +1,35 @@
|
|
| 1 |
from django import forms
|
| 2 |
-
|
| 3 |
from ..models import Etiqueta
|
| 4 |
|
|
|
|
| 5 |
class SesionTagsForm(forms.Form):
|
| 6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
super().__init__(*args, **kwargs)
|
| 8 |
|
| 9 |
if tipo_escala == "estructurada":
|
|
|
|
| 10 |
for i in range(longitud):
|
| 11 |
-
self.fields[f'segmento_{i+1}'] = forms.ModelChoiceField(queryset=Etiqueta.objects.all(), required=True, label=f"segmento {i+1}", empty_label="Selecione opcion", widget=forms.Select(attrs={
|
| 12 |
-
"class":"ct-select-op p-1 max-sm:w-full bg-surface-ligt [*]:capitalize"
|
| 13 |
}))
|
| 14 |
else:
|
| 15 |
-
self.fields['punto_inicial'] = forms.ModelChoiceField(queryset=Etiqueta.objects.all(), required=True, label="Punto inicial", empty_label="Selecione opcion", widget=forms.Select(attrs={
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
self.fields['punto_medio'] = forms.ModelChoiceField(queryset=Etiqueta.objects.all(), required=True, label="Punto medio", empty_label="Selecione opcion", widget=forms.Select(attrs={
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
self.fields['punto_final'] = forms.ModelChoiceField(queryset=Etiqueta.objects.all(), required=True, label="Punto final", empty_label="Selecione opcion", widget=forms.Select(attrs={
|
| 24 |
-
|
| 25 |
-
|
|
|
|
| 1 |
from django import forms
|
|
|
|
| 2 |
from ..models import Etiqueta
|
| 3 |
|
| 4 |
+
|
| 5 |
class SesionTagsForm(forms.Form):
|
| 6 |
+
available_struture_tags = {
|
| 7 |
+
"5": ["percepcion nula", "percepcion moderada", "se puede percibir",
|
| 8 |
+
"percepcion intensa", "percepcion total"],
|
| 9 |
+
"7": ["percepcion nula", "ligera percepcion", "percepcion moderada", "se puede percibir", "buena percepcion",
|
| 10 |
+
"percepcion intensa", "percepcion total"],
|
| 11 |
+
"9": ["percepcion nula", "ligera percepcion", "poca percepcion", "percepcion moderada", "se puede percibir", "buena percepcion",
|
| 12 |
+
"percepcion intensa", "percepcion muy intensa", "percepcion total"]
|
| 13 |
+
}
|
| 14 |
+
|
| 15 |
+
def __init__(self, *args, longitud=None, tipo_escala: str = None, **kwargs):
|
| 16 |
super().__init__(*args, **kwargs)
|
| 17 |
|
| 18 |
if tipo_escala == "estructurada":
|
| 19 |
+
use_tags = self.available_struture_tags[f"{longitud}"]
|
| 20 |
for i in range(longitud):
|
| 21 |
+
self.fields[f'segmento_{i+1}'] = forms.ModelChoiceField(queryset=Etiqueta.objects.all(), initial=Etiqueta.objects.get(valor_etiqueta=use_tags[i]), required=True, label=f"segmento {i+1}", empty_label="Selecione opcion", widget=forms.Select(attrs={
|
| 22 |
+
"class": "ct-select-op p-1 max-sm:w-full bg-surface-ligt [*]:capitalize"
|
| 23 |
}))
|
| 24 |
else:
|
| 25 |
+
self.fields['punto_inicial'] = forms.ModelChoiceField(queryset=Etiqueta.objects.all(), initial=Etiqueta.objects.get(valor_etiqueta="percepcion nula"), required=True, label="Punto inicial", empty_label="Selecione opcion", widget=forms.Select(attrs={
|
| 26 |
+
"class": "ct-select-op p-1 max-sm:w-full bg-surface-ligt [*]:capitalize"
|
| 27 |
+
}))
|
| 28 |
+
|
| 29 |
+
self.fields['punto_medio'] = forms.ModelChoiceField(queryset=Etiqueta.objects.all(), initial=Etiqueta.objects.get(valor_etiqueta="se puede percibir"), required=True, label="Punto medio", empty_label="Selecione opcion", widget=forms.Select(attrs={
|
| 30 |
+
"class": "ct-select-op p-1 max-sm:w-full bg-surface-ligt [*]:capitalize"
|
| 31 |
+
}))
|
| 32 |
+
|
| 33 |
+
self.fields['punto_final'] = forms.ModelChoiceField(queryset=Etiqueta.objects.all(), initial=Etiqueta.objects.get(valor_etiqueta="percepcion total"), required=True, label="Punto final", empty_label="Selecione opcion", widget=forms.Select(attrs={
|
| 34 |
+
"class": "ct-select-op p-1 max-sm:w-full bg-surface-ligt [*]:capitalize"
|
| 35 |
+
}))
|
tecnicas/static/js/panel-basic.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
const descriptons = {
|
| 2 |
-
estructurada:
|
| 3 |
-
continua:
|
| 4 |
atributos:
|
| 5 |
"Con el estilo atributos elijes las palabras para evaluar los productos",
|
| 6 |
vocabulario:
|
|
@@ -12,6 +12,11 @@ let inputTamano;
|
|
| 12 |
|
| 13 |
let inputsStyle;
|
| 14 |
let helpStyle;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
initPanel();
|
| 17 |
|
|
@@ -22,6 +27,7 @@ function initPanel() {
|
|
| 22 |
function initRadios() {
|
| 23 |
inputsScale = document.getElementsByName("tipo_escala");
|
| 24 |
inputTamano = document.getElementsByName("tamano_escala").item(0);
|
|
|
|
| 25 |
|
| 26 |
for (let index = 0; index < inputsScale.length; index++) {
|
| 27 |
let parent = inputsScale.item(index).parentElement;
|
|
@@ -46,6 +52,73 @@ function initRadios() {
|
|
| 46 |
showDescriptionStyle(parent);
|
| 47 |
}
|
| 48 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
}
|
| 50 |
|
| 51 |
function showDescriptionStyle(label) {
|
|
@@ -56,6 +129,5 @@ function showDescriptionStyle(label) {
|
|
| 56 |
function showDescriptionTamanoScale(label) {
|
| 57 |
const text = label.textContent.trim();
|
| 58 |
let parent = inputTamano.parentElement;
|
| 59 |
-
parent.getElementsByTagName("p")[0].textContent = descriptons[text]
|
| 60 |
-
inputTamano.placeholder = descriptons[text][1];
|
| 61 |
}
|
|
|
|
| 1 |
const descriptons = {
|
| 2 |
+
estructurada: "Establece número de segmentos:",
|
| 3 |
+
continua: "Establece la longitud de la escala:",
|
| 4 |
atributos:
|
| 5 |
"Con el estilo atributos elijes las palabras para evaluar los productos",
|
| 6 |
vocabulario:
|
|
|
|
| 12 |
|
| 13 |
let inputsStyle;
|
| 14 |
let helpStyle;
|
| 15 |
+
let sizeOptionsContainer;
|
| 16 |
+
const SIZE_OPTIONS = {
|
| 17 |
+
estructurada: [5, 7, 9],
|
| 18 |
+
continua: [9, 13, 15],
|
| 19 |
+
};
|
| 20 |
|
| 21 |
initPanel();
|
| 22 |
|
|
|
|
| 27 |
function initRadios() {
|
| 28 |
inputsScale = document.getElementsByName("tipo_escala");
|
| 29 |
inputTamano = document.getElementsByName("tamano_escala").item(0);
|
| 30 |
+
sizeOptionsContainer = document.getElementsByClassName("cts-options-size-scale")[0];
|
| 31 |
|
| 32 |
for (let index = 0; index < inputsScale.length; index++) {
|
| 33 |
let parent = inputsScale.item(index).parentElement;
|
|
|
|
| 52 |
showDescriptionStyle(parent);
|
| 53 |
}
|
| 54 |
}
|
| 55 |
+
|
| 56 |
+
initSizeOptions();
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
function initSizeOptions() {
|
| 60 |
+
for (let i = 0; i < inputsScale.length; i++) {
|
| 61 |
+
const radio = inputsScale.item(i);
|
| 62 |
+
radio.addEventListener('change', () => {
|
| 63 |
+
const tag = getTagFromLabel(radio);
|
| 64 |
+
populateSizeOptions(tag);
|
| 65 |
+
});
|
| 66 |
+
if (radio.checked) {
|
| 67 |
+
const tag = getTagFromLabel(radio);
|
| 68 |
+
populateSizeOptions(tag);
|
| 69 |
+
}
|
| 70 |
+
}
|
| 71 |
+
|
| 72 |
+
const form = document.querySelector('form');
|
| 73 |
+
if (!form) return;
|
| 74 |
+
|
| 75 |
+
form.addEventListener('submit', (e) => {
|
| 76 |
+
const chosen = document.querySelector('input[name="option_size_scale"]:checked');
|
| 77 |
+
if (chosen && inputTamano) {
|
| 78 |
+
inputTamano.value = chosen.value;
|
| 79 |
+
}
|
| 80 |
+
|
| 81 |
+
if (sizeOptionsContainer) {
|
| 82 |
+
const toRemove = sizeOptionsContainer.querySelectorAll('input[name="option_size_scale"]');
|
| 83 |
+
toRemove.forEach((el) => el.remove());
|
| 84 |
+
}
|
| 85 |
+
});
|
| 86 |
+
}
|
| 87 |
+
|
| 88 |
+
function getTagFromLabel(radio) {
|
| 89 |
+
try {
|
| 90 |
+
const parent = radio.parentElement;
|
| 91 |
+
if (!parent) return '';
|
| 92 |
+
const text = parent.textContent || '';
|
| 93 |
+
return text.trim().split(/\s+/)[0].toLowerCase();
|
| 94 |
+
} catch (err) {
|
| 95 |
+
return '';
|
| 96 |
+
}
|
| 97 |
+
}
|
| 98 |
+
|
| 99 |
+
function populateSizeOptions(tag) {
|
| 100 |
+
const options = SIZE_OPTIONS[tag] || SIZE_OPTIONS['estructurada'];
|
| 101 |
+
if (!sizeOptionsContainer) return;
|
| 102 |
+
sizeOptionsContainer.innerHTML = '';
|
| 103 |
+
|
| 104 |
+
options.forEach((val) => {
|
| 105 |
+
const label = document.createElement('label');
|
| 106 |
+
label.className = 'flex flex-col items-center cursor-pointer';
|
| 107 |
+
|
| 108 |
+
const input = document.createElement('input');
|
| 109 |
+
input.type = 'radio';
|
| 110 |
+
input.name = 'option_size_scale';
|
| 111 |
+
input.value = String(val);
|
| 112 |
+
input.className = 'radio radio-lg checked:bg-pink-500';
|
| 113 |
+
|
| 114 |
+
const span = document.createElement('span');
|
| 115 |
+
span.className = 'mt-2 text-xl text-gray-700 font-medium';
|
| 116 |
+
span.textContent = String(val);
|
| 117 |
+
|
| 118 |
+
label.appendChild(input);
|
| 119 |
+
label.appendChild(span);
|
| 120 |
+
sizeOptionsContainer.appendChild(label);
|
| 121 |
+
});
|
| 122 |
}
|
| 123 |
|
| 124 |
function showDescriptionStyle(label) {
|
|
|
|
| 129 |
function showDescriptionTamanoScale(label) {
|
| 130 |
const text = label.textContent.trim();
|
| 131 |
let parent = inputTamano.parentElement;
|
| 132 |
+
parent.getElementsByTagName("p")[0].textContent = descriptons[text];
|
|
|
|
| 133 |
}
|
tecnicas/templates/tecnicas/create_sesion/configuracion-panel-basic.html
CHANGED
|
@@ -13,8 +13,8 @@
|
|
| 13 |
<hr>
|
| 14 |
<form method="post" action="" class="[&>article]:not-last:mb-4 [&>article]:not-first:pt-4 [&>article]:px-6">
|
| 15 |
{% csrf_token %}
|
| 16 |
-
<label for="form_sesion.
|
| 17 |
-
{{ form_sesion.
|
| 18 |
</label>
|
| 19 |
|
| 20 |
<article>
|
|
@@ -93,6 +93,20 @@
|
|
| 93 |
<p>Establece número de segmentos:</p>
|
| 94 |
{{ form_sesion.tamano_escala }}
|
| 95 |
</label>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 96 |
{% if form_sesion.tamano_escala.errors %}
|
| 97 |
<article
|
| 98 |
class="w-fit rounded px-2 py-0.5 text-center text-white text-sm font-medium tracking-wide bg-red-500">
|
|
|
|
| 13 |
<hr>
|
| 14 |
<form method="post" action="" class="[&>article]:not-last:mb-4 [&>article]:not-first:pt-4 [&>article]:px-6">
|
| 15 |
{% csrf_token %}
|
| 16 |
+
<label for="form_sesion.name_tecnica.id_for_label" class="hidden">
|
| 17 |
+
{{ form_sesion.name_tecnica }}
|
| 18 |
</label>
|
| 19 |
|
| 20 |
<article>
|
|
|
|
| 93 |
<p>Establece número de segmentos:</p>
|
| 94 |
{{ form_sesion.tamano_escala }}
|
| 95 |
</label>
|
| 96 |
+
<div class="flex justify-around max-sm:flex-col gap-8 cts-options-size-scale">
|
| 97 |
+
<label class="flex flex-col items-center cursor-pointer">
|
| 98 |
+
<input type="radio" name="option_size_scale" value="5" class="radio radio-lg checked:bg-pink-500" />
|
| 99 |
+
<span class="mt-2 text-xl text-gray-700 font-medium">5</span>
|
| 100 |
+
</label>
|
| 101 |
+
<label class="flex flex-col items-center cursor-pointer">
|
| 102 |
+
<input type="radio" name="option_size_scale" value="7" class="radio radio-lg checked:bg-pink-500" />
|
| 103 |
+
<span class="mt-2 text-xl text-gray-700 font-medium">7</span>
|
| 104 |
+
</label>
|
| 105 |
+
<label class="flex flex-col items-center cursor-pointer">
|
| 106 |
+
<input type="radio" name="option_size_scale" value="9" class="radio radio-lg checked:bg-pink-500" />
|
| 107 |
+
<span class="mt-2 text-xl text-gray-700 font-medium">9</span>
|
| 108 |
+
</label>
|
| 109 |
+
</div>
|
| 110 |
{% if form_sesion.tamano_escala.errors %}
|
| 111 |
<article
|
| 112 |
class="w-fit rounded px-2 py-0.5 text-center text-white text-sm font-medium tracking-wide bg-red-500">
|
tecnicas/templates/tecnicas/create_sesion/configuracion-panel-tags.html
CHANGED
|
@@ -19,7 +19,8 @@
|
|
| 19 |
<article class="p-4 flex flex-col gap-2 rounded max-sm:text-center">
|
| 20 |
<h2 class="text-2xl mb-2 font-bold">Seleccion de etiquetas</h2>
|
| 21 |
{% for field in form_tags %}
|
| 22 |
-
<div
|
|
|
|
| 23 |
<label for="{{ field.id_for_label }}"
|
| 24 |
class="font-medium p-1 px-3 max-sm:w-full capitalize rounded">
|
| 25 |
{{ field.label }}
|
|
@@ -44,11 +45,10 @@
|
|
| 44 |
<button type="submit" class="cts-btn-general cts-btn-primary btn-push flex-1 w-full">
|
| 45 |
Continuar
|
| 46 |
</button>
|
| 47 |
-
<
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
</a>
|
| 52 |
</section>
|
| 53 |
<a href="{% url 'cata_system:seleccion_tecnica' %}" class="flex-1 w-full">
|
| 54 |
<button type="button" class="cts-btn-general cts-btn-error btn-push w-full">
|
|
@@ -71,7 +71,8 @@
|
|
| 71 |
<p
|
| 72 |
class="ct-error-tag mt-4 font-bold bg-red-500 text-white text-md capitalize text-center rounded hidden">
|
| 73 |
error</p>
|
| 74 |
-
<article
|
|
|
|
| 75 |
<button type="submit" class="cts-btn-general cts-btn-primary btn-push">
|
| 76 |
Agregar
|
| 77 |
</button>
|
|
@@ -89,20 +90,7 @@
|
|
| 89 |
|
| 90 |
{% block extra_js %}
|
| 91 |
<script src="{% static 'js/panel-tags.js' %}"></script>
|
|
|
|
| 92 |
|
| 93 |
-
{%
|
| 94 |
-
|
| 95 |
-
for (let i = 0; i < options.length; i++) {
|
| 96 |
-
if (options.item(i).value) {
|
| 97 |
-
values.push(options.item(i).value)
|
| 98 |
-
}
|
| 99 |
-
}
|
| 100 |
-
|
| 101 |
-
values.sort()
|
| 102 |
-
|
| 103 |
-
for (let i = 0; i < values.length; i++) {
|
| 104 |
-
itemsSelects.item(i).value = values[i]
|
| 105 |
-
}
|
| 106 |
-
</script>
|
| 107 |
-
{% endif %}
|
| 108 |
-
{% endblock %}
|
|
|
|
| 19 |
<article class="p-4 flex flex-col gap-2 rounded max-sm:text-center">
|
| 20 |
<h2 class="text-2xl mb-2 font-bold">Seleccion de etiquetas</h2>
|
| 21 |
{% for field in form_tags %}
|
| 22 |
+
<div
|
| 23 |
+
class="flex max-sm:flex-col justify-center items-center gap-5 max-sm:gap-2 text-lg border-b-4 border-l-4 border-btn-secondary bg-surface-card p-1">
|
| 24 |
<label for="{{ field.id_for_label }}"
|
| 25 |
class="font-medium p-1 px-3 max-sm:w-full capitalize rounded">
|
| 26 |
{{ field.label }}
|
|
|
|
| 45 |
<button type="submit" class="cts-btn-general cts-btn-primary btn-push flex-1 w-full">
|
| 46 |
Continuar
|
| 47 |
</button>
|
| 48 |
+
<button type="button" class="cts-btn-general cts-btn-secondary btn-push w-full"
|
| 49 |
+
onclick="window.history.back();">
|
| 50 |
+
Paso anterior
|
| 51 |
+
</button>
|
|
|
|
| 52 |
</section>
|
| 53 |
<a href="{% url 'cata_system:seleccion_tecnica' %}" class="flex-1 w-full">
|
| 54 |
<button type="button" class="cts-btn-general cts-btn-error btn-push w-full">
|
|
|
|
| 71 |
<p
|
| 72 |
class="ct-error-tag mt-4 font-bold bg-red-500 text-white text-md capitalize text-center rounded hidden">
|
| 73 |
error</p>
|
| 74 |
+
<article
|
| 75 |
+
class="flex max-sm:flex-col justify-center gap-8 max-sm:gap-4 mt-4 text-white font-medium tracking-wide">
|
| 76 |
<button type="submit" class="cts-btn-general cts-btn-primary btn-push">
|
| 77 |
Agregar
|
| 78 |
</button>
|
|
|
|
| 90 |
|
| 91 |
{% block extra_js %}
|
| 92 |
<script src="{% static 'js/panel-tags.js' %}"></script>
|
| 93 |
+
{% endblock %}
|
| 94 |
|
| 95 |
+
<a href="{% url 'cata_system:seleccion_tecnica' %}" class="flex-1 w-full">
|
| 96 |
+
</a>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tecnicas/templates/tecnicas/create_sesion/seleccion-tecnica.html
CHANGED
|
@@ -33,7 +33,7 @@
|
|
| 33 |
<section
|
| 34 |
class="modal-list-{{ cate }} flex flex-col text-lg bg-surface-ligt p-4 pr-6 pl-8 sm:pl-12 z-10 -translate-y-1 rounded-b-2xl *:not-last:mb-4 transition-all duration-1000 hidden w-full">
|
| 35 |
{% for tecnica in tecnicas %}
|
| 36 |
-
<a href="{% url 'cata_system:panel_configuracion_basic'%}?
|
| 37 |
<button
|
| 38 |
class="cts-btn-secondary btn-push rounded-lg border-b-0 border-l-4 border-gray-700 px-3 py-2 w-full text-left font-bold uppercase">
|
| 39 |
{{ tecnica.nombre_tecnica }}
|
|
|
|
| 33 |
<section
|
| 34 |
class="modal-list-{{ cate }} flex flex-col text-lg bg-surface-ligt p-4 pr-6 pl-8 sm:pl-12 z-10 -translate-y-1 rounded-b-2xl *:not-last:mb-4 transition-all duration-1000 hidden w-full">
|
| 35 |
{% for tecnica in tecnicas %}
|
| 36 |
+
<a href="{% url 'cata_system:panel_configuracion_basic'%}?name_tecnica={{ tecnica }}">
|
| 37 |
<button
|
| 38 |
class="cts-btn-secondary btn-push rounded-lg border-b-0 border-l-4 border-gray-700 px-3 py-2 w-full text-left font-bold uppercase">
|
| 39 |
{{ tecnica.nombre_tecnica }}
|
tecnicas/utils/__init__.py
CHANGED
|
@@ -3,4 +3,5 @@ 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
|
|
|
|
|
|
| 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
|
tecnicas/utils/delete_data_session.py
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from django.http import HttpRequest
|
| 2 |
+
from tecnicas.constants import FORMS_TO_CREATE_SESSION
|
| 3 |
+
from .personal_errors import general_error
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
def deleteDataSession(request: HttpRequest):
|
| 7 |
+
for key in FORMS_TO_CREATE_SESSION:
|
| 8 |
+
if key in request.session:
|
| 9 |
+
del request.session[key]
|
| 10 |
+
return True
|
tecnicas/views/sessions_config/configuration_panel_basic.py
CHANGED
|
@@ -1,52 +1,33 @@
|
|
| 1 |
-
from django.shortcuts import
|
| 2 |
-
from django.http import HttpRequest
|
| 3 |
from django.urls import reverse
|
| 4 |
-
from
|
| 5 |
-
from
|
| 6 |
|
| 7 |
|
| 8 |
def configurationPanelBasic(req: HttpRequest):
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
"
|
| 13 |
-
"form_words"
|
| 14 |
-
]
|
| 15 |
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
try:
|
| 22 |
-
form = SesionBasicForm(req.POST)
|
| 23 |
-
|
| 24 |
-
if form.is_valid():
|
| 25 |
-
values = {}
|
| 26 |
-
|
| 27 |
-
for name, value in form.cleaned_data.items():
|
| 28 |
-
if name == "estilo_palabras" or name == "tipo_escala":
|
| 29 |
-
values[name] = value.id
|
| 30 |
-
else:
|
| 31 |
-
values[name] = value
|
| 32 |
-
|
| 33 |
-
req.session['form_basic'] = values
|
| 34 |
-
return redirect(reverse("cata_system:panel_configuracion_tags"))
|
| 35 |
-
except KeyError:
|
| 36 |
-
return redirect(reverse("cata_system:seleccion_tecnica") + "?error=error en datos de configuracion")
|
| 37 |
|
| 38 |
-
return
|
| 39 |
-
elif req.method == "
|
| 40 |
-
|
| 41 |
-
id_tecnica = req.GET["id_tecnica"]
|
| 42 |
-
tecnica = TipoTecnica.objects.get(pk=id_tecnica)
|
| 43 |
-
except KeyError:
|
| 44 |
-
return redirect(reverse("cata_system:seleccion_tecnica") + "?error=tecnica_no_establecida")
|
| 45 |
-
except (ValueError, TipoTecnica.DoesNotExist):
|
| 46 |
-
return redirect(reverse("cata_system:seleccion_tecnica") + "?error=tecnica_no_establecida")
|
| 47 |
|
| 48 |
-
if
|
| 49 |
-
|
| 50 |
-
|
| 51 |
else:
|
| 52 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from django.shortcuts import redirect
|
| 2 |
+
from django.http import HttpRequest, JsonResponse
|
| 3 |
from django.urls import reverse
|
| 4 |
+
from tecnicas.controllers import PanelBasicController
|
| 5 |
+
from tecnicas.utils import deleteDataSession
|
| 6 |
|
| 7 |
|
| 8 |
def configurationPanelBasic(req: HttpRequest):
|
| 9 |
+
deleteDataSession(req)
|
| 10 |
+
|
| 11 |
+
if req.method == "GET":
|
| 12 |
+
name_tecnica = req.GET["name_tecnica"]
|
|
|
|
|
|
|
| 13 |
|
| 14 |
+
if name_tecnica == "escalas":
|
| 15 |
+
response = PanelBasicController.controllGetEscalas(request=req)
|
| 16 |
+
else:
|
| 17 |
+
response = redirect(
|
| 18 |
+
reverse("cata_system:seleccion_tecnica") + "?error=Técnica no valida o sin implementar")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
|
| 20 |
+
return response
|
| 21 |
+
elif req.method == "POST":
|
| 22 |
+
name_tecnica = req.GET["name_tecnica"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
|
| 24 |
+
if name_tecnica == "escalas":
|
| 25 |
+
response = PanelBasicController.controllPostEscalas(
|
| 26 |
+
request=req, name_tecnica=name_tecnica)
|
| 27 |
else:
|
| 28 |
+
response = redirect(
|
| 29 |
+
reverse("cata_system:seleccion_tecnica") + "?error=¡Oh, vaya! Cambio de técnica repentino, vuelve a elegir otra vez")
|
| 30 |
+
|
| 31 |
+
return response
|
| 32 |
+
else:
|
| 33 |
+
return JsonResponse({"message": "Método no permitido"})
|
tecnicas/views/sessions_config/configuration_panel_codes.py
CHANGED
|
@@ -1,59 +1,35 @@
|
|
| 1 |
-
from django.http import HttpRequest
|
| 2 |
-
from django.shortcuts import
|
| 3 |
from django.urls import reverse
|
| 4 |
-
from
|
| 5 |
-
from
|
| 6 |
-
import json
|
| 7 |
|
| 8 |
|
| 9 |
def configurationPanelCodes(req: HttpRequest):
|
| 10 |
-
if not req.session
|
| 11 |
-
req
|
| 12 |
return redirect(reverse("cata_system:seleccion_tecnica") +
|
| 13 |
"?error=datos del formulario requerido no encontrados")
|
| 14 |
-
|
| 15 |
data_basic = req.session["form_basic"]
|
| 16 |
|
| 17 |
-
num_products = data_basic["numero_productos"]
|
| 18 |
-
num_tester = data_basic["numero_catadores"]
|
| 19 |
-
|
| 20 |
if req.method == "GET":
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
return render(req, "tecnicas/create_sesion/configuracion-panel-codes.html", context_codes_form)
|
| 31 |
elif req.method == "POST":
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
for name, value in req.POST.items():
|
| 37 |
-
if name.__contains__("producto_"):
|
| 38 |
-
codes.append(value)
|
| 39 |
-
|
| 40 |
-
form_codes = CodesForm(req.POST, codes=codes)
|
| 41 |
-
|
| 42 |
-
context_codes_form = {
|
| 43 |
-
"form_codes": form_codes,
|
| 44 |
-
"num_tester": num_tester,
|
| 45 |
-
}
|
| 46 |
-
|
| 47 |
-
if form_codes.is_valid():
|
| 48 |
-
codes_sort = {"product_codes": []}
|
| 49 |
-
|
| 50 |
-
for name, value in form_codes.cleaned_data.items():
|
| 51 |
-
codes_sort["product_codes"].append({name: value})
|
| 52 |
-
|
| 53 |
-
codes_sort["sort_codes"] = sorts_code
|
| 54 |
-
req.session["form_codes"] = codes_sort
|
| 55 |
-
return redirect(reverse("cata_system:panel_configuracion_words"))
|
| 56 |
else:
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from django.http import HttpRequest, JsonResponse
|
| 2 |
+
from django.shortcuts import redirect
|
| 3 |
from django.urls import reverse
|
| 4 |
+
from tecnicas.controllers import PanelCodesController
|
| 5 |
+
from tecnicas.utils import deleteDataSession
|
|
|
|
| 6 |
|
| 7 |
|
| 8 |
def configurationPanelCodes(req: HttpRequest):
|
| 9 |
+
if not req.session["form_basic"]:
|
| 10 |
+
deleteDataSession(req)
|
| 11 |
return redirect(reverse("cata_system:seleccion_tecnica") +
|
| 12 |
"?error=datos del formulario requerido no encontrados")
|
| 13 |
+
|
| 14 |
data_basic = req.session["form_basic"]
|
| 15 |
|
|
|
|
|
|
|
|
|
|
| 16 |
if req.method == "GET":
|
| 17 |
+
if data_basic["name_tecnica"] == "escalas":
|
| 18 |
+
response = PanelCodesController.controllGetEscalas(
|
| 19 |
+
req, data_basic)
|
| 20 |
+
else:
|
| 21 |
+
response = redirect(
|
| 22 |
+
reverse("cata_system:seleccion_tecnica") + "?error=Técnica no valida")
|
| 23 |
+
|
| 24 |
+
return response
|
|
|
|
|
|
|
| 25 |
elif req.method == "POST":
|
| 26 |
+
if data_basic["name_tecnica"] == "escalas":
|
| 27 |
+
response = PanelCodesController.controllPostEscalas(
|
| 28 |
+
req, data_basic)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
else:
|
| 30 |
+
response = redirect(
|
| 31 |
+
reverse("cata_system:seleccion_tecnica") + "?error=Técnica no valida")
|
| 32 |
+
|
| 33 |
+
return response
|
| 34 |
+
else:
|
| 35 |
+
return JsonResponse({"message": "Método no permitido"})
|
tecnicas/views/sessions_config/configuration_panel_tags.py
CHANGED
|
@@ -1,46 +1,34 @@
|
|
| 1 |
-
from django.http import HttpRequest
|
| 2 |
-
from django.shortcuts import redirect
|
| 3 |
from django.urls import reverse
|
| 4 |
-
from
|
| 5 |
-
from
|
| 6 |
|
| 7 |
|
| 8 |
def configurationPanelTags(req: HttpRequest):
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
tamano_escala = basic_data["tamano_escala"]
|
| 16 |
-
form_new_etiqueta = EtiquetaForm()
|
| 17 |
|
| 18 |
if req.method == "GET":
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
}
|
| 26 |
|
| 27 |
-
return
|
| 28 |
elif req.method == "POST":
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
context_tags = {
|
| 34 |
-
"form_tags": form,
|
| 35 |
-
"form_new_tag": form_new_etiqueta
|
| 36 |
-
}
|
| 37 |
-
|
| 38 |
-
if form.is_valid():
|
| 39 |
-
for name, value in form.cleaned_data.items():
|
| 40 |
-
values[name] = value.id
|
| 41 |
-
|
| 42 |
-
req.session["form_tags"] = values
|
| 43 |
-
return redirect(reverse("cata_system:panel_configuracion_codes"))
|
| 44 |
else:
|
| 45 |
-
|
| 46 |
-
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from django.http import HttpRequest, JsonResponse
|
| 2 |
+
from django.shortcuts import redirect
|
| 3 |
from django.urls import reverse
|
| 4 |
+
from tecnicas.controllers import PanelTagsController
|
| 5 |
+
from tecnicas.utils import deleteDataSession
|
| 6 |
|
| 7 |
|
| 8 |
def configurationPanelTags(req: HttpRequest):
|
| 9 |
+
if not req.session.get("form_basic"):
|
| 10 |
+
deleteDataSession(req)
|
| 11 |
+
return redirect(reverse('cata_system:panel_configuracion_basic') +
|
| 12 |
+
"?error=datos requeridos no encontrados")
|
| 13 |
+
|
| 14 |
+
basic_data = req.session.get("form_basic")
|
|
|
|
|
|
|
| 15 |
|
| 16 |
if req.method == "GET":
|
| 17 |
+
if basic_data["name_tecnica"] == "escalas":
|
| 18 |
+
response = PanelTagsController.controllGetEscalas(
|
| 19 |
+
request=req, data=basic_data)
|
| 20 |
+
else:
|
| 21 |
+
response = redirect(
|
| 22 |
+
reverse("cata_system:seleccion_tecnica") + "?error=Técnica no valida")
|
|
|
|
| 23 |
|
| 24 |
+
return response
|
| 25 |
elif req.method == "POST":
|
| 26 |
+
if basic_data["name_tecnica"] == "escalas":
|
| 27 |
+
response = PanelTagsController.controllPostEscalas(
|
| 28 |
+
request=req, data=basic_data)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
else:
|
| 30 |
+
response = redirect(
|
| 31 |
+
reverse("cata_system:seleccion_tecnica") + "?error=Técnica no valida")
|
| 32 |
+
return response
|
| 33 |
+
else:
|
| 34 |
+
return JsonResponse({"message": "Método no permitido"})
|
tecnicas/views/sessions_config/configuration_panel_words.py
CHANGED
|
@@ -1,44 +1,33 @@
|
|
| 1 |
-
from django.http import HttpRequest
|
| 2 |
-
from django.shortcuts import
|
| 3 |
from django.urls import reverse
|
| 4 |
-
from
|
| 5 |
-
from
|
| 6 |
-
|
| 7 |
-
import json
|
| 8 |
|
| 9 |
|
| 10 |
def configurationPanelWords(req: HttpRequest):
|
| 11 |
-
if not req.session.get("form_basic")
|
| 12 |
-
req
|
| 13 |
return redirect(reverse("cata_system:seleccion_tecnica") +
|
| 14 |
-
"?error=datos
|
| 15 |
|
| 16 |
-
|
| 17 |
-
context = {
|
| 18 |
-
"form_word": form
|
| 19 |
-
}
|
| 20 |
|
| 21 |
if req.method == "GET":
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
words = json.loads(req.POST.get("words"))
|
| 28 |
-
context["words"] = words
|
| 29 |
-
|
| 30 |
-
ids_words = [word["id"] for word in words]
|
| 31 |
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
req.session["form_words"] = ids_words
|
| 44 |
-
return redirect(reverse("cata_system:creando_sesion"))
|
|
|
|
| 1 |
+
from django.http import HttpRequest, JsonResponse
|
| 2 |
+
from django.shortcuts import redirect
|
| 3 |
from django.urls import reverse
|
| 4 |
+
from tecnicas.controllers import PanelWordsController
|
| 5 |
+
from tecnicas.utils import deleteDataSession
|
|
|
|
|
|
|
| 6 |
|
| 7 |
|
| 8 |
def configurationPanelWords(req: HttpRequest):
|
| 9 |
+
if not req.session.get("form_basic"):
|
| 10 |
+
deleteDataSession(req)
|
| 11 |
return redirect(reverse("cata_system:seleccion_tecnica") +
|
| 12 |
+
"?error=datos requeridos no encontrados")
|
| 13 |
|
| 14 |
+
basic_data = req.session["form_basic"]
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
if req.method == "GET":
|
| 17 |
+
if basic_data["name_tecnica"] == "escalas":
|
| 18 |
+
response = PanelWordsController.controllGetEscalas(req)
|
| 19 |
+
else:
|
| 20 |
+
response = redirect(
|
| 21 |
+
reverse("cata_system:seleccion_tecnica") + "?error=Técnica no valida")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
|
| 23 |
+
return response
|
| 24 |
+
elif req.method == "POST":
|
| 25 |
+
if basic_data["name_tecnica"] == "escalas":
|
| 26 |
+
response = PanelWordsController.controllPostEscalas(req)
|
| 27 |
+
else:
|
| 28 |
+
response = redirect(
|
| 29 |
+
reverse("cata_system:seleccion_tecnica") + "?error=Técnica no valida")
|
| 30 |
+
|
| 31 |
+
return response
|
| 32 |
+
else:
|
| 33 |
+
return JsonResponse({"message": "Método no permitido"})
|
|
|
|
|
|
tecnicas/views/sessions_config/create_session.py
CHANGED
|
@@ -1,170 +1,34 @@
|
|
| 1 |
from django.http import HttpRequest, JsonResponse
|
| 2 |
-
from django.shortcuts import render
|
| 3 |
-
from
|
| 4 |
-
from
|
| 5 |
-
from
|
| 6 |
-
from django.db import transaction
|
| 7 |
|
| 8 |
|
| 9 |
def createSession(req: HttpRequest):
|
| 10 |
-
if req.
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
if not req.session.get("form_basic") or not req.session.get("form_tags") or not req.session.get("form_codes") or not req.session.get("form_words"):
|
| 15 |
-
req.session.flush()
|
| 16 |
-
return general_error("no se ha especificado informacion necesaria para la creacion de la sesion")
|
| 17 |
-
|
| 18 |
-
with transaction.atomic():
|
| 19 |
-
# ////////////////////////////////////////////////////// #
|
| 20 |
-
#
|
| 21 |
-
# First step: Create technique and scale with their tags #
|
| 22 |
-
#
|
| 23 |
-
# ////////////////////////////////////////////////////// #
|
| 24 |
-
data_basic = req.session["form_basic"]
|
| 25 |
-
controllerTechnique = TecnicaController()
|
| 26 |
-
controllerTechnique.setTechniqueFromBasicData(basic=data_basic)
|
| 27 |
-
|
| 28 |
-
technique = controllerTechnique.saveTechnique()
|
| 29 |
-
if not technique:
|
| 30 |
-
return general_error("error al guardar la tecnica")
|
| 31 |
-
|
| 32 |
-
data_scale = {
|
| 33 |
-
"id_scale": data_basic["tipo_escala"],
|
| 34 |
-
"size": data_basic["tamano_escala"],
|
| 35 |
-
"technique": technique
|
| 36 |
-
}
|
| 37 |
-
|
| 38 |
-
controllerScale = EscalaController(data=data_scale)
|
| 39 |
-
|
| 40 |
-
scale = controllerScale.saveScale()
|
| 41 |
-
if isinstance(scale, dict):
|
| 42 |
-
controllerTechnique.deleteTechnique()
|
| 43 |
-
return general_error(scale["error"])
|
| 44 |
-
|
| 45 |
-
dict_tags = req.session["form_tags"]
|
| 46 |
-
saved_related_tags = controllerScale.realteTags(dict_tags)
|
| 47 |
-
if "error" in saved_related_tags:
|
| 48 |
-
return general_error(saved_related_tags["error"])
|
| 49 |
-
|
| 50 |
-
# ////////////////////////////////////////////////////////// #
|
| 51 |
-
#
|
| 52 |
-
# Second step: Create orders, productos and set the position #
|
| 53 |
-
#
|
| 54 |
-
# ////////////////////////////////////////////////////////// #
|
| 55 |
-
data_codes = req.session["form_codes"]
|
| 56 |
-
|
| 57 |
-
list_codes_dict = data_codes["product_codes"]
|
| 58 |
-
|
| 59 |
-
codes = []
|
| 60 |
-
for product in list_codes_dict:
|
| 61 |
-
code = next(iter(product.values()))
|
| 62 |
-
codes.append(code)
|
| 63 |
-
|
| 64 |
-
controllerProducts = ProductosController(
|
| 65 |
-
codes=codes,
|
| 66 |
-
technique=technique
|
| 67 |
-
)
|
| 68 |
-
|
| 69 |
-
controllerProducts.setProductsNoSave()
|
| 70 |
-
saved_prodcuts = controllerProducts.saveProducts()
|
| 71 |
-
if isinstance(saved_prodcuts, dict):
|
| 72 |
-
controllerTechnique.deleteTechnique()
|
| 73 |
-
return general_error(saved_prodcuts["error"])
|
| 74 |
-
|
| 75 |
-
raw_sort_codes = data_codes["sort_codes"]
|
| 76 |
-
controllerOrdes = OrdenesController(
|
| 77 |
-
raw_orders=raw_sort_codes,
|
| 78 |
-
list_products=saved_prodcuts,
|
| 79 |
-
technique=technique
|
| 80 |
-
)
|
| 81 |
-
|
| 82 |
-
controllerOrdes.setOrdersToSave()
|
| 83 |
-
saved_orders = controllerOrdes.saveOrders()
|
| 84 |
-
if isinstance(saved_orders, dict):
|
| 85 |
-
controllerTechnique.deleteTechnique()
|
| 86 |
-
return general_error(saved_orders["error"])
|
| 87 |
|
| 88 |
-
|
| 89 |
-
if isinstance(seded_positions, dict):
|
| 90 |
-
controllerTechnique.deleteTechnique()
|
| 91 |
-
return general_error(seded_positions["error"])
|
| 92 |
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
technique=technique, words=words_to_use)
|
| 113 |
-
|
| 114 |
-
instace_style = style_controller.createAndSaveInstaceStyle()
|
| 115 |
-
if isinstance(instace_style, dict):
|
| 116 |
-
controllerTechnique.deleteTechnique()
|
| 117 |
-
return general_error(instace_style["error"])
|
| 118 |
-
|
| 119 |
-
words_using = style_controller.relatedWords()
|
| 120 |
-
if isinstance(words_using, dict):
|
| 121 |
-
controllerTechnique.deleteTechnique()
|
| 122 |
-
return general_error(words_using["error"])
|
| 123 |
-
|
| 124 |
-
# //////////////////////////////////////////////////////// #
|
| 125 |
-
#
|
| 126 |
-
# Fourth step: Create session and relat with the technique #
|
| 127 |
-
#
|
| 128 |
-
# //////////////////////////////////////////////////////// #
|
| 129 |
-
session_controller = SesionController(
|
| 130 |
-
name_session=data_basic["nombre_sesion"] if data_basic["nombre_sesion"] != "" else None,
|
| 131 |
-
technique=technique,
|
| 132 |
-
creator=req.user.user_presentador
|
| 133 |
-
)
|
| 134 |
-
|
| 135 |
-
setting_session = session_controller.setSession()
|
| 136 |
-
if isinstance(setting_session, dict):
|
| 137 |
-
controllerTechnique.deleteTechnique()
|
| 138 |
-
return general_error(setting_session["error"])
|
| 139 |
-
|
| 140 |
-
saved_session = session_controller.saveSession()
|
| 141 |
-
if isinstance(saved_session, dict):
|
| 142 |
-
return general_error(saved_session["error"])
|
| 143 |
-
|
| 144 |
-
context = {
|
| 145 |
-
"message": "sesion creada",
|
| 146 |
-
"data": {
|
| 147 |
-
"codigo_sesion": saved_session.codigo_sesion,
|
| 148 |
-
"nombre_sesion": saved_session.nombre_sesion
|
| 149 |
-
}
|
| 150 |
-
}
|
| 151 |
-
|
| 152 |
-
# /////////////////////////////// #
|
| 153 |
-
#
|
| 154 |
-
# Final step: Delete session keys #
|
| 155 |
-
#
|
| 156 |
-
# /////////////////////////////// #
|
| 157 |
-
|
| 158 |
-
keys_forms = [
|
| 159 |
-
"form_basic",
|
| 160 |
-
"form_tags",
|
| 161 |
-
"form_codes",
|
| 162 |
-
"form_words"
|
| 163 |
-
]
|
| 164 |
-
|
| 165 |
-
for key in keys_forms:
|
| 166 |
-
if key in req.session:
|
| 167 |
-
del req.session[key]
|
| 168 |
-
|
| 169 |
-
return JsonResponse(context)
|
| 170 |
-
return general_error("ha orcurrido un error inesperado")
|
|
|
|
| 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 PanelCreateController
|
| 5 |
+
from tecnicas.utils import deleteDataSession
|
|
|
|
| 6 |
|
| 7 |
|
| 8 |
def createSession(req: HttpRequest):
|
| 9 |
+
if not req.session.get("form_basic"):
|
| 10 |
+
deleteDataSession(req)
|
| 11 |
+
return redirect(reverse("cata_system:seleccion_tecnica") +
|
| 12 |
+
"?error=datos requeridos no encontrados")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
+
basic_data = req.session["form_basic"]
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
+
if req.method == "GET":
|
| 17 |
+
if basic_data["name_tecnica"] == "escalas":
|
| 18 |
+
response = render(
|
| 19 |
+
req, 'tecnicas/create_sesion/creando_sesion.html')
|
| 20 |
+
else:
|
| 21 |
+
response = redirect(
|
| 22 |
+
reverse("cata_system:seleccion_tecnica") + "?error=Técnica no valida")
|
| 23 |
+
|
| 24 |
+
return response
|
| 25 |
+
if req.method == "POST":
|
| 26 |
+
if basic_data["name_tecnica"] == "escalas":
|
| 27 |
+
response = PanelCreateController.controllPostEscalas(req)
|
| 28 |
+
else:
|
| 29 |
+
response = redirect(
|
| 30 |
+
reverse("cata_system:seleccion_tecnica") + "?error=Técnica no valida")
|
| 31 |
+
|
| 32 |
+
return response
|
| 33 |
+
else:
|
| 34 |
+
return JsonResponse({"message": "Método no permitido"})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tecnicas/views/sessions_config/seleccion_tecnica.py
CHANGED
|
@@ -1,7 +1,6 @@
|
|
| 1 |
from django.shortcuts import render
|
| 2 |
from django.http import HttpRequest
|
| 3 |
-
|
| 4 |
-
from ...controllers import TecnicaController
|
| 5 |
|
| 6 |
def selecionTecnica(req:HttpRequest):
|
| 7 |
tipos = TecnicaController.getTypesTechnique()
|
|
|
|
| 1 |
from django.shortcuts import render
|
| 2 |
from django.http import HttpRequest
|
| 3 |
+
from tecnicas.controllers import TecnicaController
|
|
|
|
| 4 |
|
| 5 |
def selecionTecnica(req:HttpRequest):
|
| 6 |
tipos = TecnicaController.getTypesTechnique()
|