Norberto Montalvo García commited on
Commit
6cb4a21
·
unverified ·
2 Parent(s): 110ecad 1c02f87

Merge pull request #28 from CascoArcilla/HU3

Browse files
Files changed (29) hide show
  1. tecnicas/admin.py +2 -1
  2. tecnicas/controllers/__init__.py +4 -1
  3. tecnicas/controllers/models_controller/palabras_controller.py +7 -8
  4. tecnicas/controllers/views_controller/create_session/panel_create_controller.py +269 -233
  5. tecnicas/controllers/views_controller/create_session/panel_words_controller.py +36 -7
  6. tecnicas/controllers/views_controller/{list_sessions_tester_controller.py → sessions_tester/list_sessions_tester_controller.py} +0 -0
  7. tecnicas/controllers/views_controller/vocabulary_manage/create_vocabulary_controller.py +110 -0
  8. tecnicas/controllers/views_controller/vocabulary_manage/list_vocabulary_controller.py +48 -0
  9. tecnicas/forms/__init__.py +2 -1
  10. tecnicas/forms/vocabulary_select.py +15 -0
  11. tecnicas/migrations/0021_rename_nomre_vocabulario_vocabulario_nombre_vocabulario_and_more.py +30 -0
  12. tecnicas/models/vocabulario.py +7 -4
  13. tecnicas/static/img/letters.webp +0 -0
  14. tecnicas/static/js/choose-vocabulary.js +67 -0
  15. tecnicas/static/js/created-vocabulary.js +48 -0
  16. tecnicas/static/js/panel-words.js +1 -1
  17. tecnicas/templates/tecnicas/components/item_vocabulary.html +20 -0
  18. tecnicas/templates/tecnicas/create_sesion/conf-panel-vocabulary.html +62 -0
  19. tecnicas/templates/tecnicas/main-panel.html +28 -31
  20. tecnicas/templates/tecnicas/manage_vocabulary/create-vocabulary.html +139 -0
  21. tecnicas/templates/tecnicas/manage_vocabulary/list-vocabulary.html +57 -0
  22. tecnicas/templates/tecnicas/manage_vocabulary/panel-vocabulary.html +42 -0
  23. tecnicas/urls.py +18 -2
  24. tecnicas/views/__init__.py +5 -0
  25. tecnicas/views/apis/api_words.py +20 -1
  26. tecnicas/views/sessions_config/configuration_panel_words.py +16 -3
  27. tecnicas/views/vocabulary_management/create_vocabulary.py +19 -0
  28. tecnicas/views/vocabulary_management/list_vocabulary.py +11 -0
  29. tecnicas/views/vocabulary_management/vocabulry_menu.py +4 -0
tecnicas/admin.py CHANGED
@@ -6,7 +6,7 @@ from .models import Catador, Presentador
6
 
7
  from .models import Tecnica, SesionSensorial
8
 
9
- from .models import EsAtributo, Palabra
10
 
11
  from .models import Etiqueta, Escala, EtiquetasEscala
12
 
@@ -31,6 +31,7 @@ admin.site.register(SesionSensorial)
31
 
32
  admin.site.register(EsAtributo)
33
  admin.site.register(Palabra)
 
34
 
35
  admin.site.register(Escala)
36
  admin.site.register(EtiquetasEscala)
 
6
 
7
  from .models import Tecnica, SesionSensorial
8
 
9
+ from .models import EsAtributo, Palabra, Vocabulario
10
 
11
  from .models import Etiqueta, Escala, EtiquetasEscala
12
 
 
31
 
32
  admin.site.register(EsAtributo)
33
  admin.site.register(Palabra)
34
+ admin.site.register(Vocabulario)
35
 
36
  admin.site.register(Escala)
37
  admin.site.register(EtiquetasEscala)
tecnicas/controllers/__init__.py CHANGED
@@ -28,7 +28,10 @@ from .views_controller.session_management.monitor_rata_controller import Monitor
28
  from .views_controller.sessions_tester.login_session_tester_controller import LoginSessionTesterController
29
  from .views_controller.sessions_tester.init_session_tester_controller import InitSessionTesterController
30
  from .views_controller.sessions_tester.convencional_scales_controller import ConvencionalScalesController
 
 
 
 
31
 
32
  from .views_controller.api_rating_controller import ApiRatingController
33
  from .views_controller.tester_list_controller import TesterListController
34
- from .views_controller.list_sessions_tester_controller import ListSessionsTesterController
 
28
  from .views_controller.sessions_tester.login_session_tester_controller import LoginSessionTesterController
29
  from .views_controller.sessions_tester.init_session_tester_controller import InitSessionTesterController
30
  from .views_controller.sessions_tester.convencional_scales_controller import ConvencionalScalesController
31
+ from .views_controller.sessions_tester.list_sessions_tester_controller import ListSessionsTesterController
32
+
33
+ from .views_controller.vocabulary_manage.create_vocabulary_controller import CreateVocabularyController
34
+ from .views_controller.vocabulary_manage.list_vocabulary_controller import ListVocabularyController
35
 
36
  from .views_controller.api_rating_controller import ApiRatingController
37
  from .views_controller.tester_list_controller import TesterListController
 
tecnicas/controllers/models_controller/palabras_controller.py CHANGED
@@ -22,17 +22,16 @@ class PalabrasController():
22
  @staticmethod
23
  def getWordsInTechnique(technique: Tecnica):
24
  if technique.id_estilo.nombre_estilo == "atributos":
25
- es_atribute = EsAtributo.objects.get(id_tecnica=technique)
26
- words = list(es_atribute.palabras.all())
 
27
  return words
28
  elif technique.id_estilo.nombre_estilo == "vocabulario":
29
- try:
30
- palabras = Palabra.objects.filter(
31
- vocabulario__esvocabulario__id_tecnica=technique
32
- )
33
- return list(palabras.distinct()) if palabras.exists() else controller_error("Técnica sin palabras con vocabulario")
34
- except Exception as e:
35
  return controller_error("Técnica sin palabras con vocabulario")
 
36
 
37
  @staticmethod
38
  def getWordsWithoutData(recoreded_data: list[Dato], words: list[Palabra]):
 
22
  @staticmethod
23
  def getWordsInTechnique(technique: Tecnica):
24
  if technique.id_estilo.nombre_estilo == "atributos":
25
+ words = list(technique.tecnica_esatributo.palabras.all())
26
+ if not words:
27
+ return controller_error("Técnica sin palabras")
28
  return words
29
  elif technique.id_estilo.nombre_estilo == "vocabulario":
30
+ words = list(
31
+ technique.tecnica_esvacabulario.id_vocabulario.palabras.all())
32
+ if not words:
 
 
 
33
  return controller_error("Técnica sin palabras con vocabulario")
34
+ return words
35
 
36
  @staticmethod
37
  def getWordsWithoutData(recoreded_data: list[Dato], words: list[Palabra]):
tecnicas/controllers/views_controller/create_session/panel_create_controller.py CHANGED
@@ -2,6 +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.controllers import TecnicaController, EscalaController, ProductosController, OrdenesController, EstiloPalabrasController, PalabrasController, SesionController
6
  from tecnicas.utils import deleteDataSession
7
 
@@ -21,139 +22,155 @@ class PanelCreateController():
21
  if not request.session.get("form_tags") or not request.session.get("form_codes") or not request.session.get("form_words"):
22
  deleteDataSession(request)
23
  return general_error("No se ha especificado información necesaria para la creación de la sesión, por favor, vuelve a intentarlo")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
 
