Norberto Montalvo García commited on
Commit
31ea9c3
·
unverified ·
2 Parent(s): 2ec59e0 ae4c464

Merge pull request #41 from CascoArcilla/HU5

Browse files

Descarga de datos con nappging y remover modicacion de vocabularios

Files changed (24) hide show
  1. tecnicas/controllers/__init__.py +1 -0
  2. tecnicas/controllers/models_controller/dato_controller.py +3 -3
  3. tecnicas/controllers/views_controller/create_session/panel_codes_controller.py +6 -2
  4. tecnicas/controllers/views_controller/session_management/details/details_napping_controller.py +286 -5
  5. tecnicas/controllers/views_controller/sessions_tester/tests_forms/test_rata_controller.py +6 -0
  6. tecnicas/controllers/views_controller/vocabulary_manage/create_vocabulary_controller.py +17 -68
  7. tecnicas/controllers/views_controller/vocabulary_manage/list_vocabulary_controller.py +1 -1
  8. tecnicas/controllers/views_controller/vocabulary_manage/view_vocabulary_controller.py +28 -0
  9. tecnicas/forms/catador_form.py +0 -2
  10. tecnicas/forms/codes_form.py +8 -0
  11. tecnicas/static/img/words.webp +0 -0
  12. tecnicas/static/js/created-vocabulary.js +1 -23
  13. tecnicas/templates/tecnicas/components/item_vocabulary.html +2 -2
  14. tecnicas/templates/tecnicas/components/table-napping-combined.html +174 -0
  15. tecnicas/templates/tecnicas/components/table-napping-no-mode.html +11 -1
  16. tecnicas/templates/tecnicas/components/table-napping-puf.html +10 -0
  17. tecnicas/templates/tecnicas/components/table-napping-sorting.html +10 -0
  18. tecnicas/templates/tecnicas/manage_sesions/details-session-napping.html +43 -0
  19. tecnicas/templates/tecnicas/manage_vocabulary/create-vocabulary.html +0 -17
  20. tecnicas/templates/tecnicas/manage_vocabulary/panel-vocabulary.html +2 -2
  21. tecnicas/templates/tecnicas/manage_vocabulary/view-vocabulary.html +85 -0
  22. tecnicas/urls.py +4 -0
  23. tecnicas/views/__init__.py +1 -0
  24. tecnicas/views/vocabulary_management/view_vocabulary.py +13 -0
tecnicas/controllers/__init__.py CHANGED
@@ -56,6 +56,7 @@ from .views_controller.sessions_tester.init_session.init_session_sort_controller
56
  from .views_controller.sessions_tester.init_session.init_session_napping_controller import InitSessionNappingController
57
 
58
  from .views_controller.vocabulary_manage.create_vocabulary_controller import CreateVocabularyController
 
59
  from .views_controller.vocabulary_manage.list_vocabulary_controller import ListVocabularyController
60
 
61
  from .api_controller.rating_sacales_controller import RatingScalesController
 
56
  from .views_controller.sessions_tester.init_session.init_session_napping_controller import InitSessionNappingController
57
 
58
  from .views_controller.vocabulary_manage.create_vocabulary_controller import CreateVocabularyController
59
+ from .views_controller.vocabulary_manage.view_vocabulary_controller import ViewVocabularyController
60
  from .views_controller.vocabulary_manage.list_vocabulary_controller import ListVocabularyController
61
 
62
  from .api_controller.rating_sacales_controller import RatingScalesController
tecnicas/controllers/models_controller/dato_controller.py CHANGED
@@ -36,18 +36,18 @@ class DatoController():
36
  return controller_error(e.message)
37
 
38
  def setValue(self):
39
- if isinstance(self.value_rating, bool):
 
40
  self.value_data = ValorBooleano(valor=self.value_rating)
41
 
42
  else:
43
  type_scale = self.data.id_calificacion.id_tecnica.escala_tecnica.id_tipo_escala.nombre_escala
44
-
45
 
46
  if type_scale == "continua":
47
  decimal_value = self.value_rating/100
48
  value_rounded = round(decimal_value)
49
  self.value_data = ValorDecimal(valor=value_rounded)
50
-
51
  else:
52
  self.value_data = ValorDecimal(valor=self.value_rating)
53
 
 
36
  return controller_error(e.message)
37
 
38
  def setValue(self):
39
+ type_technique = self.data.id_calificacion.id_tecnica.tipo_tecnica
40
+ if type_technique == "cata":
41
  self.value_data = ValorBooleano(valor=self.value_rating)
42
 
43
  else:
44
  type_scale = self.data.id_calificacion.id_tecnica.escala_tecnica.id_tipo_escala.nombre_escala
 
45
 
46
  if type_scale == "continua":
47
  decimal_value = self.value_rating/100
48
  value_rounded = round(decimal_value)
49
  self.value_data = ValorDecimal(valor=value_rounded)
50
+
51
  else:
52
  self.value_data = ValorDecimal(valor=self.value_rating)
53
 
tecnicas/controllers/views_controller/create_session/panel_codes_controller.py CHANGED
@@ -96,7 +96,9 @@ class PanelCodesController():
96
  }
97
 
98
  if form_codes.is_valid():
99
- request.session["form_codes"] = codes
 
 
100
  return redirect(reverse(PanelCodesController.url_words))
101
  else:
102
  context_codes_form["error"] = "error en los datos recibidos"
@@ -133,7 +135,9 @@ class PanelCodesController():
133
  }
134
 
135
  if form_codes.is_valid():
136
- request.session["form_codes"] = codes
 
 
137
  return redirect(reverse(PanelCodesController.url_create_session))
138
  else:
139
  context_codes_form["error"] = "error en los datos recibidos"
 
96
  }
97
 
98
  if form_codes.is_valid():
99
+ # Extract codes from cleaned_data to ensure uppercase conversion
100
+ cleaned_codes = [value for name, value in form_codes.cleaned_data.items() if name.startswith('producto_')]
101
+ request.session["form_codes"] = cleaned_codes
102
  return redirect(reverse(PanelCodesController.url_words))
103
  else:
104
  context_codes_form["error"] = "error en los datos recibidos"
 
135
  }
136
 
137
  if form_codes.is_valid():
138
+ # Extract codes from cleaned_data to ensure uppercase conversion
139
+ cleaned_codes = [value for name, value in form_codes.cleaned_data.items() if name.startswith('producto_')]
140
+ request.session["form_codes"] = cleaned_codes
141
  return redirect(reverse(PanelCodesController.url_create_session))
142
  else:
143
  context_codes_form["error"] = "error en los datos recibidos"
tecnicas/controllers/views_controller/session_management/details/details_napping_controller.py CHANGED
@@ -3,7 +3,11 @@ from django.shortcuts import redirect
3
  from django.urls import reverse
4
  from django.db.models import F
5
  from .details_controller import DetallesController
6
- from tecnicas.models import SesionSensorial, Presentador, Modalidad, TecnicaModalidad, Catador, Participacion, DatoPunto, Calificacion, GrupoProducto
 
 
 
 
7
  from tecnicas.utils import defaultdict_to_dict
8
  from collections import defaultdict
9
 
@@ -13,11 +17,10 @@ class DetallesNappingController(DetallesController):
13
  super().__init__(session)
