Spaces:
Sleeping
Sleeping
Correccion de logica y optimizacion en detalles sesion con sort
Browse files- tecnicas/controllers/views_controller/session_management/details/details_sort_controller.py +16 -13
- tecnicas/controllers/views_controller/sessions_tester/tests_forms/general_test_controller.py +15 -1
- tecnicas/controllers/views_controller/sessions_tester/tests_forms/test_sort_controller.py +2 -1
- tecnicas/static/js/test-sort.js +87 -41
- tecnicas/templates/tecnicas/forms_tester/test_sort.html +103 -13
- tecnicas/templates/tecnicas/manage_sesions/details-session-sort.html +10 -10
- tecnicas/views/tester_forms/pf_test.py +9 -1
- tecnicas/views/tester_forms/sort_test.py +7 -1
tecnicas/controllers/views_controller/session_management/details/details_sort_controller.py
CHANGED
|
@@ -1,5 +1,6 @@
|
|
| 1 |
from .details_controller import DetallesController
|
| 2 |
from tecnicas.models import SesionSensorial, GrupoProducto, Producto, Participacion
|
|
|
|
| 3 |
|
| 4 |
|
| 5 |
class DetallesSortController(DetallesController):
|
|
@@ -42,9 +43,9 @@ class DetallesSortController(DetallesController):
|
|
| 42 |
|
| 43 |
products = Producto.objects.filter(id_tecnica=technique)
|
| 44 |
|
| 45 |
-
groups =
|
| 46 |
tecnica=technique
|
| 47 |
-
)
|
| 48 |
|
| 49 |
if len(groups):
|
| 50 |
self.context["there_data"] = True
|
|
@@ -55,23 +56,25 @@ class DetallesSortController(DetallesController):
|
|
| 55 |
for product in products:
|
| 56 |
product_data = {
|
| 57 |
"codigo_producto": product.codigoProducto,
|
| 58 |
-
"palabras":
|
| 59 |
}
|
| 60 |
|
| 61 |
-
|
|
|
|
|
|
|
| 62 |
|
| 63 |
-
|
| 64 |
-
if product in group.productos.all():
|
| 65 |
-
catador_username = group.catador.user.username
|
| 66 |
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
words_group.add(word.nombre_palabra)
|
| 70 |
|
| 71 |
-
|
| 72 |
-
|
| 73 |
|
| 74 |
-
product_data["palabras"] =
|
|
|
|
|
|
|
|
|
|
| 75 |
|
| 76 |
data.append(product_data)
|
| 77 |
|
|
|
|
| 1 |
from .details_controller import DetallesController
|
| 2 |
from tecnicas.models import SesionSensorial, GrupoProducto, Producto, Participacion
|
| 3 |
+
from collections import defaultdict
|
| 4 |
|
| 5 |
|
| 6 |
class DetallesSortController(DetallesController):
|
|
|
|
| 43 |
|
| 44 |
products = Producto.objects.filter(id_tecnica=technique)
|
| 45 |
|
| 46 |
+
groups = GrupoProducto.objects.select_related("catador").filter(
|
| 47 |
tecnica=technique
|
| 48 |
+
)
|
| 49 |
|
| 50 |
if len(groups):
|
| 51 |
self.context["there_data"] = True
|
|
|
|
| 56 |
for product in products:
|
| 57 |
product_data = {
|
| 58 |
"codigo_producto": product.codigoProducto,
|
| 59 |
+
"palabras": {}
|
| 60 |
}
|
| 61 |
|
| 62 |
+
related_groups = groups.filter(productos=product).select_related(
|
| 63 |
+
"catador__user"
|
| 64 |
+
).prefetch_related("palabras")
|
| 65 |
|
| 66 |
+
data_words = defaultdict(set)
|
|
|
|
|
|
|
| 67 |
|
| 68 |
+
for group in related_groups:
|
| 69 |
+
catador_username = group.catador.user.username
|
|
|
|
| 70 |
|
| 71 |
+
for word in group.palabras.all():
|
| 72 |
+
data_words[catador_username].add(word.nombre_palabra)
|
| 73 |
|
| 74 |
+
product_data["palabras"] = {
|
| 75 |
+
username: list(words)
|
| 76 |
+
for username, words in data_words.items()
|
| 77 |
+
}
|
| 78 |
|
| 79 |
data.append(product_data)
|
| 80 |
|
tecnicas/controllers/views_controller/sessions_tester/tests_forms/general_test_controller.py
CHANGED
|
@@ -1,7 +1,8 @@
|
|
| 1 |
from django.http import HttpRequest
|
| 2 |
from django.shortcuts import redirect, render
|
| 3 |
from django.urls import reverse
|
| 4 |
-
from tecnicas.models import SesionSensorial, Catador
|
|
|
|
| 5 |
|
| 6 |
|
| 7 |
class GenetalTestController():
|
|
@@ -12,3 +13,16 @@ class GenetalTestController():
|
|
| 12 |
def __init__(self, sensorial_session: SesionSensorial, user_tester: Catador):
|
| 13 |
self.tester = user_tester
|
| 14 |
self.session = sensorial_session
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
from django.http import HttpRequest
|
| 2 |
from django.shortcuts import redirect, render
|
| 3 |
from django.urls import reverse
|
| 4 |
+
from tecnicas.models import SesionSensorial, Catador, Participacion
|
| 5 |
+
from tecnicas.controllers import ParticipacionController
|
| 6 |
|
| 7 |
|
| 8 |
class GenetalTestController():
|
|
|
|
| 13 |
def __init__(self, sensorial_session: SesionSensorial, user_tester: Catador):
|
| 14 |
self.tester = user_tester
|
| 15 |
self.session = sensorial_session
|
| 16 |
+
|
| 17 |
+
def controllPost(self, request: HttpRequest):
|
| 18 |
+
action = request.POST["action"]
|
| 19 |
+
|
| 20 |
+
if action == "finish_session":
|
| 21 |
+
self.participation = Participacion.objects.get(
|
| 22 |
+
tecnica=self.session.tecnica, catador=request.user.user_catador)
|
| 23 |
+
ParticipacionController.finishSession(self.participation)
|
| 24 |
+
params = {"code_sesion": self.session.codigo_sesion}
|
| 25 |
+
return redirect(reverse(self.previus_directory, kwargs=params))
|
| 26 |
+
|
| 27 |
+
else:
|
| 28 |
+
return self.controllGet(request, error="Acción no permitida")
|
tecnicas/controllers/views_controller/sessions_tester/tests_forms/test_sort_controller.py
CHANGED
|
@@ -40,10 +40,11 @@ class TestSortController(GenetalTestController):
|
|
| 40 |
self.context["products"] = products_in_technique
|
| 41 |
|
| 42 |
grups_products = GrupoProducto.objects.filter(
|
| 43 |
-
tecnica=technique, catador=request.user.user_catador)
|
| 44 |
|
| 45 |
self.context["grups_products"] = grups_products if grups_products else []
|
| 46 |
|
| 47 |
self.context["form_word"] = ListWordsForm()
|
| 48 |
|
| 49 |
return render(request, self.current_directory, self.context)
|
|
|
|
|
|
| 40 |
self.context["products"] = products_in_technique
|
| 41 |
|
| 42 |
grups_products = GrupoProducto.objects.filter(
|
| 43 |
+
tecnica=technique, catador=request.user.user_catador).select_related("productos", "palabras")
|
| 44 |
|
| 45 |
self.context["grups_products"] = grups_products if grups_products else []
|
| 46 |
|
| 47 |
self.context["form_word"] = ListWordsForm()
|
| 48 |
|
| 49 |
return render(request, self.current_directory, self.context)
|
| 50 |
+
|
tecnicas/static/js/test-sort.js
CHANGED
|
@@ -18,14 +18,6 @@ const DATA_GRUPS = {};
|
|
| 18 |
products.forEach(manageDragables);
|
| 19 |
zonesDrop.forEach(manageDropZone);
|
| 20 |
|
| 21 |
-
document
|
| 22 |
-
.getElementById("question-save")
|
| 23 |
-
.addEventListener("click", showOptionsSave);
|
| 24 |
-
|
| 25 |
-
document
|
| 26 |
-
.getElementById("cancel-save")
|
| 27 |
-
.addEventListener("click", showQuestionSave);
|
| 28 |
-
|
| 29 |
|
| 30 |
/*
|
| 31 |
////
|
|
@@ -205,6 +197,14 @@ function manageDropZone(zone) {
|
|
| 205 |
// Add listeners to elements options and WordForm for the list words
|
| 206 |
addListenersButtonQuestionGrup(zone.parentNode)
|
| 207 |
manageFormWord(parentZone.querySelector("form"), parentZone.querySelector(".words-container"), idZone)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 208 |
}
|
| 209 |
|
| 210 |
/*
|
|
@@ -293,6 +293,10 @@ function removeGrup(grup) {
|
|
| 293 |
function removeWord(code, wordName) {
|
| 294 |
const newWords = DATA_GRUPS[code].words.filter(word => word != wordName)
|
| 295 |
DATA_GRUPS[code].words = newWords
|
|
|
|
|
|
|
|
|
|
|
|
|
| 296 |
}
|
| 297 |
|
| 298 |
function removeProduct(codeProduct, codeZone) {
|
|
@@ -300,6 +304,35 @@ function removeProduct(codeProduct, codeZone) {
|
|
| 300 |
DATA_GRUPS[codeZone].products = newProducts
|
| 301 |
}
|
| 302 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 303 |
/**
|
| 304 |
*
|
| 305 |
* @param {HTMLElement} grupContainer
|
|
@@ -307,12 +340,12 @@ function removeProduct(codeProduct, codeZone) {
|
|
| 307 |
function addListenersButtonQuestionGrup(grupContainer) {
|
| 308 |
// Function hidden question
|
| 309 |
grupContainer.querySelector(".cts-question").addEventListener("click", (event) => {
|
| 310 |
-
|
| 311 |
})
|
| 312 |
|
| 313 |
// Function cancel remove
|
| 314 |
grupContainer.querySelector(".cts-no-remove").addEventListener("click", (event) => {
|
| 315 |
-
|
| 316 |
})
|
| 317 |
|
| 318 |
// Function remove grup
|
|
@@ -321,12 +354,20 @@ function addListenersButtonQuestionGrup(grupContainer) {
|
|
| 321 |
})
|
| 322 |
}
|
| 323 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 324 |
/**
|
| 325 |
*
|
| 326 |
* @param {HTMLDivElement} container
|
| 327 |
* @param {boolean} hiddenQuestion
|
| 328 |
*/
|
| 329 |
-
function
|
| 330 |
const question = container.querySelector(".cts-question")
|
| 331 |
const remove = container.querySelector(".cts-remove")
|
| 332 |
const noRemove = container.querySelector(".cts-no-remove")
|
|
@@ -351,45 +392,23 @@ function generateSimpleID() {
|
|
| 351 |
|
| 352 |
function showOptionsSave() {
|
| 353 |
document.getElementById("question-save").classList.add("hidden");
|
| 354 |
-
document.getElementById("
|
| 355 |
document.getElementById("cancel-save").classList.remove("hidden");
|
| 356 |
}
|
| 357 |
|
| 358 |
function showQuestionSave() {
|
| 359 |
document.getElementById("question-save").classList.remove("hidden");
|
| 360 |
-
document.getElementById("
|
| 361 |
document.getElementById("cancel-save").classList.add("hidden");
|
| 362 |
}
|
| 363 |
|
| 364 |
-
|
| 365 |
-
|
| 366 |
-
|
| 367 |
-
|
| 368 |
-
const btn = document.createElement("button");
|
| 369 |
-
btn.setAttribute("data-code", code);
|
| 370 |
-
btn.setAttribute("data-word", wordName);
|
| 371 |
-
btn.classList.add(...STYLES_BTN.split(" "));
|
| 372 |
-
btn.textContent = "➖";
|
| 373 |
-
|
| 374 |
-
const span = document.createElement("span");
|
| 375 |
-
span.classList.add("item-word");
|
| 376 |
-
span.textContent = wordName;
|
| 377 |
-
|
| 378 |
-
const div = document.createElement("div");
|
| 379 |
-
div.setAttribute("id", `word-${code}-${wordName}`);
|
| 380 |
-
div.classList.add(...STYLES_DIV.split(" "));
|
| 381 |
-
|
| 382 |
-
div.appendChild(span);
|
| 383 |
-
div.appendChild(btn);
|
| 384 |
-
|
| 385 |
-
btn.addEventListener("click", (e) => {
|
| 386 |
-
removeWord(code, wordName)
|
| 387 |
-
div.remove()
|
| 388 |
-
})
|
| 389 |
-
|
| 390 |
-
return div;
|
| 391 |
-
};
|
| 392 |
|
|
|
|
|
|
|
|
|
|
| 393 |
|
| 394 |
/*
|
| 395 |
////
|
|
@@ -505,4 +524,31 @@ function symmetricDifference(setA, setB) {
|
|
| 505 |
}
|
| 506 |
}
|
| 507 |
return _difference;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 508 |
}
|
|
|
|
| 18 |
products.forEach(manageDragables);
|
| 19 |
zonesDrop.forEach(manageDropZone);
|
| 20 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
|
| 22 |
/*
|
| 23 |
////
|
|
|
|
| 197 |
// Add listeners to elements options and WordForm for the list words
|
| 198 |
addListenersButtonQuestionGrup(zone.parentNode)
|
| 199 |
manageFormWord(parentZone.querySelector("form"), parentZone.querySelector(".words-container"), idZone)
|
| 200 |
+
|
| 201 |
+
if (DATA_GRUPS[idZone].words.length) {
|
| 202 |
+
parentZone.querySelector(".words-container").innerHTML = "";
|
| 203 |
+
DATA_GRUPS[idZone].words.forEach((word) => {
|
| 204 |
+
const itemWord = getItemWord(word, idZone);
|
| 205 |
+
parentZone.querySelector(".words-container").appendChild(itemWord);
|
| 206 |
+
})
|
| 207 |
+
}
|
| 208 |
}
|
| 209 |
|
| 210 |
/*
|
|
|
|
| 293 |
function removeWord(code, wordName) {
|
| 294 |
const newWords = DATA_GRUPS[code].words.filter(word => word != wordName)
|
| 295 |
DATA_GRUPS[code].words = newWords
|
| 296 |
+
if (!newWords.length) {
|
| 297 |
+
const containerWords = document.getElementById(code).parentNode.querySelector(".words-container")
|
| 298 |
+
containerWords.innerHTML = wordsPlaceHolder;
|
| 299 |
+
}
|
| 300 |
}
|
| 301 |
|
| 302 |
function removeProduct(codeProduct, codeZone) {
|
|
|
|
| 304 |
DATA_GRUPS[codeZone].products = newProducts
|
| 305 |
}
|
| 306 |
|
| 307 |
+
function getItemWord(wordName, code) {
|
| 308 |
+
const STYLES_DIV = "cts-item-words bg-surface-ligt text-black rounded font-bold text-lg p-1 flex flex-wrap flex-row flex-1 min-w-fit justify-center items-center gap-3";
|
| 309 |
+
const STYLES_BTN = "cts-remove-word cts-btn-general-compress px-2 cts-btn-error"
|
| 310 |
+
|
| 311 |
+
const btn = document.createElement("button");
|
| 312 |
+
btn.setAttribute("data-code", code);
|
| 313 |
+
btn.setAttribute("data-word", wordName);
|
| 314 |
+
btn.classList.add(...STYLES_BTN.split(" "));
|
| 315 |
+
btn.textContent = "➖";
|
| 316 |
+
|
| 317 |
+
const span = document.createElement("span");
|
| 318 |
+
span.classList.add("item-word");
|
| 319 |
+
span.textContent = wordName;
|
| 320 |
+
|
| 321 |
+
const div = document.createElement("div");
|
| 322 |
+
div.setAttribute("id", `word-${code}-${wordName}`);
|
| 323 |
+
div.classList.add(...STYLES_DIV.split(" "));
|
| 324 |
+
|
| 325 |
+
div.appendChild(span);
|
| 326 |
+
div.appendChild(btn);
|
| 327 |
+
|
| 328 |
+
btn.addEventListener("click", (e) => {
|
| 329 |
+
removeWord(code, wordName)
|
| 330 |
+
div.remove()
|
| 331 |
+
})
|
| 332 |
+
|
| 333 |
+
return div;
|
| 334 |
+
};
|
| 335 |
+
|
| 336 |
/**
|
| 337 |
*
|
| 338 |
* @param {HTMLElement} grupContainer
|
|
|
|
| 340 |
function addListenersButtonQuestionGrup(grupContainer) {
|
| 341 |
// Function hidden question
|
| 342 |
grupContainer.querySelector(".cts-question").addEventListener("click", (event) => {
|
| 343 |
+
hiddenQuestionRemoveGroup(grupContainer)
|
| 344 |
})
|
| 345 |
|
| 346 |
// Function cancel remove
|
| 347 |
grupContainer.querySelector(".cts-no-remove").addEventListener("click", (event) => {
|
| 348 |
+
hiddenQuestionRemoveGroup(grupContainer, false)
|
| 349 |
})
|
| 350 |
|
| 351 |
// Function remove grup
|
|
|
|
| 354 |
})
|
| 355 |
}
|
| 356 |
|
| 357 |
+
/*
|
| 358 |
+
////
|
| 359 |
+
//////
|
| 360 |
+
//////// Management Options Save and remove groups
|
| 361 |
+
//////
|
| 362 |
+
////
|
| 363 |
+
*/
|
| 364 |
+
|
| 365 |
/**
|
| 366 |
*
|
| 367 |
* @param {HTMLDivElement} container
|
| 368 |
* @param {boolean} hiddenQuestion
|
| 369 |
*/
|
| 370 |
+
function hiddenQuestionRemoveGroup(container, hiddenQuestion = true) {
|
| 371 |
const question = container.querySelector(".cts-question")
|
| 372 |
const remove = container.querySelector(".cts-remove")
|
| 373 |
const noRemove = container.querySelector(".cts-no-remove")
|
|
|
|
| 392 |
|
| 393 |
function showOptionsSave() {
|
| 394 |
document.getElementById("question-save").classList.add("hidden");
|
| 395 |
+
document.getElementById("finish-session").classList.remove("hidden");
|
| 396 |
document.getElementById("cancel-save").classList.remove("hidden");
|
| 397 |
}
|
| 398 |
|
| 399 |
function showQuestionSave() {
|
| 400 |
document.getElementById("question-save").classList.remove("hidden");
|
| 401 |
+
document.getElementById("finish-session").classList.add("hidden");
|
| 402 |
document.getElementById("cancel-save").classList.add("hidden");
|
| 403 |
}
|
| 404 |
|
| 405 |
+
document
|
| 406 |
+
.getElementById("question-save")
|
| 407 |
+
.addEventListener("click", showOptionsSave);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 408 |
|
| 409 |
+
document
|
| 410 |
+
.getElementById("cancel-save")
|
| 411 |
+
.addEventListener("click", showQuestionSave);
|
| 412 |
|
| 413 |
/*
|
| 414 |
////
|
|
|
|
| 524 |
}
|
| 525 |
}
|
| 526 |
return _difference;
|
| 527 |
+
}
|
| 528 |
+
|
| 529 |
+
/*
|
| 530 |
+
////
|
| 531 |
+
//////
|
| 532 |
+
//////// Finish session
|
| 533 |
+
//////
|
| 534 |
+
////
|
| 535 |
+
*/
|
| 536 |
+
|
| 537 |
+
document
|
| 538 |
+
.getElementById("finish-session")
|
| 539 |
+
.addEventListener("click", finishSession);
|
| 540 |
+
|
| 541 |
+
async function finishSession() {
|
| 542 |
+
const save = await saveData();
|
| 543 |
+
if (!save) {
|
| 544 |
+
spanNotifaction("Error al guardar los datos")
|
| 545 |
+
return
|
| 546 |
+
};
|
| 547 |
+
|
| 548 |
+
const FORM_ACTION = document.querySelector(".form-actions")
|
| 549 |
+
|
| 550 |
+
const inputAction = FORM_ACTION.querySelector(".action-input");
|
| 551 |
+
FORM_ACTION.action = "";
|
| 552 |
+
inputAction.value = "finish_session";
|
| 553 |
+
FORM_ACTION.submit();
|
| 554 |
}
|
tecnicas/templates/tecnicas/forms_tester/test_sort.html
CHANGED
|
@@ -63,7 +63,9 @@
|
|
| 63 |
</form>
|
| 64 |
|
| 65 |
<article class="container-rating-word p-2 py-6 space-y-6 bg-surface-ligt rounded">
|
| 66 |
-
<!--
|
|
|
|
|
|
|
| 67 |
<h2 class="text-xl font-bold">Productos en la sesión</h2>
|
| 68 |
<div id="items" class="original-products flex gap-4 flex-wrap justify-center"
|
| 69 |
data-original-products="original">
|
|
@@ -76,7 +78,10 @@
|
|
| 76 |
</div>
|
| 77 |
|
| 78 |
<section class="space-y-4">
|
| 79 |
-
<!--
|
|
|
|
|
|
|
|
|
|
| 80 |
<h2 class="text-xl font-bold">Puedes crear los grupos aquí</h2>
|
| 81 |
|
| 82 |
<section class="flex sm:flex-row flex-col items-stretch w-full gap-4">
|
|
@@ -98,8 +103,61 @@
|
|
| 98 |
</article>
|
| 99 |
</section>
|
| 100 |
|
|
|
|
| 101 |
<div id="containers" class="flex gap-4 overflow-x-auto py-4 px-2">
|
| 102 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 103 |
<section class="w-fit space-y-4 border rounded p-2 bg-surface-sweet">
|
| 104 |
<article
|
| 105 |
class="dropzone w-64 min-h-16 bg-surface-alter-card rounded p-2 flex items-center justify-center flex-wrap gap-2">
|
|
@@ -135,24 +193,56 @@
|
|
| 135 |
</button>
|
| 136 |
</article>
|
| 137 |
</section>
|
|
|
|
| 138 |
|
| 139 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 140 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 141 |
</section>
|
| 142 |
|
| 143 |
-
<section class="flex justify-end gap-4">
|
| 144 |
<button id="save-progress" class="cts-btn-general cts-btn-primary btn-push">
|
| 145 |
-
Guardar
|
| 146 |
-
</button>
|
| 147 |
-
<button id="question-save" class="cts-btn-general cts-btn-secondary btn-push">
|
| 148 |
-
¿Finalizar sesión?
|
| 149 |
-
</button>
|
| 150 |
-
<button id="save-data" class="cts-btn-general cts-btn-primary btn-push hidden">
|
| 151 |
-
Finalizar
|
| 152 |
-
</button>
|
| 153 |
-
<button id="cancel-save" class="cts-btn-general cts-btn-error btn-push hidden">
|
| 154 |
-
Cancelar
|
| 155 |
</button>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 156 |
<span id="loading-data-save" class="loading loading-spinner loading-xl text-accent hidden"></span>
|
| 157 |
</section>
|
| 158 |
</article>
|
|
|
|
| 63 |
</form>
|
| 64 |
|
| 65 |
<article class="container-rating-word p-2 py-6 space-y-6 bg-surface-ligt rounded">
|
| 66 |
+
<!--
|
| 67 |
+
Definir toddos los productos
|
| 68 |
+
-->
|
| 69 |
<h2 class="text-xl font-bold">Productos en la sesión</h2>
|
| 70 |
<div id="items" class="original-products flex gap-4 flex-wrap justify-center"
|
| 71 |
data-original-products="original">
|
|
|
|
| 78 |
</div>
|
| 79 |
|
| 80 |
<section class="space-y-4">
|
| 81 |
+
<!--
|
| 82 |
+
Espacio para crear grupos
|
| 83 |
+
-->
|
| 84 |
+
|
| 85 |
<h2 class="text-xl font-bold">Puedes crear los grupos aquí</h2>
|
| 86 |
|
| 87 |
<section class="flex sm:flex-row flex-col items-stretch w-full gap-4">
|
|
|
|
| 103 |
</article>
|
| 104 |
</section>
|
| 105 |
|
| 106 |
+
|
| 107 |
<div id="containers" class="flex gap-4 overflow-x-auto py-4 px-2">
|
| 108 |
|
| 109 |
+
{% if grups_products %}
|
| 110 |
+
{% for group in grups_products %}
|
| 111 |
+
<section class="w-fit space-y-4 border rounded p-2 bg-surface-sweet">
|
| 112 |
+
<article
|
| 113 |
+
class="dropzone w-64 min-h-16 bg-surface-alter-card rounded p-2 flex items-center justify-center flex-wrap gap-2">
|
| 114 |
+
{% for product in group.productos.all %}
|
| 115 |
+
<div class="draggable bg-btn-secondary text-black font-bold px-4 py-2 rounded cursor-grab"
|
| 116 |
+
draggable="true" data-id-product="{{ product.id }}"
|
| 117 |
+
data-code="{{ product.codigoProducto }}">
|
| 118 |
+
{{ product.codigoProducto }}
|
| 119 |
+
</div>
|
| 120 |
+
{% endfor %}
|
| 121 |
+
</article>
|
| 122 |
+
|
| 123 |
+
<form action="" id="form-word" method="post" class="flex items-center gap-2">
|
| 124 |
+
<label for="{{ form_word.nombre_palabra.id_for_label }}">
|
| 125 |
+
{{ form_word.nombre_palabra }}
|
| 126 |
+
</label>
|
| 127 |
+
<button type="submit"
|
| 128 |
+
class="cts-btn-general-compress cts-btn-primary btn-push px-2">➕</button>
|
| 129 |
+
</form>
|
| 130 |
+
|
| 131 |
+
<article
|
| 132 |
+
class="words-container w-64 min-h-16 bg-surface-alter rounded p-2 flex items-center justify-center flex-wrap gap-2">
|
| 133 |
+
{% for word in group.palabras.all %}
|
| 134 |
+
<div
|
| 135 |
+
class="cts-item-words bg-surface-ligt text-black rounded font-bold text-lg p-1 flex flex-wrap flex-row flex-1 min-w-fit justify-center items-center gap-3">
|
| 136 |
+
<span class="item-word">{{ word.nombre_palabra }}</span>
|
| 137 |
+
<button data-word="{{ word.nombre_palabra }}"
|
| 138 |
+
class="cts-remove-word cts-btn-general-compress px-2 cts-btn-error">
|
| 139 |
+
➖
|
| 140 |
+
</button>
|
| 141 |
+
</div>
|
| 142 |
+
{% endfor %}
|
| 143 |
+
|
| 144 |
+
</article>
|
| 145 |
+
|
| 146 |
+
<article class="cts-container-question flex items-center justify-around gap-2">
|
| 147 |
+
<button class="cts-question cts-btn-general-compress flex-1 cts-btn-secondary btn-push">
|
| 148 |
+
¿Remover este grupo?
|
| 149 |
+
</button>
|
| 150 |
+
<button class="cts-remove cts-btn-general-compress flex-1 cts-btn-primary btn-push hidden">
|
| 151 |
+
Remover
|
| 152 |
+
</button>
|
| 153 |
+
<button class="cts-no-remove cts-btn-general-compress flex-1 cts-btn-error btn-push hidden">
|
| 154 |
+
Conservar
|
| 155 |
+
</button>
|
| 156 |
+
</article>
|
| 157 |
+
</section>
|
| 158 |
+
{% endfor %}
|
| 159 |
+
|
| 160 |
+
{% else %}
|
| 161 |
<section class="w-fit space-y-4 border rounded p-2 bg-surface-sweet">
|
| 162 |
<article
|
| 163 |
class="dropzone w-64 min-h-16 bg-surface-alter-card rounded p-2 flex items-center justify-center flex-wrap gap-2">
|
|
|
|
| 193 |
</button>
|
| 194 |
</article>
|
| 195 |
</section>
|
| 196 |
+
{% endif %}
|
| 197 |
|
| 198 |
</div>
|
| 199 |
+
</section>
|
| 200 |
+
|
| 201 |
+
<section role="alert" class="alert alert-info">
|
| 202 |
+
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"
|
| 203 |
+
class="h-6 w-6 shrink-0 stroke-current">
|
| 204 |
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
| 205 |
+
d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"></path>
|
| 206 |
+
</svg>
|
| 207 |
+
<span class="text-lg">
|
| 208 |
+
Para guardar los datos sin finalizar su sesión use el botón
|
| 209 |
+
<b>"Guardar progreso"</b>
|
| 210 |
+
</span>
|
| 211 |
+
</section>
|
| 212 |
|
| 213 |
+
<section role="alert" class="alert alert-warning">
|
| 214 |
+
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6 shrink-0 stroke-current" fill="none"
|
| 215 |
+
viewBox="0 0 24 24">
|
| 216 |
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
| 217 |
+
d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z" />
|
| 218 |
+
</svg>
|
| 219 |
+
<div class="flex-col">
|
| 220 |
+
<span class="text-lg block">
|
| 221 |
+
Si usas el botón <b>“Salir de la sesión”</b> asegúrese de guardar el progreso de lo contrario
|
| 222 |
+
perderás todo lo que no hayas guardado antes
|
| 223 |
+
</span>
|
| 224 |
+
<span class="text-lg block">
|
| 225 |
+
Con el botón <b>“Finalizar la sesión”</b>, se guardan las palabras, sales de la sesión y no
|
| 226 |
+
podrás ingresar otra vez
|
| 227 |
+
</span>
|
| 228 |
+
</div>
|
| 229 |
</section>
|
| 230 |
|
| 231 |
+
<section class="flex justify-end gap-4 max-sm:flex-col">
|
| 232 |
<button id="save-progress" class="cts-btn-general cts-btn-primary btn-push">
|
| 233 |
+
Guardar progreso
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 234 |
</button>
|
| 235 |
+
<div class="flex gap-2">
|
| 236 |
+
<button id="question-save" class="cts-btn-general cts-btn-secondary btn-push flex-1">
|
| 237 |
+
¿Finalizar sesión?
|
| 238 |
+
</button>
|
| 239 |
+
<button id="finish-session" class="cts-btn-general cts-btn-tertiary btn-push hidden flex-1">
|
| 240 |
+
Finalizar
|
| 241 |
+
</button>
|
| 242 |
+
<button id="cancel-save" class="cts-btn-general cts-btn-error btn-push hidden flex-1">
|
| 243 |
+
Cancelar
|
| 244 |
+
</button>
|
| 245 |
+
</div>
|
| 246 |
<span id="loading-data-save" class="loading loading-spinner loading-xl text-accent hidden"></span>
|
| 247 |
</section>
|
| 248 |
</article>
|
tecnicas/templates/tecnicas/manage_sesions/details-session-sort.html
CHANGED
|
@@ -116,6 +116,14 @@
|
|
| 116 |
Acciones disponibles
|
| 117 |
</p>
|
| 118 |
<article class="flex flex-wrap gap-10 max-sm:gap-2">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 119 |
{% if not sesion.activo %}
|
| 120 |
<button
|
| 121 |
class="ct-btn-start-repition flex-1 uppercase text-lg max-sm:text-base tracking-wider p-4 border-b-2 active:border-b-0 active:border-t-2 active:border-green-500 border-green-800 transition-all rounded-xl bg-green-600 text-white font-bold disabled:bg-amber-600 flex flex-col justify-center items-center gap-2"
|
|
@@ -126,14 +134,6 @@
|
|
| 126 |
</figure>
|
| 127 |
</button>
|
| 128 |
{% else %}
|
| 129 |
-
{% if finished %}
|
| 130 |
-
<div
|
| 131 |
-
class="text-2xl font-semibold flex-1 cts-btn-secondary p-4 flex justify-center items-center rounded-lg select-none text-center">
|
| 132 |
-
<p class=" text-black">
|
| 133 |
-
Sesión finalizada
|
| 134 |
-
</p>
|
| 135 |
-
</div>
|
| 136 |
-
{% else %}
|
| 137 |
<a href="{% url 'cata_system:monitor_sesion' session_code=sesion.codigo_sesion %}" class="flex-1 w-fit">
|
| 138 |
<button
|
| 139 |
class="ct-btn-start-repition w-full uppercase text-lg max-sm:text-base tracking-wider p-4 border-b-2 active:border-b-0 active:border-t-2 active:border-orange-500 border-orange-800 transition-all rounded-xl bg-orange-600 text-white font-bold disabled:bg-amber-600 flex flex-col justify-center items-center gap-2">
|
|
@@ -187,9 +187,9 @@
|
|
| 187 |
</p>
|
| 188 |
|
| 189 |
{% if there_data %}
|
| 190 |
-
|
| 191 |
{% else %}
|
| 192 |
-
|
| 193 |
{% endif %}
|
| 194 |
|
| 195 |
<form action="" method="post" class="form-action-session hidden">
|
|
|
|
| 116 |
Acciones disponibles
|
| 117 |
</p>
|
| 118 |
<article class="flex flex-wrap gap-10 max-sm:gap-2">
|
| 119 |
+
{% if finished %}
|
| 120 |
+
<div
|
| 121 |
+
class="text-2xl font-semibold flex-1 cts-btn-secondary p-4 flex justify-center items-center rounded-lg select-none text-center">
|
| 122 |
+
<p class=" text-black">
|
| 123 |
+
Sesión finalizada
|
| 124 |
+
</p>
|
| 125 |
+
</div>
|
| 126 |
+
{% else %}
|
| 127 |
{% if not sesion.activo %}
|
| 128 |
<button
|
| 129 |
class="ct-btn-start-repition flex-1 uppercase text-lg max-sm:text-base tracking-wider p-4 border-b-2 active:border-b-0 active:border-t-2 active:border-green-500 border-green-800 transition-all rounded-xl bg-green-600 text-white font-bold disabled:bg-amber-600 flex flex-col justify-center items-center gap-2"
|
|
|
|
| 134 |
</figure>
|
| 135 |
</button>
|
| 136 |
{% else %}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 137 |
<a href="{% url 'cata_system:monitor_sesion' session_code=sesion.codigo_sesion %}" class="flex-1 w-fit">
|
| 138 |
<button
|
| 139 |
class="ct-btn-start-repition w-full uppercase text-lg max-sm:text-base tracking-wider p-4 border-b-2 active:border-b-0 active:border-t-2 active:border-orange-500 border-orange-800 transition-all rounded-xl bg-orange-600 text-white font-bold disabled:bg-amber-600 flex flex-col justify-center items-center gap-2">
|
|
|
|
| 187 |
</p>
|
| 188 |
|
| 189 |
{% if there_data %}
|
| 190 |
+
{% include "../components/table-sort.html" with data_groups=data_groups %}
|
| 191 |
{% else %}
|
| 192 |
+
{% include "../components/error-message.html" with message='Sin datos por mostrar aún' %}
|
| 193 |
{% endif %}
|
| 194 |
|
| 195 |
<form action="" method="post" class="form-action-session hidden">
|
tecnicas/views/tester_forms/pf_test.py
CHANGED
|
@@ -12,8 +12,16 @@ def pfTest(req: HttpRequest, code_sesion: str):
|
|
| 12 |
sensorial_session=session, user_tester=req.user.user_catador)
|
| 13 |
return controll_view.controllGet(request=req)
|
| 14 |
|
| 15 |
-
|
| 16 |
session = SesionSensorial.objects.get(codigo_sesion=code_sesion)
|
| 17 |
controll_view = TestPFController(
|
| 18 |
sensorial_session=session, user_tester=req.user.user_catador)
|
| 19 |
return controll_view.controllPost(request=req)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
sensorial_session=session, user_tester=req.user.user_catador)
|
| 13 |
return controll_view.controllGet(request=req)
|
| 14 |
|
| 15 |
+
elif req.method == "POST":
|
| 16 |
session = SesionSensorial.objects.get(codigo_sesion=code_sesion)
|
| 17 |
controll_view = TestPFController(
|
| 18 |
sensorial_session=session, user_tester=req.user.user_catador)
|
| 19 |
return controll_view.controllPost(request=req)
|
| 20 |
+
|
| 21 |
+
else:
|
| 22 |
+
return noValidTechnique(
|
| 23 |
+
name_view="cata_system:catador_init_session",
|
| 24 |
+
query_params={
|
| 25 |
+
"error": "Método no valido"
|
| 26 |
+
}
|
| 27 |
+
)
|
tecnicas/views/tester_forms/sort_test.py
CHANGED
|
@@ -12,9 +12,15 @@ def sortTest(req: HttpRequest, code_sesion: str):
|
|
| 12 |
return controll_view.controllGet(request=req)
|
| 13 |
|
| 14 |
elif req.method == "POST":
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
return noValidTechnique(
|
| 16 |
name_view="cata_system:catador_init_session",
|
| 17 |
query_params={
|
| 18 |
"error": "Método no valido"
|
| 19 |
}
|
| 20 |
-
)
|
|
|
|
| 12 |
return controll_view.controllGet(request=req)
|
| 13 |
|
| 14 |
elif req.method == "POST":
|
| 15 |
+
session = SesionSensorial.objects.get(codigo_sesion=code_sesion)
|
| 16 |
+
controll_view = TestSortController(
|
| 17 |
+
sensorial_session=session, user_tester=req.user.user_catador)
|
| 18 |
+
return controll_view.controllPost(request=req)
|
| 19 |
+
|
| 20 |
+
else:
|
| 21 |
return noValidTechnique(
|
| 22 |
name_view="cata_system:catador_init_session",
|
| 23 |
query_params={
|
| 24 |
"error": "Método no valido"
|
| 25 |
}
|
| 26 |
+
)
|