25
- with transaction.atomic():
26
- # ////////////////////////////////////////////////////// #
27
- #
28
- # First step: Create technique and scale with their tags #
29
- #
30
- # ////////////////////////////////////////////////////// #
31
- data_basic = request.session["form_basic"]
32
- controllerTechnique = TecnicaController()
33
- controllerTechnique.setTechniqueFromBasicData(basic=data_basic)
34
- technique = controllerTechnique.saveTechnique()
35
- if not technique:
36
- return general_error("Error al guardar la técnica")
37
-
38
- data_scale = {
39
- "id_scale": data_basic["tipo_escala"],
40
- "size": data_basic["tamano_escala"],
41
- "technique": technique
42
- }
43
-
44
- controllerScale = EscalaController(data=data_scale)
45
-
46
- scale = controllerScale.saveScale()
47
- if isinstance(scale, dict):
48
- return general_error(scale["error"])
49
-
50
- dict_tags = request.session["form_tags"]
51
- saved_related_tags = controllerScale.realteTags(dict_tags)
52
- if "error" in saved_related_tags:
53
- return general_error(saved_related_tags["error"])
54
-
55
- # ////////////////////////////////////////////////////////// #
56
- #
57
- # Second step: Create orders, productos and set the position #
58
- #
59
- # ////////////////////////////////////////////////////////// #
60
- data_codes = request.session["form_codes"]
61
-
62
- list_codes_dict = data_codes["product_codes"]
63
-
64
- codes = []
65
- for product in list_codes_dict:
66
- code = next(iter(product.values()))
67
- codes.append(code)
68
-
69
- controllerProducts = ProductosController(
70
- codes=codes,
71
- technique=technique
72
- )
73
-
74
- controllerProducts.setProductsNoSave()
75
- saved_prodcuts = controllerProducts.saveProducts()
76
- if isinstance(saved_prodcuts, dict):
77
- return general_error(saved_prodcuts["error"])
78
-
79
- raw_sort_codes = data_codes["sort_codes"]
80
- controllerOrdes = OrdenesController(
81
- raw_orders=raw_sort_codes,
82
- list_products=saved_prodcuts,
83
- technique=technique
84
- )
85
-
86
- controllerOrdes.setOrdersToSave()
87
- saved_orders = controllerOrdes.saveOrders()
88
- if isinstance(saved_orders, dict):
89
- return general_error(saved_orders["error"])
90
-
91
- seded_positions = controllerOrdes.setPositions()
92
- if isinstance(seded_positions, dict):
93
- return general_error(seded_positions["error"])
94
-
95
- saved_postions = controllerOrdes.savePositions()
96
- if isinstance(saved_postions, dict):
97
- return general_error(saved_prodcuts["error"])
98
-
99
- # /////////////////////////////////////////////////////// #
100
- #
101
- # Third step: Create relations technique with Words Style #
102
- #
103
- # /////////////////////////////////////////////////////// #
104
- ids_words = request.session["form_words"]
105
- words_controller = PalabrasController(ids=ids_words)
106
-
107
- words_to_use = words_controller.setWords()
108
- if isinstance(words_to_use, dict):
109
- return general_error(words_to_use["error"])
110
-
111
- style_controller = EstiloPalabrasController(
112
- technique=technique, words=words_to_use)
113
-
114
- instace_style = style_controller.createAndSaveInstaceStyle()
115
- if isinstance(instace_style, dict):
116
- return general_error(instace_style["error"])
117
-
118
- words_using = style_controller.relatedWords()
119
- if isinstance(words_using, dict):
120
- return general_error(words_using["error"])
121
-
122
- # //////////////////////////////////////////////////////// #
123
- #
124
- # Fourth step: Create session and relat with the technique #
125
- #
126
- # //////////////////////////////////////////////////////// #
127
- session_controller = SesionController(
128
- name_session=data_basic["nombre_sesion"] if data_basic["nombre_sesion"] != "" else None,
129
- technique=technique,
130
- creator=request.user.user_presentador
131
- )
132
-
133
- setting_session = session_controller.setSession()
134
- if isinstance(setting_session, dict):
135
- return general_error(setting_session["error"])
136
-
137
- saved_session = session_controller.saveSession()
138
- if isinstance(saved_session, dict):
139
- return general_error(saved_session["error"])
140
-
141
- context = {
142
- "message": "sesión creada",
143
- "data": {
144
- "codigo_sesion": saved_session.codigo_sesion,
145
- "nombre_sesion": saved_session.nombre_sesion
146
  }
147
- }
148
 
149
- # ////////////////////////////////// #
150
- #
151
- # Final step: Delete date in session #
152
- #
153
- # ////////////////////////////////// #
154
 
155
- deleteDataSession(request)
156
- return JsonResponse(context)
 
 
157
  else:
158
  return general_error("No se ha establecido acción")
159
 
@@ -163,112 +180,131 @@ class PanelCreateController():
163
  if not request.session.get("form_tags") or not request.session.get("form_codes") or not request.session.get("form_words"):
164
  deleteDataSession(request)
165
  return general_error("No se ha especificado información necesaria para la creación de la sesión, por favor, vuelve a intentarlo")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
166
 
167
- with transaction.atomic():
168
- # ////////////////////////////////////////////////////// #
169
- #
170
- # First step: Create technique and scale with their tags #
171
- #
172
- # ////////////////////////////////////////////////////// #
173
- data_basic = request.session["form_basic"]
174
- data_basic["numero_catadores"] = 0
175
- data_basic["numero_repeticiones"] = 1
176
- controllerTechnique = TecnicaController()
177
- controllerTechnique.setTechniqueFromBasicData(basic=data_basic)
178
- technique = controllerTechnique.saveTechnique()
179
- if not technique:
180
- return general_error("Error al guardar la técnica")
181
-
182
- data_scale = {
183
- "id_scale": data_basic["tipo_escala"],
184
- "size": data_basic["tamano_escala"],
185
- "technique": technique
186
- }
187
-
188
- controllerScale = EscalaController(data=data_scale)
189
-
190
- scale = controllerScale.saveScale()
191
- if isinstance(scale, dict):
192
- return general_error(scale["error"])
193
-
194
- dict_tags = request.session["form_tags"]
195
- saved_related_tags = controllerScale.realteTags(dict_tags)
196
- if "error" in saved_related_tags:
197
- return general_error(saved_related_tags["error"])
198
-
199
- # ////////////////////////////////////////////// #
200
- #
201
- # Second step: Create productos with their codes #
202
- #
203
- # ////////////////////////////////////////////// #
204
- codes = request.session["form_codes"]
205
-
206
- controllerProducts = ProductosController(
207
- codes=codes,
208
- technique=technique
209
- )
210
-
211
- controllerProducts.setProductsNoSave()
212
- saved_prodcuts = controllerProducts.saveProducts()
213
- if isinstance(saved_prodcuts, dict):
214
- return general_error(saved_prodcuts["error"])
215
-
216
- # /////////////////////////////////////////////////////// #
217
- #
218
- # Third step: Create relations technique with Words Style #
219
- #
220
- # /////////////////////////////////////////////////////// #
221
- ids_words = request.session["form_words"]
222
- words_controller = PalabrasController(ids=ids_words)
223
-
224
- words_to_use = words_controller.setWords()
225
- if isinstance(words_to_use, dict):
226
- return general_error(words_to_use["error"])
227
-
228
- style_controller = EstiloPalabrasController(
229
- technique=technique, words=words_to_use)
230
-
231
- instace_style = style_controller.createAndSaveInstaceStyle()
232
- if isinstance(instace_style, dict):
233
- return general_error(instace_style["error"])
234
-
235
- words_using = style_controller.relatedWords()
236
- if isinstance(words_using, dict):
237
- return general_error(words_using["error"])
238
-
239
- # //////////////////////////////////////////////////////// #
240
- #
241
- # Fourth step: Create session and relat with the technique #
242
- #
243
- # //////////////////////////////////////////////////////// #
244
- session_controller = SesionController(
245
- name_session=data_basic["nombre_sesion"] if data_basic["nombre_sesion"] != "" else None,
246
- technique=technique,
247
- creator=request.user.user_presentador
248
- )
249
-
250
- setting_session = session_controller.setSession()
251
- if isinstance(setting_session, dict):
252
- return general_error(setting_session["error"])
253
-
254
- saved_session = session_controller.saveSession()
255
- if isinstance(saved_session, dict):
256
- return general_error(saved_session["error"])
257
-
258
- context = {
259
- "message": "sesión creada",
260
- "data": {
261
- "codigo_sesion": saved_session.codigo_sesion,
262
- "nombre_sesion": saved_session.nombre_sesion
263
  }
264
- }
265
 
266
- # ////////////////////////////////// #
267
- #
268
- # Final step: Delete date en session #
269
- #
270
- # ////////////////////////////////// #
271
- deleteDataSession(request)
272
- return JsonResponse(context)
 
 
 
273
  else:
274
  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 EsVocabulario, Vocabulario
6
  from tecnicas.controllers import TecnicaController, EscalaController, ProductosController, OrdenesController, EstiloPalabrasController, PalabrasController, SesionController
7
  from tecnicas.utils import deleteDataSession
8
 
 
22
  if not request.session.get("form_tags") or not request.session.get("form_codes") or not request.session.get("form_words"):
23
  deleteDataSession(request)
24
  return general_error("No se ha especificado información necesaria para la creación de la sesión, por favor, vuelve a intentarlo")