14
  self.url_template = "tecnicas/manage_sesions/details-session-napping.html"
15
  self.url_next = "cata_system:monitor_sesion"
 
16
 
17
  def getContext(self):
18
- self.context = {
19
- "session": self.session,
20
- }
21
 
22
  self.defineStatus()
23
  self.setIsEndSession()
@@ -41,7 +44,6 @@ class DetallesNappingController(DetallesController):
41
  self.context["status"] = "Sesión con en curso"
42
 
43
  def controllPostResponse(self, request: HttpRequest, action: str):
44
- print(action)
45
  if action == "start_sin_modalidad":
46
  response = self.startNapping(request=request)
47
 
@@ -51,6 +53,9 @@ class DetallesNappingController(DetallesController):
51
  elif action == "start_sorting":
52
  response = self.startNapping(request=request)
53
 
 
 
 
54
  elif action == "delete_session":
55
  self.deleteSesorialSession()
56
  response = redirect(
@@ -225,3 +230,279 @@ class DetallesNappingController(DetallesController):
225
  elif not self.session.activo and self.session.tecnica.repeticion >= 1:
226
  self.context["finished"] = True
227
  return
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  from django.urls import reverse
4
  from django.db.models import F
5
  from .details_controller import DetallesController
6
+ from tecnicas.models import (
7
+ SesionSensorial, Presentador, Modalidad, TecnicaModalidad, Catador,
8
+ Participacion, DatoPunto, Calificacion, GrupoProducto, ValorBooleano,
9
+ ValorDecimal, Producto, Escala, EsVocabulario, Vocabulario
10
+ )
11
  from tecnicas.utils import defaultdict_to_dict
12
  from collections import defaultdict
13
 
 
17
  super().__init__(session)
18
  self.url_template = "tecnicas/manage_sesions/details-session-napping.html"
19
  self.url_next = "cata_system:monitor_sesion"
20
+ self.context = {}
21
 
22
  def getContext(self):
23
+ self.context["session"] = self.session
 
 
24
 
25
  self.defineStatus()
26
  self.setIsEndSession()
 
44
  self.context["status"] = "Sesión con en curso"
45
 
46
  def controllPostResponse(self, request: HttpRequest, action: str):
 
47
  if action == "start_sin_modalidad":
48
  response = self.startNapping(request=request)
49
 
 
53
  elif action == "start_sorting":
54
  response = self.startNapping(request=request)
55
 
56
+ elif action == "combine_sessions":
57
+ response = self.combineSessions(request=request)
58
+
59
  elif action == "delete_session":
60
  self.deleteSesorialSession()
61
  response = redirect(
 
230
  elif not self.session.activo and self.session.tecnica.repeticion >= 1:
231
  self.context["finished"] = True
232
  return
233
+
234
+ # ==================== SESSION COMBINATION METHODS ====================
235
+
236
+ def combineSessions(self, request: HttpRequest):
237
+ """Handle session combination request"""
238
+ session_b_code = request.POST.get("session_b_code", "").strip()
239
+
240
+ if not session_b_code:
241
+ return self.controllGetResponse(
242
+ error="Debe proporcionar un código de sesión", request=request)
243
+
244
+ # Validate and get session B
245
+ validation_result = self.validateSessionCombination(session_b_code)
246
+
247
+ if validation_result.get("error"):
248
+ return self.controllGetResponse(
249
+ error=validation_result["error"], request=request)
250
+
251
+ session_b = validation_result["session_b"]
252
+ technique_type = validation_result["technique_type"]
253
+
254
+ # Get combined data based on technique type
255
+ if technique_type == "cata":
256
+ combined_data = self.getCombinedDataForCATA(session_b)
257
+ elif technique_type == "rata":
258
+ combined_data = self.getCombinedDataForRATA(session_b)
259
+ elif technique_type == "escalas":
260
+ combined_data = self.getCombinedDataForEscalas(session_b)
261
+ else:
262
+ return self.controllGetResponse(
263
+ error="Tipo de técnica no soportado para combinación", request=request)
264
+
265
+ # Add combined data to context
266
+ self.context["combined_data"] = combined_data
267
+ self.context["session_b"] = session_b
268
+ self.context["session_b_technique_type"] = technique_type
269
+
270
+ return self.controllGetResponse(request=request)
271
+
272
+ def validateSessionCombination(self, session_b_code: str):
273
+ """Validate that Session B can be combined with Session A (Napping)"""
274
+ result = {"error": None, "session_b": None, "technique_type": None}
275
+
276
+ # Check if Session B exists
277
+ try:
278
+ session_b = SesionSensorial.objects.select_related(
279
+ "tecnica__tipo_tecnica").get(codigo_sesion=session_b_code)
280
+ except SesionSensorial.DoesNotExist:
281
+ result["error"] = f"No existe una sesión con el código: {session_b_code}"
282
+ return result
283
+
284
+ # Check if Session B technique is CATA, RATA, or Escalas
285
+ technique_type = session_b.tecnica.tipo_tecnica.nombre_tecnica
286
+ valid_techniques = ["cata", "rata", "escalas"]
287
+
288
+ if technique_type not in valid_techniques:
289
+ result[
290
+ "error"] = f"La sesión B debe usar CATA, RATA o Escalas. Técnica actual: {technique_type}"
291
+ return result
292
+
293
+ # Check if Session B is finished
294
+ if session_b.activo:
295
+ result["error"] = "La sesión B debe estar finalizada (no activa)"
296
+ return result
297
+
298
+ if session_b.tecnica.repeticion < 1:
299
+ result["error"] = "La sesión B debe haber completado al menos una repetición"
300
+ return result
301
+
302
+ # Get products from both sessions
303
+ products_a = set(
304
+ Producto.objects.filter(
305
+ calificacion_producto__id_tecnica=self.session.tecnica
306
+ ).values_list("codigoProducto", flat=True).distinct()
307
+ )
308
+
309
+ products_b = set(
310
+ Producto.objects.filter(
311
+ calificacion_producto__id_tecnica=session_b.tecnica
312
+ ).values_list("codigoProducto", flat=True).distinct()
313
+ )
314
+
315
+ # Check if products match
316
+ if products_a != products_b:
317
+ result["error"] = f"Los productos no coinciden. Sesión A: {len(products_a)} productos, Sesión B: {len(products_b)} productos"
318
+ return result
319
+
320
+ # Get tasters from both sessions
321
+ tasters_a = set(
322
+ Participacion.objects.filter(
323
+ tecnica=self.session.tecnica
324
+ ).values_list("catador__user__username", flat=True)
325
+ )
326
+
327
+ tasters_b = set(
328
+ Participacion.objects.filter(
329
+ tecnica=session_b.tecnica
330
+ ).values_list("catador__user__username", flat=True)
331
+ )
332
+
333
+ # Check if tasters match
334
+ if tasters_a != tasters_b:
335
+ result["error"] = f"Los catadores no coinciden. Sesión A: {len(tasters_a)} catadores, Sesión B: {len(tasters_b)} catadores"
336
+ return result
337
+
338
+ result["session_b"] = session_b
339
+ result["technique_type"] = technique_type
340
+ return result
341
+
342
+ def getCombinedDataForCATA(self, session_b: SesionSensorial):
343
+ """Get combined data for CATA technique (word frequencies)"""
344
+ from collections import Counter
345
+
346
+ # Get all ratings for session B
347
+ ratings_b = Calificacion.objects.filter(id_tecnica=session_b.tecnica)
348
+
349
+ # Get boolean values (CATA uses boolean)
350
+ data = (
351
+ ValorBooleano.objects
352
+ .filter(id_dato__id_calificacion__in=ratings_b, valor=True)
353
+ .values(
354
+ palabra=F("id_dato__id_palabra__nombre_palabra"),
355
+ producto=F(
356
+ "id_dato__id_calificacion__id_producto__codigoProducto"),
357
+ )
358
+ )
359
+
360
+ # Count word frequencies per product
361
+ word_frequencies = defaultdict(Counter)
362
+ all_words_set = set()
363
+
364
+ for item in data:
365
+ palabra = item["palabra"]
366
+ producto = item["producto"]
367
+ word_frequencies[producto][palabra] += 1
368
+ all_words_set.add(palabra)
369
+
370
+ # Get vocabulary info if exists
371
+ vocabulary_info = self.getVocabularyInfo(session_b.tecnica)
372
+
373
+ return {
374
+ "word_frequencies": defaultdict_to_dict(word_frequencies),
375
+ "all_words": sorted(all_words_set),
376
+ "vocabulary_info": vocabulary_info,
377
+ }
378
+
379
+ def getCombinedDataForRATA(self, session_b: SesionSensorial):
380
+ """Get combined data for RATA technique (word averages)"""
381
+
382
+ # Get all ratings for session B
383
+ ratings_b = Calificacion.objects.filter(id_tecnica=session_b.tecnica)
384
+
385
+ # Get decimal values (RATA uses decimal)
386
+ data = (
387
+ ValorDecimal.objects
388
+ .filter(id_dato__id_calificacion__in=ratings_b)
389
+ .values(
390
+ palabra=F("id_dato__id_palabra__nombre_palabra"),
391
+ producto=F(
392
+ "id_dato__id_calificacion__id_producto__codigoProducto"),
393
+ valor_decimal=F("valor"),
394
+ )
395
+ )
396
+
397
+ # Calculate averages per product per word
398
+ word_sums = defaultdict(lambda: defaultdict(list))
399
+ all_words_set = set()
400
+
401
+ for item in data:
402
+ palabra = item["palabra"]
403
+ producto = item["producto"]
404
+ valor = item["valor_decimal"]
405
+ word_sums[producto][palabra].append(valor)
406
+ all_words_set.add(palabra)
407
+
408
+ # Calculate averages
409
+ word_averages = {}
410
+ for producto, palabras in word_sums.items():
411
+ word_averages[producto] = {}
412
+ for palabra, valores in palabras.items():
413
+ word_averages[producto][palabra] = sum(valores) / len(valores)
414
+
415
+ # Get vocabulary info if exists
416
+ vocabulary_info = self.getVocabularyInfo(session_b.tecnica)
417
+
418
+ return {
419
+ "word_averages": word_averages,
420
+ "all_words": sorted(all_words_set),
421
+ "vocabulary_info": vocabulary_info,
422
+ }
423
+
424
+ def getCombinedDataForEscalas(self, session_b: SesionSensorial):
425
+ """Get combined data for Escalas technique (averages across repetitions)"""
426
+
427
+ # Get all ratings for session B
428
+ ratings_b = Calificacion.objects.filter(id_tecnica=session_b.tecnica)
429
+
430
+ # Get decimal values grouped by repetition
431
+ data = (
432
+ ValorDecimal.objects
433
+ .filter(id_dato__id_calificacion__in=ratings_b)
434
+ .values(
435
+ palabra=F("id_dato__id_palabra__nombre_palabra"),
436
+ producto=F(
437
+ "id_dato__id_calificacion__id_producto__codigoProducto"),
438
+ repeticion=F("id_dato__id_calificacion__num_repeticion"),
439
+ valor_decimal=F("valor"),
440
+ )
441
+ )
442
+
443
+ # Calculate averages per repetition (like RATA), then average across repetitions
444
+ # Structure: {producto: {repeticion: {palabra: [valores]}}}
445
+ repetition_values = defaultdict(
446
+ lambda: defaultdict(lambda: defaultdict(list)))
447
+ all_words_set = set()
448
+
449
+ for item in data:
450
+ palabra = item["palabra"]
451
+ producto = item["producto"]
452
+ repeticion = item["repeticion"]
453
+ valor = item["valor_decimal"]
454
+ # Collect all values for averaging
455
+ repetition_values[producto][repeticion][palabra].append(valor)
456
+ all_words_set.add(palabra)
457
+
458
+ # Calculate average per repetition, then average across repetitions
459
+ word_averages = {}
460
+ for producto, repeticiones in repetition_values.items():
461
+ word_averages[producto] = {}
462
+ # Get all words for this product across all repetitions
463
+ all_product_words = set()
464
+ for rep_words in repeticiones.values():
465
+ all_product_words.update(rep_words.keys())
466
+
467
+ # Calculate average for each word
468
+ for palabra in all_product_words:
469
+ # Get average for each repetition
470
+ rep_averages = []
471
+ for rep in repeticiones.keys():
472
+ if palabra in repeticiones[rep]:
473
+ valores = repeticiones[rep][palabra]
474
+ rep_averages.append(sum(valores) / len(valores))
475
+
476
+ # Average the repetition averages
477
+ if rep_averages:
478
+ word_averages[producto][palabra] = sum(
479
+ rep_averages) / len(rep_averages)
480
+
481
+ # Get scale and vocabulary info
482
+ scale = Escala.objects.get(tecnica=session_b.tecnica)
483
+ scale_info = None
484
+ if scale:
485
+ scale_info = {
486
+ "type": scale.id_tipo_escala.nombre_escala,
487
+ "size": scale.longitud
488
+ }
489
+
490
+ vocabulary_info = self.getVocabularyInfo(session_b.tecnica)
491
+
492
+ return {
493
+ "word_averages": word_averages,
494
+ "all_words": sorted(all_words_set),
495
+ "scale_info": scale_info,
496
+ "vocabulary_info": vocabulary_info,
497
+ "num_repetitions": session_b.tecnica.repeticion,
498
+ }
499
+
500
+ def getVocabularyInfo(self, tecnica):
501
+ es_vocabulario = EsVocabulario.objects.filter(
502
+ id_tecnica=tecnica).first()
503
+ if es_vocabulario:
504
+ vocabulario = es_vocabulario.id_vocabulario
505
+ return {
506
+ "nombre": vocabulario.nombre_vocabulario,
507
+ }
508
+ return None
tecnicas/controllers/views_controller/sessions_tester/tests_forms/test_rata_controller.py CHANGED
@@ -77,5 +77,11 @@ class TestRataController(GenetalTestController):
77
 
78
  use_tags = EscalaController.getRelatedTagsInScale(scale=scale)
79
  self.context["tags"] = use_tags
 
 
 
 
 
 
80
 
81
  return render(request, self.current_directory, self.context)
 
77
 
78
  use_tags = EscalaController.getRelatedTagsInScale(scale=scale)
79
  self.context["tags"] = use_tags
80
+
81
+ if self.context["type_scale"] == "continua":
82
+ self.context["size_scale"] = {
83
+ "max_size": scale.longitud * 100,
84
+ "middle_size": (scale.longitud * 100)/2
85
+ }
86
 
87
  return render(request, self.current_directory, self.context)
tecnicas/controllers/views_controller/vocabulary_manage/create_vocabulary_controller.py CHANGED
@@ -19,13 +19,6 @@ class CreateVocabularyController():
19
  "form_word": WordForm(),
20
  "words": []
21
  }
22
-
23
- if "name_voca" in request.GET:
24
- current = Vocabulario.objects.get(
25
- nombre_vocabulario=request.GET["name_voca"])
26
- self.context["name_vacabulary"] = current.nombre_vocabulario
27
- self.context["words"] = current.palabras.all()
28
-
29
  return render(request, self.current_url, self.context)
30
 
31
  def controllPost(self, request: HttpRequest):
@@ -39,72 +32,28 @@ class CreateVocabularyController():
39
  return render(request, self.current_url, self.context)
40
 
41
  new_vocabulary_name = request.POST.get("nombre_vocabulario").strip()
42
- is_update = request.POST.get("is_update")
43
-
44
- print(is_update)
45
-
46
- if is_update:
47
- if "original_name" not in request.POST:
48
- self.context["error"] = "Nombre original de vocabulario requerido"
49
- return render(request, self.current_url, self.context)
50
 
51
- original_name = request.POST["original_name"].strip()
52
-
53
- if original_name != new_vocabulary_name:
54
- if Vocabulario.objects.filter(nombre_vocabulario=new_vocabulary_name).exists():
55
- self.context["error"] = "Ya existe un vocabulario con el nombre pasado"
56
- return render(request, self.current_url, self.context)
57
 
 
 
58
  try:
59
- current_vocababulary = Vocabulario.objects.get(
60
- nombre_vocabulario=original_name)
61
- except Vocabulario.DoesNotExist:
62
- self.context["error"] = "No existe un vocabulario con ese nombre"
63
- return render(request, self.current_url, self.context)
64
-
65
- words_json = request.POST.get("words", "")
66
- if words_json:
67
- try:
68
- words_list = json.loads(words_json)
69
 
70
- ids = [int(w.get("id", 0))
71
- for w in words_list if str(w.get("id", "")).isdigit()]
72
 
73
- words = Palabra.objects.filter(id__in=ids)
74
 
75
- current_vocababulary.palabras.set(words)
76
- current_vocababulary.nombre_vocabulario = new_vocabulary_name
77
- current_vocababulary.save()
78
- except (json.JSONDecodeError, ValueError):
79
- self.context["error"] = 'Ocurrió un error al revisar las palabras, revise “Ver vocabularios”, para reasignar las palabras'
80
- return render(request, self.current_url, self.context)
81
-
82
- self.context["message"] = 'Vocabulario creado con éxito, puedes revisarlo en "Ver vocabularios"'
83
- return render(request, self.current_url, self.context)
84
- elif not is_update:
85
- try:
86
- new_vocababulary = Vocabulario.objects.create(
87
- nombre_vocabulario=new_vocabulary_name)
88
- except IntegrityError:
89
- self.context["error"] = "Ya existe un vocabulario con ese nombre"
90
  return render(request, self.current_url, self.context)
91
 
92
- words_json = request.POST.get("words", "")
93
- if words_json:
94
- try:
95
- words_list = json.loads(words_json)
96
-
97
- ids = [int(w.get("id", 0))
98
- for w in words_list if str(w.get("id", "")).isdigit()]
99
-
100
- words = Palabra.objects.filter(id__in=ids)
101
-
102
- new_vocababulary.palabras.add(*words)
103
- except (json.JSONDecodeError, ValueError):
104
- self.context["error"] = 'Ocurrió un error al revisar las palabras, revise “Ver vocabularios”, para reasignar las palabras'
105
- return render(request, self.current_url, self.context)
106
-
107
- self.context["message"] = 'Vocabulario actualziado con éxito, puedes revisarlo en "Ver vocabularios"'
108
- return render(request, self.current_url, self.context)
109
- else:
110
- pass
 
19
  "form_word": WordForm(),
20
  "words": []
21
  }
 
 
 
 
 
 
 
