Spaces:
Sleeping
Sleeping
Se establce configracion de codigos y palabras para CATA
Browse files- tecnicas/controllers/views_controller/create_session/panel_basic_controller.py +2 -2
- tecnicas/controllers/views_controller/create_session/panel_codes_controller.py +24 -22
- tecnicas/controllers/views_controller/create_session/panel_create_controller.py +171 -35
- tecnicas/templates/tecnicas/create_sesion/configuracion-panel-codes.html +7 -3
- tecnicas/views/sessions_config/configuration_panel_basic.py +3 -0
- tecnicas/views/sessions_config/configuration_panel_codes.py +11 -4
- tecnicas/views/sessions_config/configuration_panel_words.py +20 -11
- tecnicas/views/sessions_config/create_session.py +2 -0
tecnicas/controllers/views_controller/create_session/panel_basic_controller.py
CHANGED
|
@@ -14,7 +14,7 @@ class PanelBasicController():
|
|
| 14 |
url_panel_basic_cata = "tecnicas/create_sesion/panel-basic-cata.html"
|
| 15 |
|
| 16 |
url_next_panel_scales = "cata_system:panel_configuracion_tags"
|
| 17 |
-
url_next_panel_cata = "cata_system:
|
| 18 |
|
| 19 |
url_select_technique = "cata_system:seleccion_tecnica"
|
| 20 |
|
|
@@ -125,7 +125,7 @@ class PanelBasicController():
|
|
| 125 |
request, PanelBasicController.url_panel_basic_cata, view_context)
|
| 126 |
|
| 127 |
@staticmethod
|
| 128 |
-
def
|
| 129 |
form = SesionBasicCATAForm(request.POST)
|
| 130 |
|
| 131 |
if form.is_valid():
|
|
|
|
| 14 |
url_panel_basic_cata = "tecnicas/create_sesion/panel-basic-cata.html"
|
| 15 |
|
| 16 |
url_next_panel_scales = "cata_system:panel_configuracion_tags"
|
| 17 |
+
url_next_panel_cata = "cata_system:panel_configuracion_codes"
|
| 18 |
|
| 19 |
url_select_technique = "cata_system:seleccion_tecnica"
|
| 20 |
|
|
|
|
| 125 |
request, PanelBasicController.url_panel_basic_cata, view_context)
|
| 126 |
|
| 127 |
@staticmethod
|
| 128 |
+
def controllPostCATA(request: HttpRequest, name_tecnica: str):
|
| 129 |
form = SesionBasicCATAForm(request.POST)
|
| 130 |
|
| 131 |
if form.is_valid():
|
tecnicas/controllers/views_controller/create_session/panel_codes_controller.py
CHANGED
|
@@ -7,15 +7,16 @@ import json
|
|
| 7 |
|
| 8 |
|
| 9 |
class PanelCodesController():
|
|
|
|
|
|
|
|
|
|
| 10 |
def __init__(self):
|
| 11 |
pass
|
| 12 |
|
| 13 |
@staticmethod
|
| 14 |
def controllGetEscalas(request: HttpRequest, data):
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
num_tester
|
| 18 |
-
) = PanelCodesController.defineInfoConvencional(data)
|
| 19 |
|
| 20 |
codes_products = generarCodigos(num_products)
|
| 21 |
|
|
@@ -27,14 +28,11 @@ class PanelCodesController():
|
|
| 27 |
"use_technique": "escalas"
|
| 28 |
}
|
| 29 |
|
| 30 |
-
return render(request,
|
| 31 |
|
| 32 |
@staticmethod
|
| 33 |
def controllPostEscalas(request: HttpRequest, data):
|
| 34 |
-
|
| 35 |
-
num_products,
|
| 36 |
-
num_tester
|
| 37 |
-
) = PanelCodesController.defineInfoConvencional(data)
|
| 38 |
|
| 39 |
sorts_code = json.loads(request.POST.get("sort_codes"))
|
| 40 |
codes = []
|
|
@@ -60,11 +58,11 @@ class PanelCodesController():
|
|
| 60 |
|
| 61 |
codes_sort["sort_codes"] = sorts_code
|
| 62 |
request.session["form_codes"] = codes_sort
|
| 63 |
-
return redirect(reverse(
|
| 64 |
else:
|
| 65 |
context_codes_form["error"] = "error en los datos recibidos"
|
| 66 |
|
| 67 |
-
return render(request,
|
| 68 |
|
| 69 |
@staticmethod
|
| 70 |
def controllGetRATA(request: HttpRequest, data):
|
|
@@ -78,10 +76,10 @@ class PanelCodesController():
|
|
| 78 |
"use_technique": "rata"
|
| 79 |
}
|
| 80 |
|
| 81 |
-
return render(request,
|
| 82 |
|
| 83 |
@staticmethod
|
| 84 |
-
def controllPostRATA(request: HttpRequest):
|
| 85 |
codes = []
|
| 86 |
context_codes_form = {}
|
| 87 |
|
|
@@ -93,22 +91,26 @@ class PanelCodesController():
|
|
| 93 |
|
| 94 |
context_codes_form = {
|
| 95 |
"form_codes": form_codes,
|
| 96 |
-
"use_technique": "rata"
|
| 97 |
}
|
| 98 |
|
| 99 |
if form_codes.is_valid():
|
| 100 |
request.session["form_codes"] = codes
|
| 101 |
-
return redirect(reverse(
|
| 102 |
else:
|
| 103 |
context_codes_form["error"] = "error en los datos recibidos"
|
| 104 |
|
| 105 |
-
return render(request,
|
| 106 |
|
| 107 |
@staticmethod
|
| 108 |
-
def
|
| 109 |
num_products = data["numero_productos"]
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
|
| 8 |
|
| 9 |
class PanelCodesController():
|
| 10 |
+
url_current_panel = "tecnicas/create_sesion/configuracion-panel-codes.html"
|
| 11 |
+
url_next_panel = "cata_system:panel_configuracion_words"
|
| 12 |
+
|
| 13 |
def __init__(self):
|
| 14 |
pass
|
| 15 |
|
| 16 |
@staticmethod
|
| 17 |
def controllGetEscalas(request: HttpRequest, data):
|
| 18 |
+
num_products = data["numero_productos"]
|
| 19 |
+
num_tester = data["numero_catadores"]
|
|
|
|
|
|
|
| 20 |
|
| 21 |
codes_products = generarCodigos(num_products)
|
| 22 |
|
|
|
|
| 28 |
"use_technique": "escalas"
|
| 29 |
}
|
| 30 |
|
| 31 |
+
return render(request, PanelCodesController.url_current_panel, context_codes_form)
|
| 32 |
|
| 33 |
@staticmethod
|
| 34 |
def controllPostEscalas(request: HttpRequest, data):
|
| 35 |
+
num_tester = data["numero_catadores"]
|
|
|
|
|
|
|
|
|
|
| 36 |
|
| 37 |
sorts_code = json.loads(request.POST.get("sort_codes"))
|
| 38 |
codes = []
|
|
|
|
| 58 |
|
| 59 |
codes_sort["sort_codes"] = sorts_code
|
| 60 |
request.session["form_codes"] = codes_sort
|
| 61 |
+
return redirect(reverse(PanelCodesController.url_next_panel))
|
| 62 |
else:
|
| 63 |
context_codes_form["error"] = "error en los datos recibidos"
|
| 64 |
|
| 65 |
+
return render(request, PanelCodesController.url_current_panel, context_codes_form)
|
| 66 |
|
| 67 |
@staticmethod
|
| 68 |
def controllGetRATA(request: HttpRequest, data):
|
|
|
|
| 76 |
"use_technique": "rata"
|
| 77 |
}
|
| 78 |
|
| 79 |
+
return render(request, PanelCodesController.url_current_panel, context_codes_form)
|
| 80 |
|
| 81 |
@staticmethod
|
| 82 |
+
def controllPostRATA(request: HttpRequest, is_rata: True):
|
| 83 |
codes = []
|
| 84 |
context_codes_form = {}
|
| 85 |
|
|
|
|
| 91 |
|
| 92 |
context_codes_form = {
|
| 93 |
"form_codes": form_codes,
|
| 94 |
+
"use_technique": "rata" if is_rata else "cata"
|
| 95 |
}
|
| 96 |
|
| 97 |
if form_codes.is_valid():
|
| 98 |
request.session["form_codes"] = codes
|
| 99 |
+
return redirect(reverse(PanelCodesController.url_next_panel))
|
| 100 |
else:
|
| 101 |
context_codes_form["error"] = "error en los datos recibidos"
|
| 102 |
|
| 103 |
+
return render(request, PanelCodesController.url_current_panel, context_codes_form)
|
| 104 |
|
| 105 |
@staticmethod
|
| 106 |
+
def controllGetCATA(request: HttpRequest, data):
|
| 107 |
num_products = data["numero_productos"]
|
| 108 |
+
codes_products = generarCodigos(num_products)
|
| 109 |
+
form_codes = CodesForm(codes=codes_products)
|
| 110 |
+
|
| 111 |
+
context_codes_form = {
|
| 112 |
+
"form_codes": form_codes,
|
| 113 |
+
"use_technique": "cata"
|
| 114 |
+
}
|
| 115 |
+
|
| 116 |
+
return render(request, PanelCodesController.url_current_panel, context_codes_form)
|
tecnicas/controllers/views_controller/create_session/panel_create_controller.py
CHANGED
|
@@ -2,7 +2,7 @@ from django.http import HttpRequest, JsonResponse
|
|
| 2 |
from django.db import transaction
|
| 3 |
from django.shortcuts import render
|
| 4 |
from tecnicas.utils import general_error
|
| 5 |
-
from tecnicas.models import EsVocabulario, Vocabulario
|
| 6 |
from tecnicas.controllers import TecnicaController, EscalaController, ProductosController, OrdenesController, EstiloPalabrasController, PalabrasController, SesionController
|
| 7 |
from tecnicas.utils import deleteDataSession
|
| 8 |
|
|
@@ -190,9 +190,17 @@ class PanelCreateController():
|
|
| 190 |
data_basic = request.session["form_basic"]
|
| 191 |
data_basic["numero_catadores"] = 0
|
| 192 |
data_basic["numero_repeticiones"] = 1
|
| 193 |
-
|
| 194 |
-
|
| 195 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 196 |
if not technique:
|
| 197 |
raise ValueError("Error al guardar la técnica")
|
| 198 |
|
|
@@ -220,15 +228,18 @@ class PanelCreateController():
|
|
| 220 |
# ////////////////////////////////////////////// #
|
| 221 |
codes = request.session["form_codes"]
|
| 222 |
|
| 223 |
-
|
| 224 |
-
|
| 225 |
-
technique=technique
|
| 226 |
-
)
|
| 227 |
|
| 228 |
-
|
| 229 |
-
|
| 230 |
-
|
| 231 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 232 |
|
| 233 |
# /////////////////////////////////////////////////////// #
|
| 234 |
#
|
|
@@ -236,24 +247,23 @@ class PanelCreateController():
|
|
| 236 |
#
|
| 237 |
# /////////////////////////////////////////////////////// #
|
| 238 |
style_words = technique.id_estilo.nombre_estilo
|
|
|
|
| 239 |
if style_words == "atributos":
|
| 240 |
-
|
| 241 |
-
|
| 242 |
|
| 243 |
-
|
| 244 |
-
if isinstance(words_to_use, dict):
|
| 245 |
-
raise ValueError(words_to_use["error"])
|
| 246 |
|
| 247 |
-
|
| 248 |
-
|
|
|
|
| 249 |
|
| 250 |
-
|
| 251 |
-
|
| 252 |
-
|
|
|
|
|
|
|
| 253 |
|
| 254 |
-
words_using = style_controller.relatedWords()
|
| 255 |
-
if isinstance(words_using, dict):
|
| 256 |
-
raise ValueError(words_using["error"])
|
| 257 |
elif style_words == "vocabulario":
|
| 258 |
name_vocabulary = request.session["form_words"]
|
| 259 |
try:
|
|
@@ -266,6 +276,10 @@ class PanelCreateController():
|
|
| 266 |
id_tecnica=technique,
|
| 267 |
id_vocabulario=vocabulary
|
| 268 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 269 |
else:
|
| 270 |
raise ValueError("Estilo de palabas no permitido")
|
| 271 |
|
|
@@ -274,25 +288,20 @@ class PanelCreateController():
|
|
| 274 |
# Fourth step: Create session and relat with the technique #
|
| 275 |
#
|
| 276 |
# //////////////////////////////////////////////////////// #
|
| 277 |
-
|
| 278 |
name_session=data_basic["nombre_sesion"] if data_basic["nombre_sesion"] != "" else None,
|
| 279 |
technique=technique,
|
| 280 |
creator=request.user.user_presentador
|
| 281 |
)
|
| 282 |
|
| 283 |
-
|
| 284 |
-
|
| 285 |
-
raise ValueError(setting_session["error"])
|
| 286 |
-
|
| 287 |
-
saved_session = session_controller.saveSession()
|
| 288 |
-
if isinstance(saved_session, dict):
|
| 289 |
-
raise ValueError(saved_session["error"])
|
| 290 |
|
| 291 |
context = {
|
| 292 |
"message": "sesión creada",
|
| 293 |
"data": {
|
| 294 |
-
"codigo_sesion":
|
| 295 |
-
"nombre_sesion":
|
| 296 |
}
|
| 297 |
}
|
| 298 |
|
|
@@ -308,3 +317,130 @@ class PanelCreateController():
|
|
| 308 |
return general_error(f"Error: {e}")
|
| 309 |
else:
|
| 310 |
return general_error("No se ha establecido acción")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
from django.db import transaction
|
| 3 |
from django.shortcuts import render
|
| 4 |
from tecnicas.utils import general_error
|
| 5 |
+
from tecnicas.models import EsAtributo, EsVocabulario, Vocabulario, Tecnica, TipoTecnica, EstiloPalabra, Producto, Palabra, SesionSensorial
|
| 6 |
from tecnicas.controllers import TecnicaController, EscalaController, ProductosController, OrdenesController, EstiloPalabrasController, PalabrasController, SesionController
|
| 7 |
from tecnicas.utils import deleteDataSession
|
| 8 |
|
|
|
|
| 190 |
data_basic = request.session["form_basic"]
|
| 191 |
data_basic["numero_catadores"] = 0
|
| 192 |
data_basic["numero_repeticiones"] = 1
|
| 193 |
+
|
| 194 |
+
technique = Tecnica.objects.create(
|
| 195 |
+
tipo_tecnica=TipoTecnica.objects.get(
|
| 196 |
+
nombre_tecnica=data_basic["name_tecnica"]),
|
| 197 |
+
id_estilo=EstiloPalabra.objects.get(
|
| 198 |
+
id=data_basic["estilo_palabras"]),
|
| 199 |
+
repeticiones_max=data_basic["numero_repeticiones"] or 1,
|
| 200 |
+
limite_catadores=data_basic["numero_catadores"],
|
| 201 |
+
instrucciones=data_basic["instrucciones"] or "Espere instrucciones del Presentador",
|
| 202 |
+
)
|
| 203 |
+
|
| 204 |
if not technique:
|
| 205 |
raise ValueError("Error al guardar la técnica")
|
| 206 |
|
|
|
|
| 228 |
# ////////////////////////////////////////////// #
|
| 229 |
codes = request.session["form_codes"]
|
| 230 |
|
| 231 |
+
if not codes:
|
| 232 |
+
raise ValueError("No hay códigos de productos")
|
|
|
|
|
|
|
| 233 |
|
| 234 |
+
products_without_save = []
|
| 235 |
+
for code in codes:
|
| 236 |
+
product = Producto(
|
| 237 |
+
codigoProducto=code,
|
| 238 |
+
id_tecnica=technique
|
| 239 |
+
)
|
| 240 |
+
products_without_save.append(product)
|
| 241 |
+
|
| 242 |
+
Producto.objects.bulk_create(products_without_save)
|
| 243 |
|
| 244 |
# /////////////////////////////////////////////////////// #
|
| 245 |
#
|
|
|
|
| 247 |
#
|
| 248 |
# /////////////////////////////////////////////////////// #
|
| 249 |
style_words = technique.id_estilo.nombre_estilo
|
| 250 |
+
|
| 251 |
if style_words == "atributos":
|
| 252 |
+
raw_ids_words = request.session["form_words"]
|
| 253 |
+
ids_words = [int(id_w) for id_w in raw_ids_words]
|
| 254 |
|
| 255 |
+
words = Palabra.objects.filter(id__in=ids_words)
|
|
|
|
|
|
|
| 256 |
|
| 257 |
+
style_atribute = EsAtributo.objects.create(
|
| 258 |
+
id_tecnica=technique
|
| 259 |
+
)
|
| 260 |
|
| 261 |
+
if not style_atribute:
|
| 262 |
+
raise ValueError(
|
| 263 |
+
"Error al intentar relacionar las palabras con la técnica")
|
| 264 |
+
|
| 265 |
+
style_atribute.palabras.set(words)
|
| 266 |
|
|
|
|
|
|
|
|
|
|
| 267 |
elif style_words == "vocabulario":
|
| 268 |
name_vocabulary = request.session["form_words"]
|
| 269 |
try:
|
|
|
|
| 276 |
id_tecnica=technique,
|
| 277 |
id_vocabulario=vocabulary
|
| 278 |
)
|
| 279 |
+
if not es_vocabulary:
|
| 280 |
+
raise ValueError(
|
| 281 |
+
"Error al intentar relacionar el vocabulario con la técnica")
|
| 282 |
+
|
| 283 |
else:
|
| 284 |
raise ValueError("Estilo de palabas no permitido")
|
| 285 |
|
|
|
|
| 288 |
# Fourth step: Create session and relat with the technique #
|
| 289 |
#
|
| 290 |
# //////////////////////////////////////////////////////// #
|
| 291 |
+
session = SesionSensorial.objects.create(
|
| 292 |
name_session=data_basic["nombre_sesion"] if data_basic["nombre_sesion"] != "" else None,
|
| 293 |
technique=technique,
|
| 294 |
creator=request.user.user_presentador
|
| 295 |
)
|
| 296 |
|
| 297 |
+
if not session:
|
| 298 |
+
raise ValueError("Error al crear sesion sensorial")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 299 |
|
| 300 |
context = {
|
| 301 |
"message": "sesión creada",
|
| 302 |
"data": {
|
| 303 |
+
"codigo_sesion": session.codigo_sesion,
|
| 304 |
+
"nombre_sesion": session.nombre_sesion
|
| 305 |
}
|
| 306 |
}
|
| 307 |
|
|
|
|
| 317 |
return general_error(f"Error: {e}")
|
| 318 |
else:
|
| 319 |
return general_error("No se ha establecido acción")
|
| 320 |
+
|
| 321 |
+
@staticmethod
|
| 322 |
+
def controllPostCATA(request: HttpRequest):
|
| 323 |
+
if request.POST.get('action') == 'create_session':
|
| 324 |
+
if not request.session.get("form_codes") or not request.session.get("form_words"):
|
| 325 |
+
deleteDataSession(request)
|
| 326 |
+
return general_error("No se ha especificado información necesaria para la creación de la sesión, por favor, vuelve a intentarlo")
|
| 327 |
+
try:
|
| 328 |
+
with transaction.atomic():
|
| 329 |
+
# //////////////////////////// #
|
| 330 |
+
#
|
| 331 |
+
# First step: Create technique #
|
| 332 |
+
#
|
| 333 |
+
# //////////////////////////// #
|
| 334 |
+
data_basic = request.session["form_basic"]
|
| 335 |
+
data_basic["numero_catadores"] = 0
|
| 336 |
+
data_basic["numero_repeticiones"] = 1
|
| 337 |
+
|
| 338 |
+
technique = Tecnica.objects.create(
|
| 339 |
+
tipo_tecnica=TipoTecnica.objects.get(
|
| 340 |
+
nombre_tecnica=data_basic["name_tecnica"]),
|
| 341 |
+
id_estilo=EstiloPalabra.objects.get(
|
| 342 |
+
id=data_basic["estilo_palabras"]),
|
| 343 |
+
repeticiones_max=data_basic["numero_repeticiones"] or 1,
|
| 344 |
+
limite_catadores=data_basic["numero_catadores"],
|
| 345 |
+
instrucciones=data_basic["instrucciones"] or "Espere instrucciones del Presentador",
|
| 346 |
+
)
|
| 347 |
+
|
| 348 |
+
if not technique:
|
| 349 |
+
raise ValueError("Error al guardar la técnica")
|
| 350 |
+
|
| 351 |
+
# ////////////////////////////////////////////// #
|
| 352 |
+
#
|
| 353 |
+
# Second step: Create productos with their codes #
|
| 354 |
+
#
|
| 355 |
+
# ////////////////////////////////////////////// #
|
| 356 |
+
codes = request.session["form_codes"]
|
| 357 |
+
|
| 358 |
+
if not codes:
|
| 359 |
+
raise ValueError("No hay códigos de productos")
|
| 360 |
+
|
| 361 |
+
products_without_save = []
|
| 362 |
+
for code in codes:
|
| 363 |
+
product = Producto(
|
| 364 |
+
codigoProducto=code,
|
| 365 |
+
id_tecnica=technique
|
| 366 |
+
)
|
| 367 |
+
products_without_save.append(product)
|
| 368 |
+
|
| 369 |
+
Producto.objects.bulk_create(products_without_save)
|
| 370 |
+
|
| 371 |
+
# /////////////////////////////////////////////////////// #
|
| 372 |
+
#
|
| 373 |
+
# Third step: Create relations technique with Words Style #
|
| 374 |
+
#
|
| 375 |
+
# /////////////////////////////////////////////////////// #
|
| 376 |
+
style_words = technique.id_estilo.nombre_estilo
|
| 377 |
+
|
| 378 |
+
if style_words == "atributos":
|
| 379 |
+
raw_ids_words = request.session["form_words"]
|
| 380 |
+
ids_words = [int(id_w) for id_w in raw_ids_words]
|
| 381 |
+
|
| 382 |
+
words = Palabra.objects.filter(id__in=ids_words)
|
| 383 |
+
|
| 384 |
+
style_atribute = EsAtributo.objects.create(
|
| 385 |
+
id_tecnica=technique
|
| 386 |
+
)
|
| 387 |
+
|
| 388 |
+
if not style_atribute:
|
| 389 |
+
raise ValueError(
|
| 390 |
+
"Error al intentar relacionar las palabras con la técnica")
|
| 391 |
+
|
| 392 |
+
style_atribute.palabras.set(words)
|
| 393 |
+
|
| 394 |
+
elif style_words == "vocabulario":
|
| 395 |
+
name_vocabulary = request.session["form_words"]
|
| 396 |
+
try:
|
| 397 |
+
vocabulary = Vocabulario.objects.get(
|
| 398 |
+
nombre_vocabulario=name_vocabulary)
|
| 399 |
+
except Vocabulario.DoesNotExist:
|
| 400 |
+
raise ValueError("Vocabulario no encontrado")
|
| 401 |
+
|
| 402 |
+
es_vocabulary = EsVocabulario.objects.create(
|
| 403 |
+
id_tecnica=technique,
|
| 404 |
+
id_vocabulario=vocabulary
|
| 405 |
+
)
|
| 406 |
+
if not es_vocabulary:
|
| 407 |
+
raise ValueError(
|
| 408 |
+
"Error al intentar relacionar el vocabulario con la técnica")
|
| 409 |
+
|
| 410 |
+
else:
|
| 411 |
+
raise ValueError("Estilo de palabas no permitido")
|
| 412 |
+
|
| 413 |
+
# //////////////////////////////////////////////////////// #
|
| 414 |
+
#
|
| 415 |
+
# Fourth step: Create session and relat with the technique #
|
| 416 |
+
#
|
| 417 |
+
# //////////////////////////////////////////////////////// #
|
| 418 |
+
session = SesionSensorial.objects.create(
|
| 419 |
+
name_session=data_basic["nombre_sesion"] if data_basic["nombre_sesion"] != "" else None,
|
| 420 |
+
technique=technique,
|
| 421 |
+
creator=request.user.user_presentador
|
| 422 |
+
)
|
| 423 |
+
|
| 424 |
+
if not session:
|
| 425 |
+
raise ValueError("Error al crear sesion sensorial")
|
| 426 |
+
|
| 427 |
+
context = {
|
| 428 |
+
"message": "sesión creada",
|
| 429 |
+
"data": {
|
| 430 |
+
"codigo_sesion": session.codigo_sesion,
|
| 431 |
+
"nombre_sesion": session.nombre_sesion
|
| 432 |
+
}
|
| 433 |
+
}
|
| 434 |
+
|
| 435 |
+
# ////////////////////////////////// #
|
| 436 |
+
#
|
| 437 |
+
# Final step: Delete date en session #
|
| 438 |
+
#
|
| 439 |
+
# ////////////////////////////////// #
|
| 440 |
+
deleteDataSession(request)
|
| 441 |
+
return JsonResponse(context)
|
| 442 |
+
|
| 443 |
+
except ValueError as e:
|
| 444 |
+
return general_error(f"Error: {e}")
|
| 445 |
+
else:
|
| 446 |
+
return general_error("No se ha establecido acción")
|
tecnicas/templates/tecnicas/create_sesion/configuracion-panel-codes.html
CHANGED
|
@@ -7,13 +7,18 @@
|
|
| 7 |
<article class="cts-container-main">
|
| 8 |
<article class="cts-wrap-content text-black">
|
| 9 |
<h1 class="text-center font-bold text-4xl">Panel de configuración</h1>
|
|
|
|
| 10 |
{% if error %}
|
| 11 |
-
|
|
|
|
|
|
|
|
|
|
| 12 |
{% endif %}
|
|
|
|
| 13 |
<form method="post" action="" class="ct-codes-form flex flex-col gap-5">
|
| 14 |
{% csrf_token %}
|
| 15 |
<h2 class="text-2xl mb-2 font-bold">Codificar productos</h2>
|
| 16 |
-
|
| 17 |
<article class="w-full flex flex-col justify-center items-center gap-5">
|
| 18 |
<p class="text-center font-bold tracking-wide text-xl bg-surface-card px-3 py-3 pb-4 rounded max-w-4xl">
|
| 19 |
Puede dejar los campos como están para usar los códigos predefinidos.
|
|
@@ -47,7 +52,6 @@
|
|
| 47 |
</article>
|
| 48 |
{% endif %}
|
| 49 |
|
| 50 |
-
<hr>
|
| 51 |
<article class="flex flex-col items-center gap-4">
|
| 52 |
<section class="flex w-full max-sm:flex-col flex-wrap gap-4 max-w-2xl">
|
| 53 |
<button type="submit" class="cts-btn-general cts-btn-primary btn-push flex-1 w-full">
|
|
|
|
| 7 |
<article class="cts-container-main">
|
| 8 |
<article class="cts-wrap-content text-black">
|
| 9 |
<h1 class="text-center font-bold text-4xl">Panel de configuración</h1>
|
| 10 |
+
|
| 11 |
{% if error %}
|
| 12 |
+
{% include "./components/error-message.html" with message=error %}
|
| 13 |
+
{% endif %}
|
| 14 |
+
{% if message %}
|
| 15 |
+
{% include "./components/error-message.html" with message=message %}
|
| 16 |
{% endif %}
|
| 17 |
+
|
| 18 |
<form method="post" action="" class="ct-codes-form flex flex-col gap-5">
|
| 19 |
{% csrf_token %}
|
| 20 |
<h2 class="text-2xl mb-2 font-bold">Codificar productos</h2>
|
| 21 |
+
|
| 22 |
<article class="w-full flex flex-col justify-center items-center gap-5">
|
| 23 |
<p class="text-center font-bold tracking-wide text-xl bg-surface-card px-3 py-3 pb-4 rounded max-w-4xl">
|
| 24 |
Puede dejar los campos como están para usar los códigos predefinidos.
|
|
|
|
| 52 |
</article>
|
| 53 |
{% endif %}
|
| 54 |
|
|
|
|
| 55 |
<article class="flex flex-col items-center gap-4">
|
| 56 |
<section class="flex w-full max-sm:flex-col flex-wrap gap-4 max-w-2xl">
|
| 57 |
<button type="submit" class="cts-btn-general cts-btn-primary btn-push flex-1 w-full">
|
tecnicas/views/sessions_config/configuration_panel_basic.py
CHANGED
|
@@ -31,6 +31,9 @@ def configurationPanelBasic(req: HttpRequest):
|
|
| 31 |
elif name_tecnica == "rata":
|
| 32 |
response = PanelBasicController.controllPostRATA(
|
| 33 |
request=req, name_tecnica=name_tecnica)
|
|
|
|
|
|
|
|
|
|
| 34 |
else:
|
| 35 |
response = redirect(
|
| 36 |
reverse("cata_system:seleccion_tecnica") + "?error=¡Oh, vaya! Cambio de técnica repentino, vuelve a elegir otra vez")
|
|
|
|
| 31 |
elif name_tecnica == "rata":
|
| 32 |
response = PanelBasicController.controllPostRATA(
|
| 33 |
request=req, name_tecnica=name_tecnica)
|
| 34 |
+
elif name_tecnica == "cata":
|
| 35 |
+
response = PanelBasicController.controllPostCATA(
|
| 36 |
+
request=req, name_tecnica=name_tecnica)
|
| 37 |
else:
|
| 38 |
response = redirect(
|
| 39 |
reverse("cata_system:seleccion_tecnica") + "?error=¡Oh, vaya! Cambio de técnica repentino, vuelve a elegir otra vez")
|
tecnicas/views/sessions_config/configuration_panel_codes.py
CHANGED
|
@@ -12,25 +12,32 @@ def configurationPanelCodes(req: HttpRequest):
|
|
| 12 |
"?error=datos del formulario requerido no encontrados")
|
| 13 |
|
| 14 |
data_basic = req.session["form_basic"]
|
|
|
|
| 15 |
|
| 16 |
if req.method == "GET":
|
| 17 |
-
if
|
| 18 |
response = PanelCodesController.controllGetEscalas(
|
| 19 |
req, data_basic)
|
| 20 |
-
elif
|
| 21 |
response = PanelCodesController.controllGetRATA(
|
| 22 |
req, data_basic)
|
|
|
|
|
|
|
|
|
|
| 23 |
else:
|
| 24 |
response = redirect(
|
| 25 |
reverse("cata_system:seleccion_tecnica") + "?error=Técnica no valida")
|
| 26 |
|
| 27 |
return response
|
| 28 |
elif req.method == "POST":
|
| 29 |
-
if
|
| 30 |
response = PanelCodesController.controllPostEscalas(
|
| 31 |
req, data_basic)
|
| 32 |
-
elif
|
| 33 |
response = PanelCodesController.controllPostRATA(request=req)
|
|
|
|
|
|
|
|
|
|
| 34 |
else:
|
| 35 |
response = redirect(
|
| 36 |
reverse("cata_system:seleccion_tecnica") + "?error=Técnica no valida")
|
|
|
|
| 12 |
"?error=datos del formulario requerido no encontrados")
|
| 13 |
|
| 14 |
data_basic = req.session["form_basic"]
|
| 15 |
+
name_technique = data_basic["name_tecnica"]
|
| 16 |
|
| 17 |
if req.method == "GET":
|
| 18 |
+
if name_technique == "escalas":
|
| 19 |
response = PanelCodesController.controllGetEscalas(
|
| 20 |
req, data_basic)
|
| 21 |
+
elif name_technique == "rata":
|
| 22 |
response = PanelCodesController.controllGetRATA(
|
| 23 |
req, data_basic)
|
| 24 |
+
elif name_technique == "cata":
|
| 25 |
+
response = PanelCodesController.controllGetCATA(
|
| 26 |
+
req, data_basic)
|
| 27 |
else:
|
| 28 |
response = redirect(
|
| 29 |
reverse("cata_system:seleccion_tecnica") + "?error=Técnica no valida")
|
| 30 |
|
| 31 |
return response
|
| 32 |
elif req.method == "POST":
|
| 33 |
+
if name_technique == "escalas":
|
| 34 |
response = PanelCodesController.controllPostEscalas(
|
| 35 |
req, data_basic)
|
| 36 |
+
elif name_technique == "rata":
|
| 37 |
response = PanelCodesController.controllPostRATA(request=req)
|
| 38 |
+
elif name_technique == "cata":
|
| 39 |
+
response = PanelCodesController.controllPostRATA(
|
| 40 |
+
request=req, is_rata=False)
|
| 41 |
else:
|
| 42 |
response = redirect(
|
| 43 |
reverse("cata_system:seleccion_tecnica") + "?error=Técnica no valida")
|
tecnicas/views/sessions_config/configuration_panel_words.py
CHANGED
|
@@ -13,14 +13,19 @@ def configurationPanelWords(req: HttpRequest):
|
|
| 13 |
"?error=datos requeridos no encontrados")
|
| 14 |
|
| 15 |
basic_data = req.session["form_basic"]
|
| 16 |
-
|
|
|
|
|
|
|
| 17 |
|
| 18 |
if req.method == "GET":
|
| 19 |
-
if
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
|
|
|
|
|
|
|
|
|
| 24 |
else:
|
| 25 |
response = redirect(
|
| 26 |
reverse("cata_system:seleccion_tecnica") + "?error=Estilo de palabras no valida")
|
|
@@ -28,12 +33,15 @@ def configurationPanelWords(req: HttpRequest):
|
|
| 28 |
response = redirect(
|
| 29 |
reverse("cata_system:seleccion_tecnica") + "?error=Técnica no valida")
|
| 30 |
return response
|
|
|
|
| 31 |
elif req.method == "POST":
|
| 32 |
-
if
|
| 33 |
-
if style_words
|
| 34 |
-
response = PanelWordsController.controllPostEscalasAtributes(
|
| 35 |
-
|
| 36 |
-
|
|
|
|
|
|
|
| 37 |
else:
|
| 38 |
response = redirect(
|
| 39 |
reverse("cata_system:seleccion_tecnica") + "?error=Estilo de palabras no valida")
|
|
@@ -42,5 +50,6 @@ def configurationPanelWords(req: HttpRequest):
|
|
| 42 |
reverse("cata_system:seleccion_tecnica") + "?error=Técnica no valida")
|
| 43 |
|
| 44 |
return response
|
|
|
|
| 45 |
else:
|
| 46 |
return JsonResponse({"message": "Método no permitido"})
|
|
|
|
| 13 |
"?error=datos requeridos no encontrados")
|
| 14 |
|
| 15 |
basic_data = req.session["form_basic"]
|
| 16 |
+
name_technique = basic_data["name_tecnica"]
|
| 17 |
+
style_words = EstiloPalabra.objects.get(
|
| 18 |
+
id=basic_data["estilo_palabras"]).nombre_estilo
|
| 19 |
|
| 20 |
if req.method == "GET":
|
| 21 |
+
if name_technique == "escalas" or name_technique == "rata" or name_technique == "cata":
|
| 22 |
+
print()
|
| 23 |
+
if style_words == "atributos":
|
| 24 |
+
response = PanelWordsController.controllGetEscalasAtributes(
|
| 25 |
+
req)
|
| 26 |
+
elif style_words == "vocabulario":
|
| 27 |
+
response = PanelWordsController.controllGetEscalasVocabulary(
|
| 28 |
+
req)
|
| 29 |
else:
|
| 30 |
response = redirect(
|
| 31 |
reverse("cata_system:seleccion_tecnica") + "?error=Estilo de palabras no valida")
|
|
|
|
| 33 |
response = redirect(
|
| 34 |
reverse("cata_system:seleccion_tecnica") + "?error=Técnica no valida")
|
| 35 |
return response
|
| 36 |
+
|
| 37 |
elif req.method == "POST":
|
| 38 |
+
if name_technique == "escalas" or name_technique == "rata" or name_technique == "cata":
|
| 39 |
+
if style_words == "atributos":
|
| 40 |
+
response = PanelWordsController.controllPostEscalasAtributes(
|
| 41 |
+
req)
|
| 42 |
+
elif style_words == "vocabulario":
|
| 43 |
+
response = PanelWordsController.controllPostEscalasVocabulary(
|
| 44 |
+
req)
|
| 45 |
else:
|
| 46 |
response = redirect(
|
| 47 |
reverse("cata_system:seleccion_tecnica") + "?error=Estilo de palabras no valida")
|
|
|
|
| 50 |
reverse("cata_system:seleccion_tecnica") + "?error=Técnica no valida")
|
| 51 |
|
| 52 |
return response
|
| 53 |
+
|
| 54 |
else:
|
| 55 |
return JsonResponse({"message": "Método no permitido"})
|
tecnicas/views/sessions_config/create_session.py
CHANGED
|
@@ -26,6 +26,8 @@ def createSession(req: HttpRequest):
|
|
| 26 |
response = PanelCreateController.controllPostEscalas(req)
|
| 27 |
elif basic_data["name_tecnica"] == "rata":
|
| 28 |
response = PanelCreateController.controllPostRATA(req)
|
|
|
|
|
|
|
| 29 |
else:
|
| 30 |
response = redirect(
|
| 31 |
reverse("cata_system:seleccion_tecnica") + "?error=Técnica no valida")
|
|
|
|
| 26 |
response = PanelCreateController.controllPostEscalas(req)
|
| 27 |
elif basic_data["name_tecnica"] == "rata":
|
| 28 |
response = PanelCreateController.controllPostRATA(req)
|
| 29 |
+
elif basic_data["name_tecnica"] == "cata":
|
| 30 |
+
response = PanelCreateController.controllPostCATA(req)
|
| 31 |
else:
|
| 32 |
response = redirect(
|
| 33 |
reverse("cata_system:seleccion_tecnica") + "?error=Técnica no valida")
|