25
+ try:
26
+ with transaction.atomic():
27
+ # ////////////////////////////////////////////////////// #
28
+ #
29
+ # First step: Create technique and scale with their tags #
30
+ #
31
+ # ////////////////////////////////////////////////////// #
32
+ data_basic = request.session["form_basic"]
33
+ controllerTechnique = TecnicaController()
34
+ controllerTechnique.setTechniqueFromBasicData(
35
+ basic=data_basic)
36
+ technique = controllerTechnique.saveTechnique()
37
+ if not technique:
38
+ raise ValueError("Error al guardar la técnica")
39
+
40
+ data_scale = {
41
+ "id_scale": data_basic["tipo_escala"],
42
+ "size": data_basic["tamano_escala"],
43
+ "technique": technique
44
+ }
45
 
46
+ controllerScale = EscalaController(data=data_scale)
47
+
48
+ scale = controllerScale.saveScale()
49
+ if isinstance(scale, dict):
50
+ raise ValueError(scale["error"])
51
+
52
+ dict_tags = request.session["form_tags"]
53
+ saved_related_tags = controllerScale.realteTags(dict_tags)
54
+ if "error" in saved_related_tags:
55
+ raise ValueError(saved_related_tags["error"])
56
+
57
+ # ////////////////////////////////////////////////////////// #
58
+ #
59
+ # Second step: Create orders, productos and set the position #
60
+ #
61
+ # ////////////////////////////////////////////////////////// #
62
+ data_codes = request.session["form_codes"]
63
+
64
+ list_codes_dict = data_codes["product_codes"]
65
+
66
+ codes = []
67
+ for product in list_codes_dict:
68
+ code = next(iter(product.values()))
69
+ codes.append(code)
70
+
71
+ controllerProducts = ProductosController(
72
+ codes=codes,
73
+ technique=technique
74
+ )
75
+
76
+ controllerProducts.setProductsNoSave()
77
+ saved_prodcuts = controllerProducts.saveProducts()
78
+ if isinstance(saved_prodcuts, dict):
79
+ raise ValueError(saved_prodcuts["error"])
80
+
81
+ raw_sort_codes = data_codes["sort_codes"]
82
+ controllerOrdes = OrdenesController(
83
+ raw_orders=raw_sort_codes,
84
+ list_products=saved_prodcuts,
85
+ technique=technique
86
+ )
87
+
88
+ controllerOrdes.setOrdersToSave()
89
+ saved_orders = controllerOrdes.saveOrders()
90
+ if isinstance(saved_orders, dict):
91
+ raise ValueError(saved_orders["error"])
92
+
93
+ seded_positions = controllerOrdes.setPositions()
94
+ if isinstance(seded_positions, dict):
95
+ raise ValueError(seded_positions["error"])
96
+
97
+ saved_postions = controllerOrdes.savePositions()
98
+ if isinstance(saved_postions, dict):
99
+ raise ValueError(saved_prodcuts["error"])
100
+
101
+ # /////////////////////////////////////////////////////// #
102
+ #
103
+ # Third step: Create relations technique with Words Style #
104
+ #
105
+ # /////////////////////////////////////////////////////// #
106
+ style_words = technique.id_estilo.nombre_estilo
107
+ if style_words == "atributos":
108
+ ids_words = request.session["form_words"]
109
+ words_controller = PalabrasController(ids=ids_words)
110
+
111
+ words_to_use = words_controller.setWords()
112
+ if isinstance(words_to_use, dict):
113
+ raise ValueError(words_to_use["error"])
114
+
115
+ style_controller = EstiloPalabrasController(
116
+ technique=technique, words=words_to_use)
117
+
118
+ instace_style = style_controller.createAndSaveInstaceStyle()
119
+ if isinstance(instace_style, dict):
120
+ raise ValueError(instace_style["error"])
121
+
122
+ words_using = style_controller.relatedWords()
123
+ if isinstance(words_using, dict):
124
+ raise ValueError(words_using["error"])
125
+ elif style_words == "vocabulario":
126
+ name_vocabulary = request.session["form_words"]
127
+ vocabulary = Vocabulario.objects.get(
128
+ nombre_vocabulario=name_vocabulary)
129
+
130
+ es_vocabulary = EsVocabulario.objects.create(
131
+ id_tecnica=technique,
132
+ id_vocabulario=vocabulary
133
+ )
134
+ else:
135
+ raise ValueError("Estilo de palabas no permitido")
136
+
137
+ # //////////////////////////////////////////////////////// #
138
+ #
139
+ # Fourth step: Create session and relat with the technique #
140
+ #
141
+ # //////////////////////////////////////////////////////// #
142
+ session_controller = SesionController(
143
+ name_session=data_basic["nombre_sesion"] if data_basic["nombre_sesion"] != "" else None,
144
+ technique=technique,
145
+ creator=request.user.user_presentador
146
+ )
147
+
148
+ setting_session = session_controller.setSession()
149
+ if isinstance(setting_session, dict):
150
+ raise ValueError(setting_session["error"])
151
+
152
+ saved_session = session_controller.saveSession()
153
+ if isinstance(saved_session, dict):
154
+ raise ValueError(saved_session["error"])
155
+
156
+ context = {
157
+ "message": "sesión creada",
158
+ "data": {
159
+ "codigo_sesion": saved_session.codigo_sesion,
160
+ "nombre_sesion": saved_session.nombre_sesion
161
+ }
 
 
 
 
 
162
  }
 
163
 
164
+ # ////////////////////////////////// #
165
+ #
166
+ # Final step: Delete date in session #
167
+ #
168
+ # ////////////////////////////////// #
169
 
170
+ deleteDataSession(request)
171
+ return JsonResponse(context)
172
+ except ValueError as e:
173
+ return general_error(f"Error: {e}")
174
  else:
175
  return general_error("No se ha establecido acción")
176
 
 
180
  if not request.session.get("form_tags") or not request.session.get("form_codes") or not request.session.get("form_words"):
181
  deleteDataSession(request)
182
  return general_error("No se ha especificado información necesaria para la creación de la sesión, por favor, vuelve a intentarlo")
183
+ try:
184
+ with transaction.atomic():
185
+ # ////////////////////////////////////////////////////// #
186
+ #
187
+ # First step: Create technique and scale with their tags #
188
+ #
189
+ # ////////////////////////////////////////////////////// #
190
+ data_basic = request.session["form_basic"]
191
+ data_basic["numero_catadores"] = 0
192
+ data_basic["numero_repeticiones"] = 1
193
+ controllerTechnique = TecnicaController()
194
+ controllerTechnique.setTechniqueFromBasicData(basic=data_basic)
195
+ technique = controllerTechnique.saveTechnique()
196
+ if not technique:
197
+ raise ValueError("Error al guardar la técnica")
198
+
199
+ data_scale = {
200
+ "id_scale": data_basic["tipo_escala"],
201
+ "size": data_basic["tamano_escala"],
202
+ "technique": technique
203
+ }
204
 
205
+ controllerScale = EscalaController(data=data_scale)
206
+
207
+ scale = controllerScale.saveScale()
208
+ if isinstance(scale, dict):
209
+ raise ValueError(scale["error"])
210
+
211
+ dict_tags = request.session["form_tags"]
212
+ saved_related_tags = controllerScale.realteTags(dict_tags)
213
+ if "error" in saved_related_tags:
214
+ raise ValueError(saved_related_tags["error"])
215
+
216
+ # ////////////////////////////////////////////// #
217
+ #
218
+ # Second step: Create productos with their codes #
219
+ #
220
+ # ////////////////////////////////////////////// #
221
+ codes = request.session["form_codes"]
222
+
223
+ controllerProducts = ProductosController(
224
+ codes=codes,
225
+ technique=technique
226
+ )
227
+
228
+ controllerProducts.setProductsNoSave()
229
+ saved_prodcuts = controllerProducts.saveProducts()
230
+ if isinstance(saved_prodcuts, dict):
231
+ raise ValueError(saved_prodcuts["error"])
232
+
233
+ # /////////////////////////////////////////////////////// #
234
+ #
235
+ # Third step: Create relations technique with Words Style #
236
+ #
237
+ # /////////////////////////////////////////////////////// #
238
+ style_words = technique.id_estilo.nombre_estilo
239
+ if style_words == "atributos":
240
+ ids_words = request.session["form_words"]
241
+ words_controller = PalabrasController(ids=ids_words)
242
+
243
+ words_to_use = words_controller.setWords()
244
+ if isinstance(words_to_use, dict):
245
+ raise ValueError(words_to_use["error"])
246
+
247
+ style_controller = EstiloPalabrasController(
248
+ technique=technique, words=words_to_use)
249
+
250
+ instace_style = style_controller.createAndSaveInstaceStyle()
251
+ if isinstance(instace_style, dict):
252
+ raise ValueError(instace_style["error"])
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:
260
+ vocabulary = Vocabulario.objects.get(
261
+ nombre_vocabulario=name_vocabulary)
262
+ except Vocabulario.DoesNotExist:
263
+ raise ValueError("Vocabulario no encontrado")
264
+
265
+ es_vocabulary = EsVocabulario.objects.create(
266
+ id_tecnica=technique,
267
+ id_vocabulario=vocabulary
268
+ )
269
+ else:
270
+ raise ValueError("Estilo de palabas no permitido")
271
+
272
+ # //////////////////////////////////////////////////////// #
273
+ #
274
+ # Fourth step: Create session and relat with the technique #
275
+ #
276
+ # //////////////////////////////////////////////////////// #
277
+ session_controller = SesionController(
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
+ setting_session = session_controller.setSession()
284
+ if isinstance(setting_session, dict):
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": saved_session.codigo_sesion,
295
+ "nombre_sesion": saved_session.nombre_sesion
296
+ }
 
 
 
 
297
  }
 