22
  return render(request, self.current_url, self.context)
23
 
24
  def controllPost(self, request: HttpRequest):
 
32
  return render(request, self.current_url, self.context)
33
 
34
  new_vocabulary_name = request.POST.get("nombre_vocabulario").strip()
 
 
 
 
 
 
 
 
35
 
36
+ try:
37
+ new_vocababulary = Vocabulario.objects.create(
38
+ nombre_vocabulario=new_vocabulary_name)
39
+ except IntegrityError:
40
+ self.context["error"] = "Ya existe un vocabulario con ese nombre"
41
+ return render(request, self.current_url, self.context)
42
 
43
+ words_json = request.POST.get("words", "")
44
+ if words_json:
45
  try:
46
+ words_list = json.loads(words_json)
 
 
 
 
 
 
 
 
 
47
 
48
+ ids = [int(w.get("id", 0))
49
+ for w in words_list if str(w.get("id", "")).isdigit()]
50
 
51
+ words = Palabra.objects.filter(id__in=ids)
52
 
53
+ new_vocababulary.palabras.add(*words)
54
+ except (json.JSONDecodeError, ValueError):
55
+ self.context["error"] = 'Ocurrió un error al revisar las palabras, revise “Ver vocabularios”, para reasignar las palabras'
 
 
 
 
 
 
 
 
 
 
 
 
56
  return render(request, self.current_url, self.context)
