Spaces:
Sleeping
Sleeping
Panel basico de configuracion CATA
Browse files- tecnicas/controllers/views_controller/create_session/panel_basic_controller.py +50 -8
- tecnicas/forms/__init__.py +5 -3
- tecnicas/forms/create_session/sesiob_basic_cata_form.py +27 -0
- tecnicas/forms/{sesion_basic_form.py → create_session/sesion_basic_form.py} +1 -3
- tecnicas/forms/{sesion_tags_form.py → create_session/sesion_tags_form.py} +1 -1
- tecnicas/static/js/panel-basic-cata.js +31 -0
- tecnicas/templates/tecnicas/create_sesion/panel-basic-cata.html +85 -0
- tecnicas/views/sessions_config/configuration_panel_basic.py +2 -0
tecnicas/controllers/views_controller/create_session/panel_basic_controller.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
from tecnicas.forms import SesionBasicForm
|
| 2 |
from django.http import HttpRequest
|
| 3 |
from django.shortcuts import redirect, render
|
| 4 |
from django.urls import reverse
|
|
@@ -10,6 +10,14 @@ class PanelBasicController():
|
|
| 10 |
"numero_repeticiones": 1
|
| 11 |
}
|
| 12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
def __init__(self):
|
| 14 |
pass
|
| 15 |
|
|
@@ -23,7 +31,7 @@ class PanelBasicController():
|
|
| 23 |
}
|
| 24 |
|
| 25 |
response = render(
|
| 26 |
-
request,
|
| 27 |
return response
|
| 28 |
|
| 29 |
@staticmethod
|
|
@@ -44,11 +52,11 @@ class PanelBasicController():
|
|
| 44 |
response = redirect(
|
| 45 |
reverse("cata_system:panel_configuracion_tags"))
|
| 46 |
else:
|
| 47 |
-
response = render(request,
|
| 48 |
"form_sesion": form, "error": "Información no valida"})
|
| 49 |
except KeyError:
|
| 50 |
response = redirect(reverse(
|
| 51 |
-
|
| 52 |
|
| 53 |
return response
|
| 54 |
|
|
@@ -63,7 +71,7 @@ class PanelBasicController():
|
|
| 63 |
}
|
| 64 |
|
| 65 |
response = render(
|
| 66 |
-
request,
|
| 67 |
return response
|
| 68 |
|
| 69 |
@staticmethod
|
|
@@ -88,7 +96,7 @@ class PanelBasicController():
|
|
| 88 |
key, f"Valor inválido para '{key}': se esperaba {expected}, se recibió {actual}")
|
| 89 |
|
| 90 |
if form.errors:
|
| 91 |
-
response = render(request,
|
| 92 |
"form_sesion": form, "error": "No puedes modificar el número de catadores o repeticiones"})
|
| 93 |
else:
|
| 94 |
values["name_tecnica"] = name_tecnica
|
|
@@ -96,10 +104,44 @@ class PanelBasicController():
|
|
| 96 |
response = redirect(
|
| 97 |
reverse("cata_system:panel_configuracion_tags"))
|
| 98 |
else:
|
| 99 |
-
response = render(request,
|
| 100 |
"form_sesion": form, "error": "Información no valida"})
|
| 101 |
except KeyError:
|
| 102 |
response = redirect(reverse(
|
| 103 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 104 |
|
| 105 |
return response
|
|
|
|
| 1 |
+
from tecnicas.forms import SesionBasicForm, SesionBasicCATAForm
|
| 2 |
from django.http import HttpRequest
|
| 3 |
from django.shortcuts import redirect, render
|
| 4 |
from django.urls import reverse
|
|
|
|
| 10 |
"numero_repeticiones": 1
|
| 11 |
}
|
| 12 |
|
| 13 |
+
url_panel_basic = "tecnicas/create_sesion/configuracion-panel-basic.html"
|
| 14 |
+
url_panel_basic_cata = "tecnicas/create_sesion/panel-basic-cata.html"
|
| 15 |
+
|
| 16 |
+
url_next_panel_scales = "cata_system:panel_configuracion_tags"
|
| 17 |
+
url_next_panel_cata = "cata_system:panel_configuracion_tags"
|
| 18 |
+
|
| 19 |
+
url_select_technique = "cata_system:seleccion_tecnica"
|
| 20 |
+
|
| 21 |
def __init__(self):
|
| 22 |
pass
|
| 23 |
|
|
|
|
| 31 |
}
|
| 32 |
|
| 33 |
response = render(
|
| 34 |
+
request, PanelBasicController.url_panel_basic, view_context)
|
| 35 |
return response
|
| 36 |
|
| 37 |
@staticmethod
|
|
|
|
| 52 |
response = redirect(
|
| 53 |
reverse("cata_system:panel_configuracion_tags"))
|
| 54 |
else:
|
| 55 |
+
response = render(request, PanelBasicController.url_panel_basic, {
|
| 56 |
"form_sesion": form, "error": "Información no valida"})
|
| 57 |
except KeyError:
|
| 58 |
response = redirect(reverse(
|
| 59 |
+
PanelBasicController.url_select_technique) + "?error=error en datos de configuracion")
|
| 60 |
|
| 61 |
return response
|
| 62 |
|
|
|
|
| 71 |
}
|
| 72 |
|
| 73 |
response = render(
|
| 74 |
+
request, PanelBasicController.url_panel_basic, view_context)
|
| 75 |
return response
|
| 76 |
|
| 77 |
@staticmethod
|
|
|
|
| 96 |
key, f"Valor inválido para '{key}': se esperaba {expected}, se recibió {actual}")
|
| 97 |
|
| 98 |
if form.errors:
|
| 99 |
+
response = render(request, PanelBasicController.url_panel_basic, {
|
| 100 |
"form_sesion": form, "error": "No puedes modificar el número de catadores o repeticiones"})
|
| 101 |
else:
|
| 102 |
values["name_tecnica"] = name_tecnica
|
|
|
|
| 104 |
response = redirect(
|
| 105 |
reverse("cata_system:panel_configuracion_tags"))
|
| 106 |
else:
|
| 107 |
+
response = render(request, PanelBasicController.url_panel_basic, {
|
| 108 |
"form_sesion": form, "error": "Información no valida"})
|
| 109 |
except KeyError:
|
| 110 |
response = redirect(reverse(
|
| 111 |
+
PanelBasicController.url_select_technique) + "?error=error en datos de configuracion")
|
| 112 |
+
|
| 113 |
+
return response
|
| 114 |
+
|
| 115 |
+
@staticmethod
|
| 116 |
+
def controllGetCATA(request: HttpRequest):
|
| 117 |
+
form_sesion = SesionBasicCATAForm()
|
| 118 |
+
|
| 119 |
+
view_context = {
|
| 120 |
+
"form_sesion": form_sesion,
|
| 121 |
+
"use_technique": "cata"
|
| 122 |
+
}
|
| 123 |
+
|
| 124 |
+
return render(
|
| 125 |
+
request, PanelBasicController.url_panel_basic_cata, view_context)
|
| 126 |
+
|
| 127 |
+
@staticmethod
|
| 128 |
+
def controllPostRATA(request: HttpRequest, name_tecnica: str):
|
| 129 |
+
form = SesionBasicCATAForm(request.POST)
|
| 130 |
+
|
| 131 |
+
if form.is_valid():
|
| 132 |
+
values = {}
|
| 133 |
+
for name, value in form.cleaned_data.items():
|
| 134 |
+
if name == "estilo_palabras":
|
| 135 |
+
values[name] = value.id
|
| 136 |
+
else:
|
| 137 |
+
values[name] = value
|
| 138 |
+
|
| 139 |
+
values["name_tecnica"] = name_tecnica
|
| 140 |
+
request.session['form_basic'] = values
|
| 141 |
+
response = redirect(
|
| 142 |
+
reverse(PanelBasicController.url_next_panel_cata))
|
| 143 |
+
else:
|
| 144 |
+
response = render(request, PanelBasicController.url_panel_basic, {
|
| 145 |
+
"form_sesion": form, "error": "Información no valida"})
|
| 146 |
|
| 147 |
return response
|
tecnicas/forms/__init__.py
CHANGED
|
@@ -1,7 +1,9 @@
|
|
| 1 |
-
from .sesion_basic_form import SesionBasicForm
|
| 2 |
-
from .
|
|
|
|
|
|
|
| 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
|
|
|
|
| 1 |
+
from .create_session.sesion_basic_form import SesionBasicForm
|
| 2 |
+
from .create_session.sesiob_basic_cata_form import SesionBasicCATAForm
|
| 3 |
+
from .create_session.sesion_tags_form import SesionTagsForm
|
| 4 |
+
|
| 5 |
from .etiqueta_form import EtiquetaForm
|
| 6 |
from .codes_form import CodesForm
|
| 7 |
from .catador_form import CatadorForm
|
| 8 |
from .word_form import WordForm
|
| 9 |
+
from .vocabulary_select import VocabularioSelectForm
|
tecnicas/forms/create_session/sesiob_basic_cata_form.py
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from django import forms
|
| 2 |
+
from tecnicas.models import EstiloPalabra
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
class SesionBasicCATAForm(forms.Form):
|
| 6 |
+
nombre_sesion = forms.CharField(max_length=255, widget=forms.TextInput(attrs={
|
| 7 |
+
"class": "bg-surface-ligt border-b-1 text-center w-full p-1",
|
| 8 |
+
"name": "nombre_sesion",
|
| 9 |
+
"placeholder": "Ej. Mermelada de mango picante"
|
| 10 |
+
}), required=False)
|
| 11 |
+
|
| 12 |
+
numero_productos = forms.IntegerField(widget=forms.NumberInput(attrs={
|
| 13 |
+
"class": "bg-surface-ligt p-1 border-b-1 text-center w-full",
|
| 14 |
+
"placeholder": "Solo números"
|
| 15 |
+
}), required=True)
|
| 16 |
+
|
| 17 |
+
instrucciones = forms.CharField(max_length=255, widget=forms.TextInput(attrs={
|
| 18 |
+
"class": "bg-surface-ligt border-b-1 text-center w-full p-1",
|
| 19 |
+
"placeholder": "Este campo es opcional"
|
| 20 |
+
}), required=False)
|
| 21 |
+
|
| 22 |
+
def __init__(self, *args, **kwargs):
|
| 23 |
+
super().__init__(*args, **kwargs)
|
| 24 |
+
|
| 25 |
+
self.fields['estilo_palabras'] = forms.ModelChoiceField(queryset=EstiloPalabra.objects.all(), widget=forms.RadioSelect(attrs={
|
| 26 |
+
"class": "uppercase text-lg tracking-wider font-medium p-2 px-4 active:px-5 transition-all rounded-xl bg-blue-500 text-white",
|
| 27 |
+
}), required=True, initial=EstiloPalabra.objects.first())
|
tecnicas/forms/{sesion_basic_form.py → create_session/sesion_basic_form.py}
RENAMED
|
@@ -1,7 +1,5 @@
|
|
| 1 |
from django import forms
|
| 2 |
-
from
|
| 3 |
-
from ..models import TipoTecnica
|
| 4 |
-
from ..models import EstiloPalabra
|
| 5 |
|
| 6 |
|
| 7 |
class SesionBasicForm(forms.Form):
|
|
|
|
| 1 |
from django import forms
|
| 2 |
+
from tecnicas.models import TipoEscala, EstiloPalabra
|
|
|
|
|
|
|
| 3 |
|
| 4 |
|
| 5 |
class SesionBasicForm(forms.Form):
|
tecnicas/forms/{sesion_tags_form.py → create_session/sesion_tags_form.py}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
from django import forms
|
| 2 |
-
from
|
| 3 |
|
| 4 |
|
| 5 |
class SesionTagsForm(forms.Form):
|
|
|
|
| 1 |
from django import forms
|
| 2 |
+
from tecnicas.models import Etiqueta
|
| 3 |
|
| 4 |
|
| 5 |
class SesionTagsForm(forms.Form):
|
tecnicas/static/js/panel-basic-cata.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
const descriptons = {
|
| 2 |
+
atributos:
|
| 3 |
+
"Con el estilo atributos elijes las palabras para evaluar los productos",
|
| 4 |
+
vocabulario:
|
| 5 |
+
"Los vocabularios son un conjunto de palabras específicas para evaluar aspectos de un producto",
|
| 6 |
+
};
|
| 7 |
+
|
| 8 |
+
const helpStyleWords = document.querySelector(".cts-help-style-words");
|
| 9 |
+
let radiosStyleWords;
|
| 10 |
+
|
| 11 |
+
function initRadiosStyleWords() {
|
| 12 |
+
radiosStyleWords = document.getElementsByName("estilo_palabras");
|
| 13 |
+
|
| 14 |
+
for (let index = 0; index < radiosStyleWords.length; index++) {
|
| 15 |
+
const radio = radiosStyleWords[index];
|
| 16 |
+
|
| 17 |
+
if (radio.checked) {
|
| 18 |
+
const radioOption = radio.parentElement.textContent.trim();
|
| 19 |
+
const textHelp = descriptons[radioOption];
|
| 20 |
+
helpStyleWords.textContent = textHelp;
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
radio.parentElement.addEventListener("click", (e) => {
|
| 24 |
+
const radioOption = radio.parentElement.textContent.trim();
|
| 25 |
+
const textHelp = descriptons[radioOption];
|
| 26 |
+
helpStyleWords.textContent = textHelp;
|
| 27 |
+
});
|
| 28 |
+
}
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
initRadiosStyleWords();
|
tecnicas/templates/tecnicas/create_sesion/panel-basic-cata.html
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{% extends 'tecnicas/layouts/base.html' %}
|
| 2 |
+
{% load static %}
|
| 3 |
+
|
| 4 |
+
{% block title %}Panel Configuracion{% endblock %}
|
| 5 |
+
|
| 6 |
+
{% block content %}
|
| 7 |
+
<article class="cts-container-main">
|
| 8 |
+
<article class="cts-wrap-content text-black">
|
| 9 |
+
<h1 class="text-center font-bold text-4xl">Panel de configuración</h1>
|
| 10 |
+
|
| 11 |
+
{% if error %}
|
| 12 |
+
{% include "../components/error-message.html" with message=error %}
|
| 13 |
+
{% endif %}
|
| 14 |
+
{% if message %}
|
| 15 |
+
{% include "../components/error-message.html" with message=message %}
|
| 16 |
+
{% endif %}
|
| 17 |
+
|
| 18 |
+
<form method="post" action="" class="space-y-4">
|
| 19 |
+
{% csrf_token %}
|
| 20 |
+
<article class="space-y-4">
|
| 21 |
+
<h2 class="text-2xl font-bold">Información Basica</h2>
|
| 22 |
+
|
| 23 |
+
<section class="flex justify-center items-center">
|
| 24 |
+
<label for="{{form_sesion.nombre_sesion.id_for_label}}"
|
| 25 |
+
class="text-lg flex flex-col items-center px-2 w-fit font-medium tracking-wide mb-4">
|
| 26 |
+
<p class="tracking-normal text-xl font-bold">Ingrese el nombre de la sesion si lo desea:</p>
|
| 27 |
+
{{ form_sesion.nombre_sesion }}
|
| 28 |
+
</label>
|
| 29 |
+
</section>
|
| 30 |
+
|
| 31 |
+
<section class="flex justify-center items-center">
|
| 32 |
+
<label for="{{ form_sesion.numero_productos.id_for_label }}"
|
| 33 |
+
class="text-lg flex flex-col items-center px-2 font-medium tracking-wide">
|
| 34 |
+
<p class="tracking-normal text-base font-bold">
|
| 35 |
+
Número de Productos:
|
| 36 |
+
</p>
|
| 37 |
+
{{ form_sesion.numero_productos }}
|
| 38 |
+
</label>
|
| 39 |
+
</section>
|
| 40 |
+
|
| 41 |
+
<section class="flex justify-center items-center">
|
| 42 |
+
<label for="{{form_sesion.instrucciones.id_for_label}}"
|
| 43 |
+
class="text-lg flex flex-col items-center px-2 w-fit font-medium tracking-wide mb-4">
|
| 44 |
+
<p class="tracking-normal text-base font-bold">Ingrese las instrucciones para la tecnica:</p>
|
| 45 |
+
{{ form_sesion.instrucciones }}
|
| 46 |
+
</label>
|
| 47 |
+
</section>
|
| 48 |
+
</article>
|
| 49 |
+
|
| 50 |
+
<article class="cs-escalas-radio flex flex-col gap-4">
|
| 51 |
+
<h2 class="text-2xl font-bold">Selecciona estilo para las palabras</h2>
|
| 52 |
+
<section class="flex flex-row gap-4 justify-around flex-wrap">
|
| 53 |
+
{% for estilo in form_sesion.estilo_palabras %}
|
| 54 |
+
<label for="{{estilo.id_for_label}}"
|
| 55 |
+
class="ct-radio-estilo uppercase text-lg tracking-wider font-bold p-2 px-4 rounded-xl cts-btn-secondary btn-push">
|
| 56 |
+
{{ estilo.tag }}
|
| 57 |
+
{{ estilo.choice_label }}
|
| 58 |
+
</label>
|
| 59 |
+
{% endfor %}
|
| 60 |
+
</section>
|
| 61 |
+
<section class="w-full flex justify-center items-center">
|
| 62 |
+
<p
|
| 63 |
+
class="cts-help-style-words max-w-2xl text-lg font-medium tracking-wide bg-surface-card text-center py-1 px-4 rounded-xl">
|
| 64 |
+
</p>
|
| 65 |
+
</section>
|
| 66 |
+
</article>
|
| 67 |
+
|
| 68 |
+
<article class="w-full flex max-sm:flex-col flex-wrap items-center justify-center gap-4">
|
| 69 |
+
<button type="submit" class="cts-btn-general cts-btn-primary btn-push flex-1/4 w-full">
|
| 70 |
+
Continuar
|
| 71 |
+
</button>
|
| 72 |
+
<a href="{% url 'cata_system:seleccion_tecnica' %}" class="flex-1/4 w-full">
|
| 73 |
+
<button type="button" class="cts-btn-general cts-btn-error btn-push w-full">
|
| 74 |
+
Cancelar la creación
|
| 75 |
+
</button>
|
| 76 |
+
</a>
|
| 77 |
+
</article>
|
| 78 |
+
</form>
|
| 79 |
+
</article>
|
| 80 |
+
</article>
|
| 81 |
+
{% endblock %}
|
| 82 |
+
|
| 83 |
+
{% block extra_js %}
|
| 84 |
+
<script src="{% static 'js/panel-basic-cata.js' %}"></script>
|
| 85 |
+
{% endblock %}
|
tecnicas/views/sessions_config/configuration_panel_basic.py
CHANGED
|
@@ -15,6 +15,8 @@ def configurationPanelBasic(req: HttpRequest):
|
|
| 15 |
response = PanelBasicController.controllGetEscalas(request=req)
|
| 16 |
elif name_tecnica == "rata":
|
| 17 |
response = PanelBasicController.controllGetRATA(request=req)
|
|
|
|
|
|
|
| 18 |
else:
|
| 19 |
response = redirect(
|
| 20 |
reverse("cata_system:seleccion_tecnica") + "?error=Técnica no valida o sin implementar")
|
|
|
|
| 15 |
response = PanelBasicController.controllGetEscalas(request=req)
|
| 16 |
elif name_tecnica == "rata":
|
| 17 |
response = PanelBasicController.controllGetRATA(request=req)
|
| 18 |
+
elif name_tecnica == "cata":
|
| 19 |
+
response = PanelBasicController.controllGetCATA(request=req)
|
| 20 |
else:
|
| 21 |
response = redirect(
|
| 22 |
reverse("cata_system:seleccion_tecnica") + "?error=Técnica no valida o sin implementar")
|