298
 
299
+ # ////////////////////////////////// #
300
+ #
301
+ # Final step: Delete date en session #
302
+ #
303
+ # ////////////////////////////////// #
304
+
305
+ deleteDataSession(request)
306
+ return JsonResponse(context)
307
+ except ValueError as e:
308
+ return general_error(f"Error: {e}")
309
  else:
310
  return general_error("No se ha establecido acción")
tecnicas/controllers/views_controller/create_session/panel_words_controller.py CHANGED
@@ -1,5 +1,5 @@
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
@@ -7,27 +7,36 @@ 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
@@ -36,14 +45,34 @@ class PanelWordsController():
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"))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  from django.http import HttpRequest
2
+ from tecnicas.forms import WordForm, VocabularioSelectForm
3
  from django.shortcuts import render, redirect
4
  from django.urls import reverse
5
  from tecnicas.models import Palabra
 
7
 
8
 
9
  class PanelWordsController():
10
+ current_url_escalas_atribute = "tecnicas/create_sesion/configuracion-panel-words.html"
11
+ current_url_escalas_vocabulary = "tecnicas/create_sesion/conf-panel-vocabulary.html"
12
+
13
  def __init__(self):
14
  pass
15
 
16
  @staticmethod
17
+ def controllGetEscalasAtributes(request: HttpRequest):
18
  form = WordForm()
19
  context = {
20
  "form_word": form
21
  }
22
 
23
+ return render(request, PanelWordsController.current_url_escalas_atribute, context)
24
+
25
+ @staticmethod
26
+ def controllGetEscalasVocabulary(request: HttpRequest):
27
+ form = VocabularioSelectForm()
28
+ context = {"form": form}
29
+ return render(request, PanelWordsController.current_url_escalas_vocabulary, context)
30
 
31
  @staticmethod
32
+ def controllPostEscalasAtributes(request: HttpRequest):
33
  form = WordForm()
34
  context = {
35
  "form_word": form
36
  }
37
 
38
  if not request.POST.get("words"):
39
+ return render(request, PanelWordsController.current_url_escalas_atribute, context)
40
 
41
  words = json.loads(request.POST.get("words"))
42
  context["words"] = words
 
45
 
46
  if len(ids_words) != len(set(ids_words)):
47
  context["error"] = "existen palabras duplicadas"
48
+ return render(request, PanelWordsController.current_url_escalas_atribute, context)
49
 
50
  exist_words = Palabra.objects.filter(
51
  id__in=ids_words).count() == len(ids_words)
52
 
53
  if not exist_words:
54
  context["error"] = "algunas palabras no existen"
55
+ return render(request, PanelWordsController.current_url_escalas_atribute, context)
56
 
57
  request.session["form_words"] = ids_words
58
  return redirect(reverse("cata_system:creando_sesion"))
59
+
60
+ @staticmethod
61
+ def controllPostEscalasVocabulary(request: HttpRequest):
62
+ context = {}
63
+ if not request.POST.get("vocabulario"):
64
+ context["form"] = VocabularioSelectForm()
65
+ context["error"] = "No hay un vocabulario seleccionado"
66
+ return render(request, PanelWordsController.current_url_escalas_vocabulary, context)
67
+
68
+ form = VocabularioSelectForm(request.POST)
69
+ vocabulary: int
70
+ if form.is_valid():
71
+ vocabulary = form.cleaned_data["vocabulario"]
72
+ else:
73
+ context["form"] = VocabularioSelectForm()
74
+ context["error"] = "Erro al validar el vocabulario"
75
+ return render(request, PanelWordsController.current_url_escalas_vocabulary, context)
76
+
77
+ request.session["form_words"] = vocabulary.nombre_vocabulario
78
+ return redirect(reverse("cata_system:creando_sesion"))
tecnicas/controllers/views_controller/{list_sessions_tester_controller.py → sessions_tester/list_sessions_tester_controller.py} RENAMED
File without changes
tecnicas/controllers/views_controller/vocabulary_manage/create_vocabulary_controller.py ADDED
@@ -0,0 +1,110 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from django.shortcuts import render
2
+ from django.db import IntegrityError
3
+ from django.http import HttpRequest
4
+ from tecnicas.forms import WordForm
5
+ from tecnicas.models import Vocabulario, Palabra
6
+ import json
7
+
8
+
9
+ class CreateVocabularyController():
10
+ context = {}
11
+ current_url = "tecnicas/manage_vocabulary/create-vocabulary.html"
12
+
13
+ def __init__(self, form_word: WordForm = WordForm(), list_words: list = []):
14
+ self.context["form_word"] = form_word
15
+ self.context["words"] = list_words
16
+
17
+ def controllGet(self, request: HttpRequest):
18
+ self.context = {
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):
32
+ self.context = {
33
+ "form_word": self.context["form_word"],
34
+ "words": self.context["words"],
35
+ }
36
+
37
+ if "nombre_vocabulario" not in request.POST:
38
+ self.context["error"] = "Nombre de vocabulario requerido"
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
tecnicas/controllers/views_controller/vocabulary_manage/list_vocabulary_controller.py ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from django.shortcuts import render
2
+ from django.http import HttpRequest
3
+ from django.core.paginator import Paginator, PageNotAnInteger
4
+ from tecnicas.models import Vocabulario
5
+ from tecnicas.utils import controller_error
6
+
7
+
8
+ class ListVocabularyController():
9
+ current_url = "tecnicas/manage_vocabulary/list-vocabulary.html"
10
+
11
+ def __init__(self):
12
+ pass
13
+
14
+ def controllGet(self, request: HttpRequest, page: int):
15
+ context = {}
16
+
17
+ info_element_page = self.getVocabularys(page)
18
+
19
+ if isinstance(info_element_page, dict):
20
+ context["error"] = info_element_page["error"]
21
+ return render(request, self.current_url, context)
22
+
23
+ (vocabularies_in_page, is_last_page, current_page) = info_element_page
24
+
25
+ context["vocabularies"] = vocabularies_in_page
26
+ context["last_page"] = is_last_page
27
+ context["num_page"] = current_page
28
+
29
+ return render(request, self.current_url, context)
30
+
31
+ def getVocabularys(self, num_page: int):
32
+ elements_by_page = 6
33
+
34
+ queryset = Vocabulario.objects.all().order_by('-creado')
35
+
36
+ paginator = Paginator(queryset, elements_by_page)
37
+ try:
38
+ vocabularies_in_page = paginator.page(num_page)
39
+ except PageNotAnInteger:
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
47
+
48
+ return (vocabularies_in_page, is_last_page, current_page)
tecnicas/forms/__init__.py CHANGED
@@ -3,4 +3,5 @@ from .sesion_tags_form import SesionTagsForm
3
  from .etiqueta_form import EtiquetaForm
4
  from .codes_form import CodesForm
5
  from .catador_form import CatadorForm
6
- from .word_form import WordForm
 
 
3
  from .etiqueta_form import EtiquetaForm
4
  from .codes_form import CodesForm
5
  from .catador_form import CatadorForm