57
 
58
+ self.context["message"] = 'Vocabulario creado con éxito, puedes revisarlo en "Ver vocabularios"'
59
+ return render(request, self.current_url, self.context)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tecnicas/controllers/views_controller/vocabulary_manage/list_vocabulary_controller.py CHANGED
@@ -40,7 +40,7 @@ class ListVocabularyController():
40
  return controller_error("índice inválido")
41
 
42
  if not vocabularies_in_page.object_list:
43
- return controller_error("Sin registros de Participaciones")
44
 
45
  current_page = vocabularies_in_page.number
46
  is_last_page = not current_page < paginator.num_pages
 
40
  return controller_error("índice inválido")
41
 
42
  if not vocabularies_in_page.object_list:
43
+ return controller_error("Sin registros de Vocabularios")
44
 
45
  current_page = vocabularies_in_page.number
46
  is_last_page = not current_page < paginator.num_pages
tecnicas/controllers/views_controller/vocabulary_manage/view_vocabulary_controller.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from django.shortcuts import render
2
+ from django.http import HttpRequest
3
+ from tecnicas.models import Vocabulario
4
+
5
+
6
+ class ViewVocabularyController():
7
+ context = {}
8
+ current_url = "tecnicas/manage_vocabulary/view-vocabulary.html"
9
+
10
+ def __init__(self):
11
+ self.context = {}
12
+
13
+ def controllGet(self, request: HttpRequest, nombre_vocabulario: str):
14
+ try:
15
+ vocabulary = Vocabulario.objects.get(
16
+ nombre_vocabulario=nombre_vocabulario)
17
+
18
+ self.context = {
19
+ "vocabulary": vocabulary,
20
+ "words": vocabulary.palabras.all().order_by('nombre_palabra')
21
+ }
22
+
23
+ except Vocabulario.DoesNotExist:
24
+ self.context = {
25
+ "error": f"No existe un vocabulario con el nombre '{nombre_vocabulario}'"
26
+ }
27
+
28
+ return render(request, self.current_url, self.context)
tecnicas/forms/catador_form.py CHANGED
@@ -138,8 +138,6 @@ class CatadorForm(forms.Form):
138
  username = cleaned_data.get("nombre_usuario")
