Spaces:
Sleeping
Sleeping
Validacion primer formulario configuracion de sesion
Browse files
tecnicas/forms/conf_sesion_form_start.py
CHANGED
|
@@ -7,7 +7,7 @@ class SesionFirtsForm(forms.Form):
|
|
| 7 |
"class": "bg-gray-200 border-b-1 text-center w-full p-1",
|
| 8 |
"name": "nombre_sesion",
|
| 9 |
"placeholder": "Ej. Mermelada de mango picante"
|
| 10 |
-
}), required=
|
| 11 |
|
| 12 |
numero_productos = forms.IntegerField(widget=forms.NumberInput(attrs={
|
| 13 |
"class": "bg-gray-200 p-1 border-b-1 text-center w-full",
|
|
@@ -24,10 +24,34 @@ class SesionFirtsForm(forms.Form):
|
|
| 24 |
"placeholder": "Solo números"
|
| 25 |
}), required=True)
|
| 26 |
|
| 27 |
-
tipo_escala = forms.ModelChoiceField(queryset=TipoEscala.objects.all(),
|
| 28 |
"class":"uppercase text-lg tracking-wider font-medium p-2 px-4 active:px-5 transition-all rounded-xl bg-blue-500 text-white",
|
| 29 |
-
}))
|
| 30 |
|
| 31 |
tamano_escala = forms.IntegerField(widget=forms.NumberInput(attrs={
|
| 32 |
"class": "bg-gray-200 p-1 border-b-1 text-center w-full",
|
| 33 |
-
}), required=True, min_value=5
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
"class": "bg-gray-200 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-gray-200 p-1 border-b-1 text-center w-full",
|
|
|
|
| 24 |
"placeholder": "Solo números"
|
| 25 |
}), required=True)
|
| 26 |
|
| 27 |
+
tipo_escala = forms.ModelChoiceField(queryset=TipoEscala.objects.all(), widget=forms.RadioSelect(attrs={
|
| 28 |
"class":"uppercase text-lg tracking-wider font-medium p-2 px-4 active:px-5 transition-all rounded-xl bg-blue-500 text-white",
|
| 29 |
+
}), required=True, initial=TipoEscala.objects.first())
|
| 30 |
|
| 31 |
tamano_escala = forms.IntegerField(widget=forms.NumberInput(attrs={
|
| 32 |
"class": "bg-gray-200 p-1 border-b-1 text-center w-full",
|
| 33 |
+
}), required=True, min_value=5)
|
| 34 |
+
|
| 35 |
+
def clean(self):
|
| 36 |
+
data_clean = super().clean()
|
| 37 |
+
|
| 38 |
+
sizes_estruturada = [5, 7, 9]
|
| 39 |
+
sizes_continua = [9, 12, 15]
|
| 40 |
+
|
| 41 |
+
escala = data_clean.get("tipo_escala")
|
| 42 |
+
|
| 43 |
+
if escala and not isinstance(escala, TipoEscala):
|
| 44 |
+
try:
|
| 45 |
+
escala = TipoEscala.objects.get(pk=escala)
|
| 46 |
+
except (ValueError, TipoEscala.DoesNotExist):
|
| 47 |
+
self.add_error("tipo_escala", "Escala no valida")
|
| 48 |
+
return data_clean
|
| 49 |
+
|
| 50 |
+
tamano_escala = data_clean.get("tamano_escala")
|
| 51 |
+
|
| 52 |
+
if escala.nombre_escala == "estructurada" and not sizes_estruturada.__contains__(tamano_escala):
|
| 53 |
+
self.add_error("tamano_escala", "El tamaño de la escala no aplica")
|
| 54 |
+
elif escala.nombre_escala == "continua" and not sizes_continua.__contains__(tamano_escala):
|
| 55 |
+
self.add_error("tamano_escala", "El tamaño de la escala no aplica")
|
| 56 |
+
else:
|
| 57 |
+
self.add_error("tipo_escala", "Escala no valida")
|
tecnicas/templates/tecnicas/configuracion-panel.html
CHANGED
|
@@ -21,7 +21,7 @@
|
|
| 21 |
<article class="flex flex-col gap-4 bg-gray-400 md:p-10 p-5 rounded-2xl lg:w-4xl w-full">
|
| 22 |
<h1 class="text-center font-bold text-4xl">Panel de configuración</h1>
|
| 23 |
<hr>
|
| 24 |
-
<form class="[&>article]:not-last:mb-4 [&>article]:not-first:pt-4 [&>article]:px-6">
|
| 25 |
{% csrf_token %}
|
| 26 |
<article>
|
| 27 |
<h2 class="text-2xl mb-2 font-bold">Información Basica</h2>
|
|
@@ -54,11 +54,17 @@
|
|
| 54 |
<section class="flex flex-row justify-around flex-wrap">
|
| 55 |
{% for escala in form_sesion.tipo_escala %}
|
| 56 |
<label for="{{escala.id_for_label}}"
|
| 57 |
-
class="ct-radio-escala uppercase text-lg tracking-wider font-medium p-2 px-4 active:
|
| 58 |
{{ escala.tag }}
|
| 59 |
{{ escala.choice_label }}
|
| 60 |
</label>
|
| 61 |
{% endfor %}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 62 |
</section>
|
| 63 |
|
| 64 |
<section class="py-2 px-5 flex flex-col justify-center items-center gap-2 relative">
|
|
@@ -67,6 +73,11 @@
|
|
| 67 |
<p>Establece número de segmentos:</p>
|
| 68 |
{{ form_sesion.tamano_escala }}
|
| 69 |
</label>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 70 |
<!-- <article class="bg-gray-500 p-4 flex flex-col gap-2">
|
| 71 |
<div class="flex flex-row justify-center items-center gap-5 text-lg">
|
| 72 |
<p class="font-medium p-1 px-3 bg-gray-200">Segmento 1</p>
|
|
@@ -151,6 +162,10 @@
|
|
| 151 |
</section>
|
| 152 |
</article>
|
| 153 |
<hr>
|
|
|
|
|
|
|
|
|
|
|
|
|
| 154 |
</form>
|
| 155 |
</article>
|
| 156 |
</article>
|
|
@@ -178,8 +193,7 @@
|
|
| 178 |
labels = document.getElementsByClassName("ct-radio-escala")
|
| 179 |
pSize = document.getElementsByClassName("ct-size-scale").item(0).getElementsByTagName("p")[0]
|
| 180 |
iSize = document.getElementsByClassName("ct-size-scale").item(0).getElementsByTagName("input")[0]
|
| 181 |
-
|
| 182 |
-
labels.item(0).getElementsByTagName("input")[0].checked = true
|
| 183 |
pSize.textContent = descriptons["estructurada"][0]
|
| 184 |
iSize.placeholder = descriptons["estructurada"][1]
|
| 185 |
|
|
|
|
| 21 |
<article class="flex flex-col gap-4 bg-gray-400 md:p-10 p-5 rounded-2xl lg:w-4xl w-full">
|
| 22 |
<h1 class="text-center font-bold text-4xl">Panel de configuración</h1>
|
| 23 |
<hr>
|
| 24 |
+
<form method="post" action="" class="[&>article]:not-last:mb-4 [&>article]:not-first:pt-4 [&>article]:px-6">
|
| 25 |
{% csrf_token %}
|
| 26 |
<article>
|
| 27 |
<h2 class="text-2xl mb-2 font-bold">Información Basica</h2>
|
|
|
|
| 54 |
<section class="flex flex-row justify-around flex-wrap">
|
| 55 |
{% for escala in form_sesion.tipo_escala %}
|
| 56 |
<label for="{{escala.id_for_label}}"
|
| 57 |
+
class="ct-radio-escala uppercase text-lg tracking-wider font-medium p-2 px-4 border-b-2 active:border-b-0 active:border-t-2 border-blue-800 transition-all rounded-xl bg-blue-500 text-white w-fit">
|
| 58 |
{{ escala.tag }}
|
| 59 |
{{ escala.choice_label }}
|
| 60 |
</label>
|
| 61 |
{% endfor %}
|
| 62 |
+
|
| 63 |
+
{% if form_sesion.tipo_escala.errors %}
|
| 64 |
+
<div class="w-full text-center text-red-600 text-xl font-medium tracking-wide">
|
| 65 |
+
{{ form_sesion.tipo_escala.errors }}
|
| 66 |
+
</div>
|
| 67 |
+
{% endif %}
|
| 68 |
</section>
|
| 69 |
|
| 70 |
<section class="py-2 px-5 flex flex-col justify-center items-center gap-2 relative">
|
|
|
|
| 73 |
<p>Establece número de segmentos:</p>
|
| 74 |
{{ form_sesion.tamano_escala }}
|
| 75 |
</label>
|
| 76 |
+
{% if form_sesion.tamano_escala.errors %}
|
| 77 |
+
<article class="w-fit rounded px-2 py-0.5 text-center text-white text-sm font-medium tracking-wide bg-red-500">
|
| 78 |
+
{{ form_sesion.tamano_escala.errors }}
|
| 79 |
+
</article>
|
| 80 |
+
{% endif %}
|
| 81 |
<!-- <article class="bg-gray-500 p-4 flex flex-col gap-2">
|
| 82 |
<div class="flex flex-row justify-center items-center gap-5 text-lg">
|
| 83 |
<p class="font-medium p-1 px-3 bg-gray-200">Segmento 1</p>
|
|
|
|
| 162 |
</section>
|
| 163 |
</article>
|
| 164 |
<hr>
|
| 165 |
+
<article class="cs-escalas-radio flex flex-col items-center gap-4">
|
| 166 |
+
<button type="submit"
|
| 167 |
+
class="uppercase text-lg tracking-wider font-medium p-2 px-4 border-b-2 active:border-b-0 active:border-t-2 active:border-yellow-500 border-yellow-800 transition-all rounded-xl bg-yellow-500 text-white w-fit">Continuar</button>
|
| 168 |
+
</article>
|
| 169 |
</form>
|
| 170 |
</article>
|
| 171 |
</article>
|
|
|
|
| 193 |
labels = document.getElementsByClassName("ct-radio-escala")
|
| 194 |
pSize = document.getElementsByClassName("ct-size-scale").item(0).getElementsByTagName("p")[0]
|
| 195 |
iSize = document.getElementsByClassName("ct-size-scale").item(0).getElementsByTagName("input")[0]
|
| 196 |
+
|
|
|
|
| 197 |
pSize.textContent = descriptons["estructurada"][0]
|
| 198 |
iSize.placeholder = descriptons["estructurada"][1]
|
| 199 |
|
tecnicas/templates/tecnicas/seleccion-tecnica.html
CHANGED
|
@@ -21,37 +21,19 @@
|
|
| 21 |
<button
|
| 22 |
class="p-4 bg-blue-700 hover:bg-blue-800 active:ring-4 active:outline-none active:ring-blue-300 flex flex-row gap-4 justify-center items-center rounded-lg text-2xl font-medium uppercase tracking-wider w-full z-20 relative"
|
| 23 |
onclick="showList('{{cate}}')" type="button">{{ cate }}</button>
|
|
|
|
| 24 |
<section
|
| 25 |
-
class="modal-list-{{ cate }} text-lg bg-blue-100 p-4 pr-6 pl-8 sm:pl-12 z-10 -translate-y-1 rounded-b-2xl *:not-last:mb-4 transition-all duration-1000 hidden">
|
| 26 |
{% for tecnica in tecnicas %}
|
| 27 |
-
<
|
| 28 |
class="bg-green-700 border-l-10 border-gray-700 rounded-md px-3 py-2 w-full font-bold tracking-wider text-left uppercase">
|
| 29 |
{{ tecnica.nombre_tecnica }}
|
| 30 |
-
</
|
| 31 |
{% endfor %}
|
| 32 |
</section>
|
|
|
|
| 33 |
</article>
|
| 34 |
{% endfor %}
|
| 35 |
-
<article>
|
| 36 |
-
<button
|
| 37 |
-
class="p-4 bg-blue-700 hover:bg-blue-800 active:ring-4 active:outline-none active:ring-blue-300 flex flex-row gap-4 justify-center items-center rounded-lg text-2xl font-medium uppercase tracking-wider w-full z-20 relative"
|
| 38 |
-
onclick="showList('otro')" type="button">ejemplo sin funcion</button>
|
| 39 |
-
<section
|
| 40 |
-
class="modal-list-otro text-lg bg-blue-100 p-4 pr-6 pl-8 sm:pl-12 z-10 -translate-y-1 rounded-b-2xl *:not-last:mb-4 transition-all duration-1000 hidden">
|
| 41 |
-
<button
|
| 42 |
-
class="bg-green-700 border-l-10 border-gray-700 rounded-md px-3 py-2 w-full font-bold tracking-wider text-left">
|
| 43 |
-
Una tecnica sensorial
|
| 44 |
-
</button>
|
| 45 |
-
<button
|
| 46 |
-
class="bg-green-700 border-l-10 border-gray-700 rounded-md px-3 py-2 w-full font-bold tracking-wider text-left">
|
| 47 |
-
Una tecnica sensorial
|
| 48 |
-
</button>
|
| 49 |
-
<button
|
| 50 |
-
class="bg-green-700 border-l-10 border-gray-700 rounded-md px-3 py-2 w-full font-bold tracking-wider text-left">
|
| 51 |
-
Una tecnica sensorial
|
| 52 |
-
</button>
|
| 53 |
-
</section>
|
| 54 |
-
</article>
|
| 55 |
</section>
|
| 56 |
</article>
|
| 57 |
</article>
|
|
|
|
| 21 |
<button
|
| 22 |
class="p-4 bg-blue-700 hover:bg-blue-800 active:ring-4 active:outline-none active:ring-blue-300 flex flex-row gap-4 justify-center items-center rounded-lg text-2xl font-medium uppercase tracking-wider w-full z-20 relative"
|
| 23 |
onclick="showList('{{cate}}')" type="button">{{ cate }}</button>
|
| 24 |
+
{% if tecnicas %}
|
| 25 |
<section
|
| 26 |
+
class="modal-list-{{ cate }} flex flex-col text-lg bg-blue-100 p-4 pr-6 pl-8 sm:pl-12 z-10 -translate-y-1 rounded-b-2xl *:not-last:mb-4 transition-all duration-1000 hidden w-full">
|
| 27 |
{% for tecnica in tecnicas %}
|
| 28 |
+
<a href="{% url 'cata_system:panel_configuracion'%}?id_tecnica={{tecnica.id}}"
|
| 29 |
class="bg-green-700 border-l-10 border-gray-700 rounded-md px-3 py-2 w-full font-bold tracking-wider text-left uppercase">
|
| 30 |
{{ tecnica.nombre_tecnica }}
|
| 31 |
+
</a>
|
| 32 |
{% endfor %}
|
| 33 |
</section>
|
| 34 |
+
{% endif %}
|
| 35 |
</article>
|
| 36 |
{% endfor %}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
</section>
|
| 38 |
</article>
|
| 39 |
</article>
|
tecnicas/views/configuracion_panel.py
CHANGED
|
@@ -1,9 +1,26 @@
|
|
| 1 |
-
from django.shortcuts import render
|
| 2 |
-
from
|
| 3 |
from ..forms import SesionFirtsForm
|
|
|
|
| 4 |
|
| 5 |
-
def configuracionPanel(req):
|
| 6 |
-
|
| 7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
|
| 9 |
-
|
|
|
|
| 1 |
+
from django.shortcuts import render, redirect
|
| 2 |
+
from django.http import HttpRequest
|
| 3 |
from ..forms import SesionFirtsForm
|
| 4 |
+
from ..models import TipoTecnica
|
| 5 |
|
| 6 |
+
def configuracionPanel(req: HttpRequest):
|
| 7 |
+
if req.method == "POST":
|
| 8 |
+
form = SesionFirtsForm(req.POST)
|
| 9 |
+
if form.is_valid():
|
| 10 |
+
return redirect("/cata")
|
| 11 |
+
else:
|
| 12 |
+
return render(req, "tecnicas/configuracion-panel.html", { "form_sesion": form })
|
| 13 |
+
elif req.method == "GET":
|
| 14 |
+
if req.GET["id_tecnica"]:
|
| 15 |
+
try:
|
| 16 |
+
tecnica = TipoTecnica.objects.get(pk=int(req.GET["id_tecnica"]))
|
| 17 |
+
except (ValueError, TipoTecnica.DoesNotExist):
|
| 18 |
+
|
| 19 |
+
pass
|
| 20 |
+
else:
|
| 21 |
+
redirect("/seleccion-tecnica")
|
| 22 |
+
pass
|
| 23 |
+
|
| 24 |
+
form_sesion = SesionFirtsForm()
|
| 25 |
|
| 26 |
+
return render(req, "tecnicas/configuracion-panel.html", { "form_sesion": form_sesion })
|