6
+ from .word_form import WordForm
7
+ from .vocabulary_select import VocabularioSelectForm
tecnicas/forms/vocabulary_select.py ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from django import forms
2
+ from tecnicas.models import Vocabulario
3
+
4
+
5
+ class VocabularioSelectForm(forms.Form):
6
+ vocabulario = forms.ModelChoiceField(
7
+ queryset=Vocabulario.objects.all(),
8
+ required=True,
9
+ label="Selecciona un vocabulario",
10
+ empty_label="-- Selecciona uno --",
11
+ widget=forms.Select(attrs={
12
+ "class": "w-full border rounded p-4 bg-surface-sweet",
13
+ "id": "vocabulario"
14
+ })
15
+ )
tecnicas/migrations/0021_rename_nomre_vocabulario_vocabulario_nombre_vocabulario_and_more.py ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Generated by Django 5.2.1 on 2025-11-06 21:46
2
+
3
+ import django.utils.timezone
4
+ import shortuuid.main
5
+ from django.db import migrations, models
6
+
7
+
8
+ class Migration(migrations.Migration):
9
+
10
+ dependencies = [
11
+ ('tecnicas', '0020_remove_catador_apellido_remove_catador_correo_and_more'),
12
+ ]
13
+
14
+ operations = [
15
+ migrations.RenameField(
16
+ model_name='vocabulario',
17
+ old_name='nomre_vocabulario',
18
+ new_name='nombre_vocabulario',
19
+ ),
20
+ migrations.AddField(
21
+ model_name='vocabulario',
22
+ name='creado',
23
+ field=models.DateTimeField(default=django.utils.timezone.now),
24
+ ),
25
+ migrations.AlterField(
26
+ model_name='sesionsensorial',
27
+ name='codigo_sesion',
28
+ field=models.CharField(default=shortuuid.main.ShortUUID.uuid, editable=False, max_length=22, primary_key=True, serialize=False),
29
+ ),
30
+ ]
tecnicas/models/vocabulario.py CHANGED
@@ -1,10 +1,13 @@
1
  from django.db import models
2
-
3
  from .palabra import Palabra
4
 
 
5
  class Vocabulario(models.Model):
6
- nomre_vocabulario = models.CharField(max_length=255, unique=True)
7
- palabras = models.ManyToManyField(Palabra, related_name="vovabulario_palabras")
 
 
8
 
9
  def __str__(self):
10
- return self.nomre_vocabulario
 
1
  from django.db import models
2
+ from django.utils import timezone
3
  from .palabra import Palabra
4
 
5
+
6
  class Vocabulario(models.Model):
7
+ nombre_vocabulario = models.CharField(max_length=255, unique=True)
8
+ palabras = models.ManyToManyField(
9
+ Palabra, related_name="vovabulario_palabras")
10
+ creado = models.DateTimeField(default=timezone.now)
11
 
12
  def __str__(self):
13
+ return self.nombre_vocabulario
tecnicas/static/img/letters.webp ADDED
tecnicas/static/js/choose-vocabulary.js ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ document.addEventListener("DOMContentLoaded", () => {
2
+ const vocabSelect = document.getElementById("vocabulario");
3
+ const wordsList = document.getElementById("palabras-lista");
4
+ const formNextStep = document.getElementById("cts-create-session");
5
+ let vocabularyId = "";
6
+
7
+ vocabSelect.addEventListener("change", async (e) => {
8
+ const vocabId = e.target.value;
9
+ vocabularyId = vocabId;
10
+ console.log(e.target);
11
+ console.log(vocabId);
12
+
13
+ wordsList.innerHTML =
14
+ "<li class='text-gray-500 text-center'>Cargando...</li>";
15
+
16
+ if (!vocabId) {
17
+ wordsList.innerHTML =
18
+ "<li class='text-gray-500 text-center'>Selecciona un vocabulario para ver sus palabras</li>";
19
+ return;
20
+ }
21
+
22
+ url_fetch = `api/vocabulario/${vocabId}/palabras`;
23
+
24
+ try {
25
+ const response = await fetch(url_fetch, { method: "GET" });
26
+ if (!response.ok) throw new Error("Error en la petición");
27
+ const json_response = await response.json();
28
+
29
+ words = json_response.data.words;
30
+
31
+ if (words === 0) {
32
+ wordsList.innerHTML =
33
+ "<li class='text-center text-lg'>No hay palabras asociadas</li>";
34
+ return;
35
+ }
36
+
37
+ wordsList.innerHTML = "";
38
+ words.forEach((p) => {
39
+ const li = document.createElement("li");
40
+ li.textContent = p.nombre_palabra;
41
+ li.className =
42
+ "bg-surface-sweet text-black rounded font-bold text-lg px-4 py-3";
43
+ wordsList.appendChild(li);
44
+ });
45
+ } catch (err) {
46
+ wordsList.innerHTML =
47
+ "<li class='text-red-500 text-center text-lg'>Error al cargar las palabras</li>";
48
+ console.error(err);
49
+ }
50
+ });
51
+
52
+ formNextStep.addEventListener("submit", (e) => {
53
+ if (!vocabularyId) {
54
+ e.preventDefault();
55
+ wordsList.innerHTML =
56
+ "<li class='text-center text-lg'>Seleccione un Vocabulario</li>";
57
+ return;
58
+ }
59
+
60
+ const useVocabulary = document.createElement("input");
61
+ useVocabulary.type = "hidden";
62
+ useVocabulary.name = "vocabulario";
63
+ useVocabulary.value = vocabularyId;
64
+
65
+ formNextStep.appendChild(useVocabulary);
66
+ });
67
+ });
tecnicas/static/js/created-vocabulary.js ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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;
8
+ if (!name_vocabulary || name_vocabulary == "") {
9
+ spanNotificationRed("Se requiere el nombre del vocabulario");
10
+ return;
11
+ }
12
+
13
+ if (listWordsSelect.length === 0) {
14
+ spanNotificationRed("Debe seleccionar al menos una palabra");
15
+ return;
16
+ }
17
+
18
+ const wordsInput = document.createElement("input");
19
+ wordsInput.type = "hidden";
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
+ }
tecnicas/static/js/panel-words.js CHANGED
@@ -28,7 +28,7 @@ async function getWordsByName(e) {
28
  palabra: dataForm.get("search").trim(),
29
  });
30
 
31
- const url = `/cata/api/palabras?${params}`;
32
 