139
  is_update = cleaned_data.get("is_update")
140
 
141
- print(username, is_update)
142
-
143
  if not is_update:
144
  if User.objects.filter(username__iexact=username).exists():
145
  raise forms.ValidationError(
 
138
  username = cleaned_data.get("nombre_usuario")
139
  is_update = cleaned_data.get("is_update")
140
 
 
 
141
  if not is_update:
142
  if User.objects.filter(username__iexact=username).exists():
143
  raise forms.ValidationError(
tecnicas/forms/codes_form.py CHANGED
@@ -9,3 +9,11 @@ class CodesForm(forms.Form):
9
  self.fields[f'producto_{index+1}'] = forms.CharField(max_length=3, required=True, min_length=3, initial=code, label=f"codigo {index+1}", widget=forms.TextInput(attrs={
10
  "class": "ct-code bg-surface-ligt p-1 border-b-1 text-center w-full disabled:bg-surface-general uppercase"
11
  }))
 
 
 
 
 
 
 
 
 
9
  self.fields[f'producto_{index+1}'] = forms.CharField(max_length=3, required=True, min_length=3, initial=code, label=f"codigo {index+1}", widget=forms.TextInput(attrs={
10
  "class": "ct-code bg-surface-ligt p-1 border-b-1 text-center w-full disabled:bg-surface-general uppercase"
11
  }))
12
+
13
+ def clean(self):
14
+ cleaned_data = super().clean()
15
+ # Convert all product codes to uppercase
16
+ for field_name, value in cleaned_data.items():
17
+ if field_name.startswith('producto_') and value:
18
+ cleaned_data[field_name] = value.upper()
19
+ return cleaned_data
tecnicas/static/img/words.webp ADDED
tecnicas/static/js/created-vocabulary.js CHANGED
@@ -1,7 +1,7 @@
1
  // **************************************
2
  // Create Vocabulary
3
  // **************************************
4
- async function submitSelectWords(classNanmeForm, update = false) {
5
  const form = document.querySelector(`.${classNanmeForm}`);
6
 
7
  const name_vocabulary = form.querySelector(".cts-name-voca").value;
@@ -20,29 +20,7 @@ async function submitSelectWords(classNanmeForm, update = false) {
20
  wordsInput.name = "words";
21
  wordsInput.value = JSON.stringify(listWordsSelect);
22
 
23
- const [isUpdata, orinalName] = inputIsUpdateVocabulary(update);
24
-
25
  form.appendChild(wordsInput);
26
- form.appendChild(isUpdata);
27
- if (orinalName) form.appendChild(orinalName);
28
 
29
  form.submit();
30
  }
31
-
32
- function inputIsUpdateVocabulary(is_update = false) {
33
- const isUpdata = document.createElement("input");
34
- isUpdata.type = "hidden";
35
- isUpdata.name = "is_update";
36
- isUpdata.value = is_update;
37
-
38
- if (is_update) {
39
- const orinalName = document.querySelector(".cts-original-name").textContent;
40
- const inputName = document.createElement("input");
41
- inputName.type = "hidden";
42
- inputName.name = "original_name";
43
- inputName.value = orinalName;
44
- return [isUpdata, inputName];
45
- }
46
-
47
- return [isUpdata, is_update];
48
- }
 
1
  // **************************************
2
  // Create Vocabulary
3
  // **************************************
4
+ async function submitSelectWords(classNanmeForm) {
5
  const form = document.querySelector(`.${classNanmeForm}`);
6
 
7
  const name_vocabulary = form.querySelector(".cts-name-voca").value;
 
20
  wordsInput.name = "words";
21
  wordsInput.value = JSON.stringify(listWordsSelect);
22
 
 
 
23
  form.appendChild(wordsInput);
 
 
24
 
25
  form.submit();
26
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tecnicas/templates/tecnicas/components/item_vocabulary.html CHANGED
@@ -10,9 +10,9 @@
10
  </div>
11
  </div>
12
  <div>
13
- <a href="{% url 'cata_system:crear_vocabulario' %}?name_voca={{vocabulary.nombre_vocabulario}}">
14
  <button class="btn bg-btn-primary border-0 block w-full btn-push">
15
- Revisar Vocabulario
16
  </button>
17
  </a>
18
  </div>
 
10
  </div>
11
  </div>
12
  <div>
13
+ <a href="{% url 'cata_system:ver_vocabulario' nombre_vocabulario=vocabulary.nombre_vocabulario %}">
14
  <button class="btn bg-btn-primary border-0 block w-full btn-push">
15
+ Ver Detalles
16
  </button>
17
  </a>
18
  </div>
tecnicas/templates/tecnicas/components/table-napping-combined.html ADDED
@@ -0,0 +1,174 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {% load static %}
2
+ {% load custom_filters %}
3
+ <article class="space-y-4 text-black">
4
+ <!-- Session B Information -->
5
+ <div class="bg-surface-card p-4 rounded-lg space-y-2">
6
+ <h3 class="font-bold text-lg">Información de la Sesión B</h3>
7
+ <div class="grid grid-cols-2 max-sm:grid-cols-1 gap-2 text-sm">
8
+ <p><span class="font-semibold">Código:</span> {{ session_b.codigo_sesion }}</p>
9
+ <p><span class="font-semibold">Técnica:</span> {{ technique_type }}</p>
10
+ <p><span class="font-semibold">Nombre:</span> {{ session_b.nombre_sesion|default:"Sin nombre" }}</p>
11
+ <p><span class="font-semibold">Catadores:</span> {{ testers|length }}</p>
12
+
13
+ {% if combined_data.vocabulary_info %}
14
+ <p class="col-span-2 max-sm:col-span-1">
15
+ <span class="font-semibold">Vocabulario:</span> {{ combined_data.vocabulary_info.nombre }}
16
+ </p>
17
+ {% endif %}
18
+
19
+ {% if combined_data.scale_info %}
20
+ <p><span class="font-semibold">Escala:</span> {{ combined_data.scale_info.type }}</p>
21
+ <p><span class="font-semibold">Longitud:</span> {{ combined_data.scale_info.size }}</p>
22
+ {% endif %}
23
+
24
+ {% if combined_data.num_repetitions %}
25
+ <p><span class="font-semibold">Repeticiones:</span> {{ combined_data.num_repetitions }}</p>
26
+ {% endif %}
27
+
28
+ <p class="col-span-2 max-sm:col-span-1">
29
+ <span class="font-semibold">Palabras utilizadas:</span>
30
+ {{ combined_data.all_words|join:", " }}
31
+ </p>
32
+ </div>
33
+ </div>
34
+
35
+ <!-- Combined Data Table -->
36
+ <div class="overflow-x-auto rounded-lg border border-surface-general">
37
+ <table id="combined-table-download" class="min-w-max w-full text-sm text-center border-collapse">
38
+ <thead class="bg-surface-sweet font-semibold">
39
+ <tr>
40
+ <th class="py-2 px-3 border border-surface-general">Producto</th>
41
+ {% for tester in testers %}
42
+ <th class="py-2 px-3 border border-surface-general uppercase">
43
+ X{{ forloop.counter }}
44
+ </th>
45
+ <th class="py-2 px-3 border border-surface-general uppercase">
46
+ Y{{ forloop.counter }}
47
+ </th>
48
+ {% endfor %}
49
+ {% for word in combined_data.all_words %}
50
+ <th class="py-2 px-3 border border-surface-general capitalize">
51
+ {{ word }}
52
+ </th>
53
+ {% endfor %}
54
+ </tr>
55
+ </thead>
56
+ <tbody class="bg-surface-ligt divide-y divide-gray-200">
57
+ {% for product, coordinates_tester in coordinates_no_mode.items %}
58
+ <tr>
59
+ <td class="py-2 px-3 border border-surface-general">{{ product }}</td>
60
+ {% for tester in testers %}
61
+ {% with points=coordinates_tester|get_item:tester.user.username %}
62
+ <td class="py-2 px-3 border border-surface-general">
63
+ {{ points.px }}
64
+ </td>
65
+ <td class="py-2 px-3 border border-surface-general">
66
+ {{ points.py }}
67
+ </td>
68
+ {% endwith %}
69
+ {% endfor %}
70
+ {% for word in combined_data.all_words %}
71
+ <td class="py-2 px-3 border border-surface-general">
72
+ {% if combined_data.word_frequencies %}
73
+ {% with freq=combined_data.word_frequencies|get_item:product|get_item:word %}
74
+ {% if freq %}{{ freq }}{% else %}0{% endif %}
75
+ {% endwith %}
76
+ {% elif combined_data.word_averages %}
77
+ {% with avg=combined_data.word_averages|get_item:product|get_item:word %}
78
+ {% if avg %}{{ avg|floatformat:2 }}{% else %}0.00{% endif %}
79
+ {% endwith %}
80
+ {% else %}
81
+ 0
82
+ {% endif %}
83
+ </td>
84
+ {% endfor %}
85
+ </tr>
86
+ {% endfor %}
87
+ </tbody>
88
+ </table>
89
+ </div>
90
+
91
+ <div class="flex justify-end">
92
+ <button id="download-combined-csv-btn" class="cts-btn-general cts-btn-primary btn-push"
93
+ data-session-name="{{ session.nombre_sesion }}_combinado_{{ session_b.codigo_sesion }}"
94
+ data-session-code="{{ session.codigo_sesion }}">
95
+ Descargar datos combinados en CSV
96
+ </button>
97
+ </div>
98
+ </article>
99
+
100
+ <script>
101
+ (function() {
102
+ const btn = document.getElementById("download-combined-csv-btn");
103
+ if (!btn) return;
104
+
105
+ btn.addEventListener("click", function () {
106
+ const table = document.getElementById("combined-table-download");
107
+ if (!table) {
108
+ console.warn("No se encontró la tabla combinada para descargar.");
109
+ return;
110
+ }
111
+
112
+ // helper to trim and normalize cell text
113
+ const cellText = (cell) => {
114
+ if (!cell) return "";
115
+ return String(cell.textContent || "").trim();
116
+ };
117
+
118
+ // Collect headers
119
+ const headers = [];
120
+ const ths = table.querySelectorAll("thead th");
121
+ ths.forEach((th) => headers.push(cellText(th)));
122
+
123
+ // Collect rows
124
+ const rows = [];
125
+ const trs = table.querySelectorAll("tbody tr");
126
+ trs.forEach((tr) => {
127
+ const cols = [];
128
+ const tds = tr.querySelectorAll("td");
129
+ tds.forEach((td) => cols.push(cellText(td)));
130
+ rows.push(cols);
131
+ });
132
+
133
+ // Convert to CSV string (escape quotes, wrap in quotes if needed)
134
+ const escapeValue = (val) => {
135
+ if (val == null) return "";
136
+ const normalVal = val.normalize("NFD").replace(/[\u0300-\u036f]/g, "");
137
+ const needsQuotes = /[",\n,]/.test(normalVal);
138
+ let v = String(normalVal).replace(/"/g, '""');
139
+ if (needsQuotes) v = `"${v}"`;
140
+ return v;
141
+ };
142
+
143
+ const lines = [];
144
+ if (headers.length) lines.push(headers.map(escapeValue).join(","));
145
+ rows.forEach((r) => lines.push(r.map(escapeValue).join(",")));
146
+
147
+ const csvContent = lines.join("\n");
148
+
149
+ // File name: data_{nombre_sesion or codigo_sesion}
150
+ const rawName = (btn.dataset.sessionName || "").trim();
151
+ const code = (btn.dataset.sessionCode || "").trim() || "session";
152
+ const namePart = rawName
153
+ ? rawName.replace(/[^a-zA-Z0-9-_áéíóúÁÉÍÓÚ ]/g, "").replace(/\s+/g, "_")
154
+ : code;
155
+ const fileName = `data_${namePart}.csv`;
156
+
157
+ // Create blob and force download
158
+ const blob = new Blob([csvContent], { type: "text/csv;charset=UTF-8;" });
159
+ if (navigator.msSaveBlob) {
160
+ navigator.msSaveBlob(blob, fileName);
161
+ } else {
162
+ const link = document.createElement("a");
163
+ const url = URL.createObjectURL(blob);
164
+ link.setAttribute("href", url);
165
+ link.setAttribute("download", fileName);
166
+ link.style.visibility = "hidden";
167
+ document.body.appendChild(link);
168
+ link.click();
169
+ document.body.removeChild(link);
170
+ URL.revokeObjectURL(url);
171
+ }
172
+ });
173
+ })();
174
+ </script>
tecnicas/templates/tecnicas/components/table-napping-no-mode.html CHANGED
@@ -38,4 +38,14 @@
38
  </tbody>
39
  </table>
40
  </div>
41
- </article>
 
 
 
 
 
 
 
 
 
 
 
38
  </tbody>
39
  </table>
40
  </div>
41
+
42
+ <div class="flex justify-end">
43
+ <button id="download-csv-btn" class="cts-btn-general cts-btn-primary btn-push"
44
+ data-session-name="{{ session.nombre_sesion }}" data-session-code="{{ session.codigo_sesion }}">
45
+ Descargar datos en CSV
46
+ </button>
47
+ </div>
48
+ </article>
49
+
50
+ {% load static %}
51
+ <script src="{% static 'js/download-table-csv.js' %}"></script>
tecnicas/templates/tecnicas/components/table-napping-puf.html CHANGED
@@ -50,4 +50,14 @@
50
  </tbody>
51
  </table>
52
  </div>
 
 
 
 
 
 
 
53
  </article>
 
 
 
 
50
  </tbody>
51
  </table>
52
  </div>
53
+
54
+ <div class="flex justify-end">
55
+ <button id="download-csv-btn" class="cts-btn-general cts-btn-primary btn-push"
56
+ data-session-name="{{ session.nombre_sesion }}" data-session-code="{{ session.codigo_sesion }}">
57
+ Descargar datos en CSV
58
+ </button>
59
+ </div>
60
  </article>
61
+
62
+ {% load static %}
63
+ <script src="{% static 'js/download-table-csv.js' %}"></script>
tecnicas/templates/tecnicas/components/table-napping-sorting.html CHANGED
@@ -44,4 +44,14 @@
44
  </tbody>
45
  </table>
46
  </div>
 
 
 
 
 
 
 
47
  </article>
 
 
 
 
44
  </tbody>
45
  </table>
46
  </div>
47
+
48
+ <div class="flex justify-end">
49
+ <button id="download-csv-btn" class="cts-btn-general cts-btn-primary btn-push"
50
+ data-session-name="{{ session.nombre_sesion }}" data-session-code="{{ session.codigo_sesion }}">
51
+ Descargar datos en CSV
52
+ </button>
53
+ </div>
54
  </article>
55
+
56
+ {% load static %}
57
+ <script src="{% static 'js/download-table-sort-csv.js' %}"></script>
tecnicas/templates/tecnicas/manage_sesions/details-session-napping.html CHANGED
@@ -203,6 +203,49 @@
203
  {% include "../components/error-message.html" with message='Sin datos por mostrar aún' %}
204
  {% endif %}
205
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
206
 
207
  <form action="" method="post" class="form-action-session hidden">
208
  <input type="hidden" name="action" class="action-option">
 
203
  {% include "../components/error-message.html" with message='Sin datos por mostrar aún' %}
204
  {% endif %}
205
 
206
+ {% if mode == "sin modalidad" and finished %}
207
+ <p class="text-black font-bold text-2xl border-b-2">
208
+ Combinar datos con otra sesión
209
+ </p>
210
+ <article class="space-y-4 text-black bg-surface-card p-4 rounded-2xl">
211
+ <p class="text-lg">
212
+ Puede combinar los datos de esta sesión de Napping con otra sesión que use CATA, RATA o Escalas.
213
+ Ambas sesiones deben tener los mismos productos y catadores
214
+ </p>
215
+
216
+ <form method="post" class="space-y-4">
217
+ {% csrf_token %}
218
+ <input type="hidden" name="action" value="combine_sessions">
219
+
220
+ <div class="flex flex-col gap-2">
221
+ <label for="session_b_code" class="font-semibold">
222
+ Código de la sesión a combinar:
223
+ </label>
224
+ <div class="flex gap-2 max-sm:flex-col">
225
+ <input
226
+ type="text"
227
+ id="session_b_code"
228
+ name="session_b_code"
229
+ class="flex-1 px-4 py-2 border border-surface-general rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500"
230
+ placeholder="Ingrese el código de sesión"
231
+ required
232
+ >
233
+ <button type="submit" class="cts-btn-general cts-btn-primary btn-push">
234
+ Validar y Combinar
235
+ </button>
236
+ </div>
237
+ </div>
238
+ </form>
239
+ </article>
240
+ {% endif %}
241
+
242
+ {% if combined_data %}
243
+ <p class="text-black font-bold text-2xl border-b-2 mt-8">
244
+ Datos Combinados (Napping + {{ session_b_technique_type }})
245
+ </p>
246
+ {% include "../components/table-napping-combined.html" with session=session session_b=session_b technique_type=session_b_technique_type combined_data=combined_data testers=testers coordinates_no_mode=coordinates_no_mode %}
247
+ {% endif %}
248
+
249
 
250
  <form action="" method="post" class="form-action-session hidden">
251
  <input type="hidden" name="action" class="action-option">
tecnicas/templates/tecnicas/manage_vocabulary/create-vocabulary.html CHANGED
@@ -26,15 +26,9 @@
26
  <form action="" method="post" class="cts-craed-vocabulary bg-surface-card p-4 rounded-lg">
27
  {% csrf_token %}
28
  <label for="nombre_vocabulario" class="font-bold text-2xl mb-2 block">Nombre del vocabulario</label>
29
- {% if name_vacabulary %}
30
- <input id="nombre_vocabulario" name="nombre_vocabulario" type="text" required
31
- class="cts-name-voca p-2 px-4 bg-surface-ligt rounded-lg w-full text-lg font-medium"
32
- placeholder="Ingrese un nombre" value="{{ name_vacabulary }}">
33
- {% else %}
34
  <input id="nombre_vocabulario" name="nombre_vocabulario" type="text" required
35
  class="cts-name-voca p-2 px-4 bg-surface-ligt rounded-lg w-full text-lg font-medium"
36
  placeholder="Ingrese un nombre">
37
- {% endif %}
38
  <p class="text-lg mt-2 font-semibold">Debajo puede buscar y seleccionar palabras para asignarlas a
39
  este vocabulario.</p>
40
  </form>
@@ -105,22 +99,11 @@
105
  </p>
106
  </form>
107
 
108
- {% if name_vacabulary %}
109
- <p class="hidden cts-original-name">{{ name_vacabulary }}</p>
110
- {% endif %}
111
-
112
  <article class="flex justify-center gap-4 mt-4">
113
- {% if name_vacabulary %}
114
- <button type="button" name="start" class="cts-btn-general cts-btn-primary btn-push flex-1 w-full"
115
- onclick="submitSelectWords('cts-craed-vocabulary', true)">
116
- Actualizar vocabulario
117
- </button>
118
- {% else %}
119
  <button type="button" name="start" class="cts-btn-general cts-btn-primary btn-push flex-1 w-full"
120
  onclick="submitSelectWords('cts-craed-vocabulary')">
121
  Crear vocabulario
122
  </button>
123
- {% endif %}
124
  <a href="{% url 'cata_system:panel_vocabulario' %}" class="flex-1 w-full">
125
  <button type="button" class="cts-btn-general cts-btn-error btn-push w-full">
126
  Cancelar
 
26
  <form action="" method="post" class="cts-craed-vocabulary bg-surface-card p-4 rounded-lg">
27
  {% csrf_token %}
28
  <label for="nombre_vocabulario" class="font-bold text-2xl mb-2 block">Nombre del vocabulario</label>
 
 
 
 
 
29
  <input id="nombre_vocabulario" name="nombre_vocabulario" type="text" required
30
  class="cts-name-voca p-2 px-4 bg-surface-ligt rounded-lg w-full text-lg font-medium"
31
  placeholder="Ingrese un nombre">
 
32
  <p class="text-lg mt-2 font-semibold">Debajo puede buscar y seleccionar palabras para asignarlas a
33
  este vocabulario.</p>
34
  </form>
 
99
  </p>
100
  </form>
101
 
 
 
 
 
102
  <article class="flex justify-center gap-4 mt-4">
 
 
 
 
 
 
103
  <button type="button" name="start" class="cts-btn-general cts-btn-primary btn-push flex-1 w-full"
104
  onclick="submitSelectWords('cts-craed-vocabulary')">
105
  Crear vocabulario
106
  </button>
 
107
  <a href="{% url 'cata_system:panel_vocabulario' %}" class="flex-1 w-full">
108
  <button type="button" class="cts-btn-general cts-btn-error btn-push w-full">
109
  Cancelar
tecnicas/templates/tecnicas/manage_vocabulary/panel-vocabulary.html CHANGED
@@ -19,7 +19,7 @@
19
  </header>
20
  <section class="flex flex-col gap-7">
21
  <div class="w-full h-40 rounded-lg max-sm:hidden">
22
- <img src="{% static 'img/letters.webp' %}" alt="varias personas en fila"
23
  class="w-full h-full object-cover rounded-xl">
24
  </div>
25
  <a href="{% url 'cata_system:crear_vocabulario' %}" class="flex-1">
@@ -33,7 +33,7 @@
33
  </button>
34
  </a>
35
  <div class="w-full h-40 rounded-lg min-sm:hidden">
36
- <img src="{% static 'img/letters.webp' %}" alt="varias personas en fila"
37
  class="w-full h-full object-cover rounded-xl">
38
  </div>
39
  </section>
 
19
  </header>
20
  <section class="flex flex-col gap-7">
21
  <div class="w-full h-40 rounded-lg max-sm:hidden">
22
+ <img src="{% static 'img/words.webp' %}" alt="varias personas en fila"
23
  class="w-full h-full object-cover rounded-xl">
24
  </div>
25
  <a href="{% url 'cata_system:crear_vocabulario' %}" class="flex-1">
 
33
  </button>
34
  </a>
35
  <div class="w-full h-40 rounded-lg min-sm:hidden">
36
+ <img src="{% static 'img/words.webp' %}" alt="varias personas en fila"
37
  class="w-full h-full object-cover rounded-xl">
38
  </div>
39
  </section>
tecnicas/templates/tecnicas/manage_vocabulary/view-vocabulary.html ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {% extends 'tecnicas/layouts/base.html' %}
2
+ {% load static %}
3
+
4
+ {% block title %}Ver Vocabulario{% endblock %}
5
+
6
+ {% block content %}
7
+ <article class="cts-container-main">
8
+ <article class="cts-wrap-content">
9
+ <header class="text-center flex flex-row max-sm:flex-col gap-8 items-center w-full mb-6">
10
+ <div class="bg-surface-card p-4 text-black shadow-lg rounded-xl flex-1">
11
+ <h1 class="font-bold text-2xl">Detalles del Vocabulario</h1>
12
+ </div>
13
+ <div class="flex-1 flex justify-end items-center">
14
+ <a href="{% url 'cata_system:lista_vocabulario' num_page=1 %}" class="w-fit">
15
+ <button class="cts-btn-general cts-btn-secondary btn-push">
16
+ Volver a la Lista
17
+ </button>
18
+ </a>
19
+ </div>
20
+ </header>
21
+
22
+ {% if error %}
23
+ {% include "../components/error-message.html" with message=error %}
24
+
25
+ <div class="flex justify-center mt-6">
26
+ <a href="{% url 'cata_system:lista_vocabulario' num_page=1 %}">
27
+ <button class="cts-btn-general cts-btn-primary btn-push">
28
+ Ir a Lista de Vocabularios
29
+ </button>
30
+ </a>
31
+ </div>
32
+
33
+ {% else %}
34
+ <section class="bg-surface-card p-6 rounded-lg shadow-lg space-y-6 text-black">
35
+ <!-- Información del Vocabulario -->
36
+ <div class="space-y-4">
37
+ <div class="bg-surface-alter-card p-4 rounded-lg">
38
+ <p class="font-bold text-xl mb-2">Nombre del Vocabulario:</p>
39
+ <p class="text-2xl font-semibold text-btn-primary">{{ vocabulary.nombre_vocabulario }}</p>
40
+ </div>
41
+
42
+ <div class="bg-surface-alter-card p-4 rounded-lg">
43
+ <p class="font-bold text-lg mb-2">Fecha de Creación:</p>
44
+ <p class="text-lg">{{ vocabulary.creado|date:"d/m/Y H:i" }}</p>
45
+ </div>
46
+
47
+ <div class="bg-surface-alter-card p-4 rounded-lg">
48
+ <p class="font-bold text-lg mb-2">Total de Palabras:</p>
49
+ <p class="text-lg">{{ words|length }}</p>
50
+ </div>
51
+ </div>
52
+
53
+ <!-- Lista de Palabras -->
54
+ <div class="mt-6">
55
+ <h2 class="font-bold text-2xl mb-4 text-center">Palabras del Vocabulario</h2>
56
+ <hr class="mb-4">
57
+
58
+ {% if words %}
59
+ <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
60
+ {% for word in words %}
61
+ <div class="bg-gray-200 text-black rounded-lg font-medium text-lg px-4 py-3 text-center shadow">
62
+ {{ word.nombre_palabra }}
63
+ </div>
64
+ {% endfor %}
65
+ </div>
66
+ {% else %}
67
+ <div class="text-center py-8">
68
+ <p class="text-xl text-gray-500">Este vocabulario no tiene palabras asociadas</p>
69
+ </div>
70
+ {% endif %}
71
+ </div>
72
+ </section>
73
+
74
+ <!-- Botón adicional para volver -->
75
+ <div class="flex justify-center mt-6">
76
+ <a href="{% url 'cata_system:lista_vocabulario' num_page=1 %}" class="w-full max-w-md">
77
+ <button class="cts-btn-general cts-btn-error btn-push w-full">
78
+ Volver a la Lista
79
+ </button>
80
+ </a>
81
+ </div>
82
+ {% endif %}
83
+ </article>
84
+ </article>
85
+ {% endblock %}
tecnicas/urls.py CHANGED
@@ -53,6 +53,10 @@ urlpatterns = [
53
  views.createVocabulary,
54
  name="crear_vocabulario"),
55
 
 
 
 
 
56
  path("presenter/lista-vocabulario/<int:num_page>",
57
  views.listVocabulary,
58
  name="lista_vocabulario"),
 
53
  views.createVocabulary,
54
  name="crear_vocabulario"),
55
 
56
+ path("presenter/ver-vocabulario/<str:nombre_vocabulario>",
57
+ views.viewVocabulary,
58
+ name="ver_vocabulario"),
59
+
60
  path("presenter/lista-vocabulario/<int:num_page>",
61
  views.listVocabulary,
62
  name="lista_vocabulario"),
tecnicas/views/__init__.py CHANGED
@@ -20,6 +20,7 @@ from .tester_management.tester_list import testerList
20
 
21
  from .vocabulary_management.vocabulry_menu import vocabularyMenu
22
  from .vocabulary_management.create_vocabulary import createVocabulary
 
23
  from .vocabulary_management.list_vocabulary import listVocabulary
24
 
25
  from .apis.api_tag import newTag
 
20
 
21
  from .vocabulary_management.vocabulry_menu import vocabularyMenu
22
  from .vocabulary_management.create_vocabulary import createVocabulary
23
+ from .vocabulary_management.view_vocabulary import viewVocabulary
24
  from .vocabulary_management.list_vocabulary import listVocabulary
25
 
26
  from .apis.api_tag import newTag
tecnicas/views/vocabulary_management/view_vocabulary.py ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from django.shortcuts import render
2
+ from django.http import HttpRequest
3
+ from tecnicas.controllers import ViewVocabularyController
4
+
5
+
6
+ def viewVocabulary(req: HttpRequest, nombre_vocabulario: str):
7
+ view_controller = ViewVocabularyController()
8
+ if req.method == "GET":
9
+ response = view_controller.controllGet(req, nombre_vocabulario)
10
+ return response
11
+ else:
12
+ context = {"error": "Método no permitido"}
13
+ return render(req, "tecnicas/manage_vocabulary/view-vocabulary.html", context)