33
  try {
34
  const respone = await fetch(url, {
 
28
  palabra: dataForm.get("search").trim(),
29
  });
30
 
31
+ const url = `api/palabras?${params}`;
32
 
33
  try {
34
  const respone = await fetch(url, {
tecnicas/templates/tecnicas/components/item_vocabulary.html ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div class='card bg-surface-ligt shadow-lg text-black sm:max-w-80 w-full flex justify-center items-center'>
2
+ <div class="card-body flex flex-col justify-between w-full">
3
+ <div class="flex flex-col gap-2">
4
+ <h2 class="text-xl font-bold text-right bg-btn-secondary text-white p-2 rounded">
5
+ {{ vocabulary.nombre_vocabulario }}
6
+ </h2>
7
+ <div class="text-lg bg-surface-alter-card p-2 rounded">
8
+ <p class="font-bold">Creado en:</p>
9
+ <p>{{ vocabulary.creado }}</p>
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>
19
+ </div>
20
+ </div>
tecnicas/templates/tecnicas/create_sesion/conf-panel-vocabulary.html ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {% extends 'tecnicas/layouts/base.html' %}
2
+ {% load static %}
3
+
4
+ {% block content %}
5
+ <article class="cts-container-main">
6
+ <article class="cts-wrap-content text-black lg:w-4xl">
7
+ <h2 class="text-2xl font-bold text-center bg-surface-card p-4 rounded-lg">
8
+ Elegir vocabulario
9
+ </h2>
10
+
11
+ <form method="get" id="form-vocabulario" class="bg-surface-card rounded-lg p-6">
12
+ <label for="{{ form.vocabulario.id_for_label }}"
13
+ class="text-lg w-fit font-medium tracking-wide w-full space-y-4">
14
+ <p class="tracking-normal text-xl font-bold">Seleccione un vocabulario</p>
15
+ {{ form.vocabulario }}
16
+ </label>
17
+ </form>
18
+
19
+ {% if error %}
20
+ {% include "../components/error-message.html" with message=error %}
21
+ {% endif %}
22
+ {% if message %}
23
+ {% include "../components/error-message.html" with message=message %}
24
+ {% endif %}
25
+
26
+ <div id="palabras-container" class="rounded-lg p-3 min-h-24 max-h-64 overflow-y-auto bg-surface-card">
27
+ <h3 class="text-xl font-semibold">Palabras asociadas:</h3>
28
+ <ul id="palabras-lista" class="flex flex-wrap gap-4">
29
+ <li class="text-center text-lg">Selecciona un vocabulario para ver sus palabras</li>
30
+ </ul>
31
+ </div>
32
+
33
+ <section>
34
+ <form action="" method="post" id="cts-create-session" class="flex justify-center mt-4">
35
+ {% csrf_token %}
36
+ <article class="cs-escalas-radio w-full flex flex-col gap-4">
37
+ <section class="flex max-sm:flex-col flex-wrap items-center justify-center gap-4">
38
+ <button type="submit" name="start"
39
+ class="cts-btn-general cts-btn-primary btn-push flex-1 w-full">
40
+ Crear sesión
41
+ </button>
42
+ <a href="{% url 'cata_system:seleccion_tecnica' %}" class="flex-1 w-full">
43
+ <button type="button" class="cts-btn-general cts-btn-secondary btn-push w-full">
44
+ Paso anterior
45
+ </button>
46
+ </a>
47
+ </section>
48
+ <a href="{% url 'cata_system:seleccion_tecnica' %}" class="flex-1 w-full">
49
+ <button type="button" class="cts-btn-general cts-btn-error btn-push w-full">
50
+ Cancelar la creación
51
+ </button>
52
+ </a>
53
+ </article>
54
+ </form>
55
+ </section>
56
+ </article>
57
+ </article>
58
+ {% endblock %}
59
+
60
+ {% block extra_js %}
61
+ <script src="{% static 'js/choose-vocabulary.js' %}"></script>
62
+ {% endblock %}
tecnicas/templates/tecnicas/main-panel.html CHANGED
@@ -6,13 +6,13 @@
6
  {% block content %}
7
  <article class="cts-container-main">
8
  <article class="cts-wrap-content">
9
- <header class="flex flex-col flex-wrap justify-center items-center gap-8">
10
  <section class="bg-surface-card p-8 rounded-md w-full shadow-lg">
11
  <h1 class="text-black text-4xl font-bold text-center max-sm:text-2xl">Panel Principal</h1>
12
  </section>
13
  <section
14
- class="flex flex-wrap justify-center max-sm:gap-4 items-center p-8 w-full bg-surface-card rounded-md shadow-lg">
15
- <section class="flex flex-col text-black flex-1 flex-wrap gap-4">
16
  <fieldset class="fieldset rounded-box border px-3 pb-3 rounded-2xl">
17
  <legend class="text-black fieldset-legend px-1.5">Nombre Presentador</legend>
18
  <p class="text-3xl max-sm:text-2xl font-medium">{{ name }}</p>
@@ -23,9 +23,9 @@
23
  <p class="text-3xl max-sm:text-2xl font-medium">{{ cumple }}</p>
24
  </fieldset>
25
  </section>
26
- <section class="flex-1 flex justify-center">
27
  <button type="button"
28
- class="btn btn-active text-xl tracking-wider font-bold text-black btn-error py-8 px-12 border-b-red-600 btn-push"
29
  onclick="exit_sesion('frm-exit')">
30
  Salir del sistema
31
  </button>
@@ -37,32 +37,29 @@
37
  {% include "./components/error-message.html" with message=error %}
38
  {% endif %}
39
 
40
- <article class="w-full flex flex-col gap-7 items-center min-sm:mt-7 mt-4 bg-surface-card rounded-lg shadow-lg">
41
- <article
42
- class="w-5xl max-lg:w-3xl max-md:w-auto p-8 flex flex-col justify-around items-center gap-4 flex-wrap text-3xl max-sm:text-2xl">
43
- <section class="flex flex-row flex-wrap gap-4 w-full">
44
- <a href="{% url 'cata_system:seleccion_tecnica' %}" class="flex-1 w-full">
45
- <button
46
- class="w-full text-black bg-btn-primary font-medium rounded-xl px-8 py-4 text-center border-b-green-800 btn-push">
47
- Iniciar Sesión <br> Sensorial
48
- </button>
49
- </a>
50
- <a href="{% url 'cata_system:panel_catadores' %}" class="flex-1 w-full">
51
- <button
52
- class="w-full text-black bg-btn-secondary font-medium rounded-xl px-8 py-4 text-center border-b-pink-800 btn-push">
53
- Gestión de <br>catadores
54
- </button>
55
- </a>
56
- </section>
57
-
58
- <section class="flex flex-row flex-wrap gap-4 w-f ull justify-center">
59
- <a href="{% url 'cata_system:panel_sesiones' page=1 %}">
60
- <button
61
- class="text-black bg-btn-tertiary font-medium rounded-xl px-8 py-4 text-center border-b-pink-800 btn-push">
62
- Gestión de sesiones<br>sensoriales
63
- </button>
64
- </a>
65
- </section>
66
  </article>
67
  </article>
68
  </article>
 
6
  {% block content %}
7
  <article class="cts-container-main">
8
  <article class="cts-wrap-content">
9
+ <header class="flex flex-col flex-wrap justify-center items-center space-y-8">
10
  <section class="bg-surface-card p-8 rounded-md w-full shadow-lg">
11
  <h1 class="text-black text-4xl font-bold text-center max-sm:text-2xl">Panel Principal</h1>
12
  </section>
13
  <section
14
+ class="flex max-sm:flex-col flex-wrap justify-center max-sm:gap-4 items-center p-8 w-full bg-surface-card rounded-md shadow-lg">
15
+ <section class="flex flex-col text-black flex-1 flex-wrap gap-4 w-full">
16
  <fieldset class="fieldset rounded-box border px-3 pb-3 rounded-2xl">
17
  <legend class="text-black fieldset-legend px-1.5">Nombre Presentador</legend>
18
  <p class="text-3xl max-sm:text-2xl font-medium">{{ name }}</p>
 
23
  <p class="text-3xl max-sm:text-2xl font-medium">{{ cumple }}</p>
24
  </fieldset>
25
  </section>
26
+ <section class="flex-1 flex justify-center max-sm:w-full">
27
  <button type="button"
28
+ class="text-black cts-btn-general cts-btn-error btn-push max-sm:w-full"
29
  onclick="exit_sesion('frm-exit')">
30
  Salir del sistema
31
  </button>
 
37
  {% include "./components/error-message.html" with message=error %}
38
  {% endif %}
39
 
40
+ <article class="w-full py-6 p-2 sm:p-4 md:p-8 bg-surface-card rounded-lg shadow-lg">
41
+ <article class="grid grid-cols-2 gap-6 w-5xl max-lg:w-3xl max-md:w-auto text-3xl max-sm:text-2xl
42
+ max-md:grid-cols-1 justify-items-center items-start place-items-stretch">
43
+ <a href="{% url 'cata_system:seleccion_tecnica' %}" class="w-full">
44
+ <button class="w-full text-black cts-btn-general cts-btn-tertiary btn-push">
45
+ Iniciar Sesión <br> Sensorial
46
+ </button>
47
+ </a>
48
+ <a href="{% url 'cata_system:panel_catadores' %}" class="w-full">
49
+ <button class="w-full text-black cts-btn-general cts-btn-tertiary btn-push">
50
+ Gestión de <br>catadores
51
+ </button>
52
+ </a>
53
+ <a href="{% url 'cata_system:panel_sesiones' page=1 %}" class="w-full">
54
+ <button class="w-full text-black cts-btn-general cts-btn-tertiary btn-push">
55
+ Gestión de sesiones<br>sensoriales
56
+ </button>
57
+ </a>
58
+ <a href="{% url 'cata_system:panel_vocabulario' %}" class="w-full h-full">
59
+ <button class="w-full h-full text-black cts-btn-general cts-btn-tertiary btn-push">
60
+ Gestión de vocabularios
61
+ </button>
62
+ </a>
 
 
 
63
  </article>
64
  </article>
65
  </article>
tecnicas/templates/tecnicas/manage_vocabulary/create-vocabulary.html ADDED
@@ -0,0 +1,139 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {% extends 'tecnicas/layouts/base.html' %}
2
+ {% load static %}
3
+
4
+ {% block title %}Crear vocabulario{% endblock %}
5
+
6
+ {% block content %}
7
+ <article class="cts-container-main">
8
+ <article
9
+ class="ct-notification-red absolute max-md:fixed bottom-0 mb-4 left-1/2 -translate-x-1/2 bg-red-400 text-white p-2 px-4 rounded-lg text-center font-bold hidden uppercase traking-wide">
10
+ </article>
11
+ <article
12
+ class="ct-notification-green absolute max-md:fixed bottom-0 mb-4 left-1/2 -translate-x-1/2 bg-green-600 text-white p-2 px-4 rounded-lg text-center font-medium hidden uppercase">
13
+ </article>
14
+
15
+ <article class="cts-wrap-content text-black lg:w-4xl space-y-4">
16
+ <h1 class="w-full text-center font-bold text-4xl bg-surface-card py-8 rounded-lg">Crear vocabulario</h1>
17
+
18
+ {% if error %}
19
+ {% include "../components/error-message.html" with message=error %}
20
+ {% endif %}
21
+ {% if message %}
22
+ {% include "../components/error-message.html" with message=message %}
23
+ {% endif %}
24
+
25
+ <article class="rounded-lg space-y-4 w-full">
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>
41
+
42
+ <article class="flex flex-col md:flex-row gap-5 justify-between">
43
+ <section class="flex-3/5 flex flex-col gap-4 min-h-96 max-h-96">
44
+ <form action="" method="get" class="ct-serach-words bg-surface-card p-4 rounded-lg">
45
+ {% csrf_token %}
46
+ <p class="text-lg font-semibold mb-2">
47
+ Dejar en blaco para buscar las primeras 10 palabras
48
+ </p>
49
+ <section class="flex flex-row gap-2">
50
+ <label for="search" class="w-full">
51
+ <input type="text" name="search" id="search" placeholder="Buscar palabra"
52
+ class="p-2 px-4 bg-surface-ligt rounded-lg w-full text-lg font-medium">
53
+ </label>
54
+ <button type="submit"
55
+ class="font-bold rounded-lg text-xl px-3 text-center cts-btn-tertiary btn-push">
56
+ Buscar
57
+ </button>
58
+ </section>
59
+ </form>
60
+ <p class="ct-error-words hidden capitalize bg-red-600 text-center text-2xl p-1.5 rounded">
61
+ error</p>
62
+ <ul class="ct-palabras-encontradas gap-2 grid-cols-2 overflow-y-auto">
63
+ <div class="flex justify-center items-center">
64
+ <img src="{% static 'img/lupa.svg' %}" alt="lupa de busqueda" style="width: 50%;">
65
+ </div>
66
+ </ul>
67
+ </section>
68
+
69
+ <section
70
+ class="flex-1/3 bg-surface-card p-4 rounded-lg text-center min-h-96 max-h-96 flex flex-col overflow-hidden">
71
+ <div>
72
+ <p class="text-xl font-bold pb-3">Lista de palabras</p>
73
+ <hr class="mb-3">
74
+ </div>
75
+ <ul class="ct-palabras-usadas flex flex-col gap-3 overflow-y-auto max-h-full">
76
+ {% if not words %}
77
+ <img src="{% static 'img/list.svg' %}" alt="lista de palabras" class="ct-img-list">
78
+ {% endif %}
79
+ {% for word in words %}
80
+ <li
81
+ class="bg-gray-400 text-black rounded font-bold text-lg px-4 py-3 flex flex-wrap flex-row flex-1 min-w-fit justify-center items-center gap-3">
82
+ <p class="ct-word-received" id="{{ word.id }}">{{ word.nombre_palabra }}</p>
83
+ <button
84
+ class="px-4 border-b-2 active:border-b-0 active:border-t-2 transition-all rounded-xl font-black w-fit capitalize active:border-red-500 border-red-800 bg-red-500">➖</button>
85
+ </li>
86
+ {% endfor %}
87
+ </ul>
88
+ </section>
89
+ </article>
90
+
91
+ <form method="post" action="" class="ct-form-new-word p-4 bg-surface-card rounded-lg">
92
+ {% csrf_token %}
93
+ <p class="mb-2 font-bold text-2xl">¿No encuentras una palabra?</p>
94
+ <section class="flex gap-4 flex-wrap justify-center">
95
+ <label for="{{ form_word.nombre_palabra.id_for_label }}"
96
+ class="font-medium w-fit text-xl flex-1 *:w-full *:h-full">
97
+ {{ form_word.nombre_palabra }}
98
+ </label>
99
+ <button class="cts-btn-general-compress cts-btn-primary btn-push p-2 flex-1" type="submit">
100
+ Crear y agregar a la lista
101
+ </button>
102
+ </section>
103
+ <p class="ct-error-word mb-4 font-bold bg-red-500 text-md capitalize text-center rounded hidden">
104
+ error
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
127
+ </button>
128
+ </a>
129
+ </article>
130
+ </article>
131
+
132
+ </article>
133
+ </article>
134
+ {% endblock %}
135
+
136
+ {% block extra_js %}
137
+ <script src="{% static 'js/panel-words.js' %}"></script>
138
+ <script src="{% static 'js/created-vocabulary.js' %}"></script>
139
+ {% endblock %}
tecnicas/templates/tecnicas/manage_vocabulary/list-vocabulary.html ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {% extends 'tecnicas/layouts/base.html' %}
2
+ {% load static %}
3
+
4
+ {% block title %}Panel Sesiones{% 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">
10
+ <div class="bg-surface-card p-4 text-black shadow-lg rounded-xl flex-1">
11
+ <h1 class="font-bold text-2xl">Revisa los vocabularios existentes</h1>
12
+ </div>
13
+ <div class="flex-1 flex justify-end items-center">
14
+ <a href="{% url 'cata_system:panel_vocabulario' %}" class="w-fit">
15
+ <button class="cts-btn-general cts-btn-error btn-push">
16
+ Panel Vocabulario
17
+ </button>
18
+ </a>
19
+ </div>
20
+ </header>
21
+ {% if message %}
22
+ {% include "../components/error-message.html" with message=message %}
23
+ {% endif %}
24
+
25
+ {% if error %}
26
+ {% include "../components/error-message.html" with message=error %}
27
+
28
+ {% else %}
29
+ <section class="grid grid-cols-3 max-lg:grid-cols-2 max-sm:grid-cols-1 w-full gap-4 justify-center">
30
+ {% for vocabu in vocabularies %}
31
+ {% include "../components/item_vocabulary.html" with vocabulary=vocabu %}
32
+ {% endfor %}
33
+ </section>
34
+
35
+ <section class="flex justify-center items-center gap-2">
36
+ <div class="join space-x-2">
37
+ {% if num_page != 1 %}
38
+ <a href="{% url 'cata_system:panel_sesiones' page=num_page|add:-1 %}" class="w-fit">
39
+ <button class="join-item btn bg-btn-secondary py-1">
40
+ <img class="h-full" src="{% static 'img/less-than.svg' %}" alt="menor que">
41
+ </button>
42
+ </a>
43
+ {% endif %}
44
+ <button class="join-item btn bg-btn-secondary">Page {{ num_page }}</button>
45
+ {% if not last_page %}
46
+ <a href="{% url 'cata_system:panel_sesiones' page=num_page|add:1 %}" class="w-fit">
47
+ <button class="join-item btn bg-btn-secondary py-1">
48
+ <img class="h-full" src="{% static 'img/greater-than.svg' %}" alt="mayor que">
49
+ </button>
50
+ </a>
51
+ {% endif %}
52
+ </div>
53
+ </section>
54
+ {% endif %}
55
+ </article>
56
+ </article>
57
+ {% endblock %}
tecnicas/templates/tecnicas/manage_vocabulary/panel-vocabulary.html ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {% extends 'tecnicas/layouts/base.html' %}
2
+ {% load static %}
3
+
4
+ {% block title %}Gestionar Catadores{% endblock %}
5
+
6
+ {% block content %}
7
+ <article class="cts-container-main">
8
+ <article class="cts-wrap-content">
9
+ <header class="flex gap-4">
10
+ <div class="bg-surface-card p-8 text-2xl text-black font-bold rounded-lg text-center block">
11
+ <h1>Panel de vocabularios</h1>
12
+ </div>
13
+ <a href="{% url 'cata_system:index' %}" class="block flex-1">
14
+ <button
15
+ class="w-full h-full text-black cts-btn-general cts-btn-error btn-push">
16
+ Ir al Panel principal
17
+ </button>
18
+ </a>
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">
26
+ <button class="w-full h-full cts-btn-general cts-btn-primary btn-push">
27
+ ➕ Crear Vocabulario
28
+ </button>
29
+ </a>
30
+ <a href="{% url 'cata_system:lista_vocabulario' num_page=1 %}" class="flex-1">
31
+ <button class="w-full h-full cts-btn-general cts-btn-tertiary btn-push">
32
+ 📋 Ver vocabularios
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>
40
+ </article>
41
+ </article>
42
+ {% endblock %}
tecnicas/urls.py CHANGED
@@ -44,6 +44,18 @@ urlpatterns = [
44
  views.createSession,
45
  name="creando_sesion"),
46
 
 
 
 
 
 
 
 
 
 
 
 
 
47
 
48
  # Gestion de catadores
49
  path("presenter/panel-catadores",
@@ -100,14 +112,18 @@ urlpatterns = [
100
 
101
 
102
  # APIs
103
- path("api/nueva-etiqueta",
104
  views.newTag,
105
  name="nueva_etiqueta"),
106
 
107
- path("api/palabras",
108
  views.words,
109
  name="api_palabras"),
110
 
 
 
 
 
111
  path("testers/api/ratingword",
112
  views.reatingWord,
113
  name="api_rating_word"),
 
44
  views.createSession,
45
  name="creando_sesion"),
46
 
47
+ # Gestion de Vocabularios
48
+ path("presenter/panel-vocabulario",
49
+ views.vocabularyMenu,
50
+ name="panel_vocabulario"),
51
+
52
+ path("presenter/crear-vocabulario",
53
+ views.createVocabulary,
54
+ name="crear_vocabulario"),
55
+
56
+ path("presenter/lista-vocabulario/<int:num_page>",
57
+ views.listVocabulary,
58
+ name="lista_vocabulario"),
59
 
60
  # Gestion de catadores
61
  path("presenter/panel-catadores",
 
112
 
113
 
114
  # APIs
115
+ path("presenter/api/nueva-etiqueta",
116
  views.newTag,
117
  name="nueva_etiqueta"),
118
 
119
+ path("presenter/api/palabras",
120
  views.words,
121
  name="api_palabras"),
122
 
123
+ path("presenter/api/vocabulario/<int:vocab_id>/palabras",
124
+ views.wordsVocabulary,
125
+ name="api_palabras_vocabulary"),
126
+
127
  path("testers/api/ratingword",
128
  views.reatingWord,
129
  name="api_rating_word"),
tecnicas/views/__init__.py CHANGED
@@ -18,8 +18,13 @@ from .tester_management.tester_create import testerCreate
18
  from .tester_management.tester_search import testerSearch
19
  from .tester_management.tester_list import testerList
20
 
 
 
 
 
21
  from .apis.api_tag import newTag
22
  from .apis.api_words import words
 
23
  from .apis.rating_word import reatingWord
24
 
25
  from .tester_forms.init_tester_form import initTesterForm
 
18
  from .tester_management.tester_search import testerSearch
19
  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
26
  from .apis.api_words import words
27
+ from .apis.api_words import wordsVocabulary
28
  from .apis.rating_word import reatingWord
29
 
30
  from .tester_forms.init_tester_form import initTesterForm
tecnicas/views/apis/api_words.py CHANGED
@@ -1,9 +1,10 @@
1
  from django.http import HttpRequest, JsonResponse
2
  from tecnicas.decorators import required_presenter
3
- from tecnicas.models import Palabra
4
  from tecnicas.utils import general_error
5
  from tecnicas.forms.word_form import WordForm
6
 
 
7
  @required_presenter
8
  def words(req: HttpRequest):
9
  if req.method == "GET":
@@ -48,3 +49,21 @@ def words(req: HttpRequest):
48
  else:
49
  errors = form.errors.get("nombre_palabra")
50
  return general_error(errors[0])
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  from django.http import HttpRequest, JsonResponse
2
  from tecnicas.decorators import required_presenter
3
+ from tecnicas.models import Palabra, Vocabulario
4
  from tecnicas.utils import general_error
5
  from tecnicas.forms.word_form import WordForm
6
 
7
+
8
  @required_presenter
9
  def words(req: HttpRequest):
10
  if req.method == "GET":
 
49
  else:
50
  errors = form.errors.get("nombre_palabra")
51
  return general_error(errors[0])
52
+
53
+
54
+ @required_presenter
55
+ def wordsVocabulary(req: HttpRequest, vocab_id: int):
56
+ if req.method == "GET":
57
+ vocabulary = Vocabulario.objects.filter(id=vocab_id).first()
58
+ if not vocabulary:
59
+ return JsonResponse([])
60
+ palabras = vocabulary.palabras.all().values("id", "nombre_palabra")
61
+ response_json = {
62
+ "ok": True,
63
+ "data": {
64
+ "words": list(palabras)
65
+ }
66
+ }
67
+ return JsonResponse(response_json)
68
+ else:
69
+ return JsonResponse({"error": "Este método no es permitido"})
tecnicas/views/sessions_config/configuration_panel_words.py CHANGED
@@ -1,6 +1,7 @@
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
 
@@ -12,18 +13,30 @@ def configurationPanelWords(req: HttpRequest):
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" or basic_data["name_tecnica"] == "rata":
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" or basic_data["name_tecnica"] == "rata":
26
- response = PanelWordsController.controllPostEscalas(req)
 
 
 
 
 
 
27
  else:
28
  response = redirect(
29
  reverse("cata_system:seleccion_tecnica") + "?error=Técnica no valida")
 
1
  from django.http import HttpRequest, JsonResponse
2
  from django.shortcuts import redirect
3
  from django.urls import reverse
4
+ from tecnicas.models import EstiloPalabra
5
  from tecnicas.controllers import PanelWordsController
6
  from tecnicas.utils import deleteDataSession
7
 
 
13
  "?error=datos requeridos no encontrados")
14
 
15
  basic_data = req.session["form_basic"]
16
+ style_words = EstiloPalabra.objects.get(id=basic_data["estilo_palabras"])
17
 
18
  if req.method == "GET":
19
  if basic_data["name_tecnica"] == "escalas" or basic_data["name_tecnica"] == "rata":
20
+ if style_words.nombre_estilo == "atributos":
21
+ response = PanelWordsController.controllGetEscalasAtributes(req)
22
+ elif style_words.nombre_estilo == "vocabulario":
23
+ response = PanelWordsController.controllGetEscalasVocabulary(req)
24
+ else:
25
+ response = redirect(
26
+ reverse("cata_system:seleccion_tecnica") + "?error=Estilo de palabras no valida")
27
  else:
28
  response = redirect(
29
  reverse("cata_system:seleccion_tecnica") + "?error=Técnica no valida")
 
30
  return response
31
  elif req.method == "POST":
32
  if basic_data["name_tecnica"] == "escalas" or basic_data["name_tecnica"] == "rata":
33
+ if style_words.nombre_estilo == "atributos":
34
+ response = PanelWordsController.controllPostEscalasAtributes(req)
35
+ elif style_words.nombre_estilo == "vocabulario":
36
+ response = PanelWordsController.controllPostEscalasVocabulary(req)
37
+ else:
38
+ response = redirect(
39
+ reverse("cata_system:seleccion_tecnica") + "?error=Estilo de palabras no valida")
40
  else:
41
  response = redirect(
42
  reverse("cata_system:seleccion_tecnica") + "?error=Técnica no valida")
tecnicas/views/vocabulary_management/create_vocabulary.py ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from django.shortcuts import render
2
+ from django.http import HttpRequest
3
+ from tecnicas.forms import WordForm
4
+ from tecnicas.controllers import CreateVocabularyController
5
+
6
+
7
+ def createVocabulary(req: HttpRequest):
8
+ view_controller = CreateVocabularyController()
9
+ if req.method == "GET":
10
+ response = view_controller.controllGet(req)
11
+ return response
12
+
13
+ elif req.method == "POST":
14
+ response = view_controller.controllPost(req)
15
+ return response
16
+
17
+ else:
18
+ context = {"error": "Método no permitido"}
19
+ return render(req, "tecnicas/manage_vocabulary/create-vocabulary.html", context)
tecnicas/views/vocabulary_management/list_vocabulary.py ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from django.http import HttpRequest
2
+ from tecnicas.controllers import ListVocabularyController
3
+
4
+
5
+ def listVocabulary(req: HttpRequest, num_page: int):
6
+ controll_view = ListVocabularyController()
7
+ if req.method == "GET":
8
+ response = controll_view.controllGet(req, num_page)
9
+ return response
10
+ else:
11
+ pass
tecnicas/views/vocabulary_management/vocabulry_menu.py ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ from django.shortcuts import render
2
+
3
+ def vocabularyMenu(req):
4
+ return render(req, "tecnicas/manage_vocabulary/panel-vocabulary.html")