Spaces:
Sleeping
Sleeping
Creacion de metodos para el controlador de tecnica y escala
Browse files- tecnicas/controllers/escala_controller.py +62 -6
- tecnicas/controllers/tecnica_controller.py +13 -6
- tecnicas/forms/sesion_basic_form.py +1 -1
- tecnicas/forms/sesion_tags_form.py +1 -1
- tecnicas/migrations/0010_escala_tecnica_alter_sesionsensorial_codigo_sesion_and_more.py +28 -0
- tecnicas/migrations/0011_alter_escala_tecnica_and_more.py +25 -0
- tecnicas/models/__init__.py +0 -1
- tecnicas/models/escala.py +2 -0
- tecnicas/models/tecnica_intensidad.py +0 -8
- tecnicas/services/__init__.py +0 -1
- tecnicas/services/build_sesory_sesion.py +0 -17
- tecnicas/services/service_technique.py +0 -3
- tecnicas/templates/tecnicas/configuracion-panel-basic.html +3 -3
- tecnicas/views/configuration_panel_words.py +1 -1
tecnicas/controllers/escala_controller.py
CHANGED
|
@@ -1,9 +1,65 @@
|
|
| 1 |
-
from ..models import TipoEscala
|
|
|
|
| 2 |
|
| 3 |
class EscalaController():
|
| 4 |
-
def __init__(self):
|
| 5 |
-
pass
|
| 6 |
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from ..models import TipoEscala, Etiqueta, EtiquetasEscala, Escala, Tecnica
|
| 2 |
+
|
| 3 |
|
| 4 |
class EscalaController():
|
|
|
|
|
|
|
| 5 |
|
| 6 |
+
scale: Escala
|
| 7 |
+
|
| 8 |
+
def __init__(self, scale):
|
| 9 |
+
self.scale = scale or None
|
| 10 |
+
|
| 11 |
+
def setAndSaveScale(self, type_scale: TipoEscala, size: int, technique: Tecnica):
|
| 12 |
+
self.scale = Escala.objects.create(
|
| 13 |
+
id_tipo_escala=type_scale,
|
| 14 |
+
longitud=size,
|
| 15 |
+
tecnica=technique
|
| 16 |
+
)
|
| 17 |
+
|
| 18 |
+
def setScale(self, scale):
|
| 19 |
+
self.scale = scale
|
| 20 |
+
|
| 21 |
+
def realte_tags_type_cotinue(self, tags: list):
|
| 22 |
+
tag = Etiqueta.objects.get(id=tags["punto_inicial"])
|
| 23 |
+
start_point = EtiquetasEscala.objects.create(
|
| 24 |
+
id_escala=self.scale.id,
|
| 25 |
+
id_etiqueta=tag,
|
| 26 |
+
posicion=1
|
| 27 |
+
)
|
| 28 |
+
|
| 29 |
+
tag = Etiqueta.objects.get(id=tags["punto_medio"])
|
| 30 |
+
half_point = EtiquetasEscala.objects.create(
|
| 31 |
+
id_escala=self.scale.id,
|
| 32 |
+
id_etiqueta=tag,
|
| 33 |
+
posicion=2
|
| 34 |
+
)
|
| 35 |
+
|
| 36 |
+
tag = Etiqueta.objects.get(id=tags["punto_final"])
|
| 37 |
+
end_point = EtiquetasEscala.objects.create(
|
| 38 |
+
id_escala=self.scale.id,
|
| 39 |
+
id_etiqueta=tag,
|
| 40 |
+
posicion=3
|
| 41 |
+
)
|
| 42 |
+
|
| 43 |
+
self.tags = [
|
| 44 |
+
("start", start_point),
|
| 45 |
+
("medium", half_point),
|
| 46 |
+
("end", end_point)
|
| 47 |
+
]
|
| 48 |
+
|
| 49 |
+
return self.tags
|
| 50 |
+
|
| 51 |
+
def realte_tags_type_structure(self, tags: dict):
|
| 52 |
+
index = 1
|
| 53 |
+
self.tags = []
|
| 54 |
+
|
| 55 |
+
for name, id_tag in tags.items():
|
| 56 |
+
tag = Etiqueta.objects.get(id=id_tag)
|
| 57 |
+
related_tag = EtiquetasEscala(
|
| 58 |
+
id_escala=self.scale.id,
|
| 59 |
+
id_etiqueta=tag,
|
| 60 |
+
posicion=index
|
| 61 |
+
)
|
| 62 |
+
self.tags.append((name, related_tag))
|
| 63 |
+
index += 1
|
| 64 |
+
|
| 65 |
+
return self.tags
|
tecnicas/controllers/tecnica_controller.py
CHANGED
|
@@ -1,16 +1,23 @@
|
|
| 1 |
-
from ..models import TipoTecnica, CategoriaTecnica
|
|
|
|
| 2 |
|
| 3 |
class TecnicaController():
|
| 4 |
-
def
|
| 5 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
@staticmethod
|
| 8 |
def getTypesTechnique():
|
| 9 |
showTecnicas = {}
|
| 10 |
-
|
| 11 |
|
| 12 |
-
for cata in
|
| 13 |
tecnicas = TipoTecnica.objects.filter(id_categoria_tecnica=cata.id)
|
| 14 |
showTecnicas[cata.nombre_categoria] = tecnicas
|
| 15 |
|
| 16 |
-
return showTecnicas
|
|
|
|
| 1 |
+
from ..models import TipoTecnica, CategoriaTecnica, Tecnica
|
| 2 |
+
|
| 3 |
|
| 4 |
class TecnicaController():
|
| 5 |
+
def setTechnique(self, **kwargs):
|
| 6 |
+
self.technique = Tecnica.objects.create(
|
| 7 |
+
tipo_tecnica=kwargs["tipo_tecnica"],
|
| 8 |
+
repeticiones_max=kwargs["numero_repeticiones"] or 0,
|
| 9 |
+
limite_catadores=kwargs["numero_catadores"],
|
| 10 |
+
instrucciones=kwargs["instrucciones"],
|
| 11 |
+
id_estilo=kwargs["estilo_palabras"],
|
| 12 |
+
)
|
| 13 |
|
| 14 |
@staticmethod
|
| 15 |
def getTypesTechnique():
|
| 16 |
showTecnicas = {}
|
| 17 |
+
categories = CategoriaTecnica.objects.all()
|
| 18 |
|
| 19 |
+
for cata in categories:
|
| 20 |
tecnicas = TipoTecnica.objects.filter(id_categoria_tecnica=cata.id)
|
| 21 |
showTecnicas[cata.nombre_categoria] = tecnicas
|
| 22 |
|
| 23 |
+
return showTecnicas
|
tecnicas/forms/sesion_basic_form.py
CHANGED
|
@@ -18,7 +18,7 @@ class SesionBasicForm(forms.Form):
|
|
| 18 |
"placeholder": "Solo números"
|
| 19 |
}), required=True)
|
| 20 |
|
| 21 |
-
|
| 22 |
"class": "bg-gray-200 p-1 border-b-1 text-center w-full",
|
| 23 |
"placeholder": "Solo números"
|
| 24 |
}), required=True)
|
|
|
|
| 18 |
"placeholder": "Solo números"
|
| 19 |
}), required=True)
|
| 20 |
|
| 21 |
+
numero_catadores = forms.IntegerField(widget=forms.NumberInput(attrs={
|
| 22 |
"class": "bg-gray-200 p-1 border-b-1 text-center w-full",
|
| 23 |
"placeholder": "Solo números"
|
| 24 |
}), required=True)
|
tecnicas/forms/sesion_tags_form.py
CHANGED
|
@@ -8,7 +8,7 @@ class SesionTagsForm(forms.Form):
|
|
| 8 |
|
| 9 |
if tipo_escala == "estructurada":
|
| 10 |
for i in range(longitud):
|
| 11 |
-
self.fields[f'segmento_{i}'] = forms.ModelChoiceField(queryset=Etiqueta.objects.all(), required=True, label=f"segmento {i+1}", empty_label="Selecione opcion", widget=forms.Select(attrs={
|
| 12 |
"class":"ct-select-op p-1 rounded bg-gray-200 [*]:capitalize"
|
| 13 |
}))
|
| 14 |
else:
|
|
|
|
| 8 |
|
| 9 |
if tipo_escala == "estructurada":
|
| 10 |
for i in range(longitud):
|
| 11 |
+
self.fields[f'segmento_{i+1}'] = forms.ModelChoiceField(queryset=Etiqueta.objects.all(), required=True, label=f"segmento {i+1}", empty_label="Selecione opcion", widget=forms.Select(attrs={
|
| 12 |
"class":"ct-select-op p-1 rounded bg-gray-200 [*]:capitalize"
|
| 13 |
}))
|
| 14 |
else:
|
tecnicas/migrations/0010_escala_tecnica_alter_sesionsensorial_codigo_sesion_and_more.py
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Generated by Django 5.2.1 on 2025-08-11 23:21
|
| 2 |
+
|
| 3 |
+
import django.db.models.deletion
|
| 4 |
+
import shortuuid.main
|
| 5 |
+
from django.db import migrations, models
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
class Migration(migrations.Migration):
|
| 9 |
+
|
| 10 |
+
dependencies = [
|
| 11 |
+
('tecnicas', '0009_alter_orden_id_catador_and_more'),
|
| 12 |
+
]
|
| 13 |
+
|
| 14 |
+
operations = [
|
| 15 |
+
migrations.AddField(
|
| 16 |
+
model_name='escala',
|
| 17 |
+
name='tecnica',
|
| 18 |
+
field=models.OneToOneField(default=None, on_delete=django.db.models.deletion.CASCADE, related_name='escala_tecnica', to='tecnicas.tecnica'),
|
| 19 |
+
),
|
| 20 |
+
migrations.AlterField(
|
| 21 |
+
model_name='sesionsensorial',
|
| 22 |
+
name='codigo_sesion',
|
| 23 |
+
field=models.CharField(default=shortuuid.main.ShortUUID.uuid, editable=False, max_length=22, primary_key=True, serialize=False),
|
| 24 |
+
),
|
| 25 |
+
migrations.DeleteModel(
|
| 26 |
+
name='TecnicaIntensidad',
|
| 27 |
+
),
|
| 28 |
+
]
|
tecnicas/migrations/0011_alter_escala_tecnica_and_more.py
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Generated by Django 5.2.1 on 2025-08-11 23:22
|
| 2 |
+
|
| 3 |
+
import django.db.models.deletion
|
| 4 |
+
import shortuuid.main
|
| 5 |
+
from django.db import migrations, models
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
class Migration(migrations.Migration):
|
| 9 |
+
|
| 10 |
+
dependencies = [
|
| 11 |
+
('tecnicas', '0010_escala_tecnica_alter_sesionsensorial_codigo_sesion_and_more'),
|
| 12 |
+
]
|
| 13 |
+
|
| 14 |
+
operations = [
|
| 15 |
+
migrations.AlterField(
|
| 16 |
+
model_name='escala',
|
| 17 |
+
name='tecnica',
|
| 18 |
+
field=models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='escala_tecnica', to='tecnicas.tecnica'),
|
| 19 |
+
),
|
| 20 |
+
migrations.AlterField(
|
| 21 |
+
model_name='sesionsensorial',
|
| 22 |
+
name='codigo_sesion',
|
| 23 |
+
field=models.CharField(default=shortuuid.main.ShortUUID.uuid, editable=False, max_length=22, primary_key=True, serialize=False),
|
| 24 |
+
),
|
| 25 |
+
]
|
tecnicas/models/__init__.py
CHANGED
|
@@ -17,7 +17,6 @@ from .sesion_sensorial import SesionSensorial
|
|
| 17 |
|
| 18 |
from .escala import Escala
|
| 19 |
from .etiquetas_escala import EtiquetasEscala
|
| 20 |
-
from .tecnica_intensidad import TecnicaIntensidad
|
| 21 |
from .producto import Producto
|
| 22 |
|
| 23 |
from .calificacion import Calificacion
|
|
|
|
| 17 |
|
| 18 |
from .escala import Escala
|
| 19 |
from .etiquetas_escala import EtiquetasEscala
|
|
|
|
| 20 |
from .producto import Producto
|
| 21 |
|
| 22 |
from .calificacion import Calificacion
|
tecnicas/models/escala.py
CHANGED
|
@@ -1,10 +1,12 @@
|
|
| 1 |
from django.db import models
|
| 2 |
|
| 3 |
from .tipo_escala import TipoEscala
|
|
|
|
| 4 |
|
| 5 |
class Escala(models.Model):
|
| 6 |
id_tipo_escala = models.ForeignKey(TipoEscala, on_delete=models.CASCADE, related_name="escala_tipo_escala")
|
| 7 |
longitud = models.IntegerField()
|
|
|
|
| 8 |
|
| 9 |
def __str__(self):
|
| 10 |
return self.longitud
|
|
|
|
| 1 |
from django.db import models
|
| 2 |
|
| 3 |
from .tipo_escala import TipoEscala
|
| 4 |
+
from .tecnica import Tecnica
|
| 5 |
|
| 6 |
class Escala(models.Model):
|
| 7 |
id_tipo_escala = models.ForeignKey(TipoEscala, on_delete=models.CASCADE, related_name="escala_tipo_escala")
|
| 8 |
longitud = models.IntegerField()
|
| 9 |
+
tecnica = models.OneToOneField(Tecnica, on_delete=models.CASCADE, related_name="escala_tecnica")
|
| 10 |
|
| 11 |
def __str__(self):
|
| 12 |
return self.longitud
|
tecnicas/models/tecnica_intensidad.py
DELETED
|
@@ -1,8 +0,0 @@
|
|
| 1 |
-
from django.db import models
|
| 2 |
-
|
| 3 |
-
from .escala import Escala
|
| 4 |
-
from .tecnica import Tecnica
|
| 5 |
-
|
| 6 |
-
class TecnicaIntensidad(models.Model):
|
| 7 |
-
id_tecnica = models.OneToOneField(Tecnica, on_delete=models.CASCADE, related_name="tecnica_intensidad")
|
| 8 |
-
id_escala = models.OneToOneField(Escala, on_delete=models.CASCADE, related_name="escala_intensidad")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tecnicas/services/__init__.py
DELETED
|
@@ -1 +0,0 @@
|
|
| 1 |
-
from .build_sesory_sesion import BuildSensorySesion
|
|
|
|
|
|
tecnicas/services/build_sesory_sesion.py
DELETED
|
@@ -1,17 +0,0 @@
|
|
| 1 |
-
from ..models import Escala, TipoEscala, Etiqueta, EtiquetasEscala
|
| 2 |
-
|
| 3 |
-
class BuildSensorySesion():
|
| 4 |
-
|
| 5 |
-
def realte_tags(self, tags:list):
|
| 6 |
-
if self.escala.id_tipo_escala.nombre_escala == "continua":
|
| 7 |
-
tag = Etiqueta.objects.get(id=tags["punto_inicial"])
|
| 8 |
-
start_point = EtiquetasEscala(id_escala = self.escala.id, id_etiqueta = tag, posicion = 1)
|
| 9 |
-
|
| 10 |
-
tag = Etiqueta.objects.get(id=tags["punto_medio"])
|
| 11 |
-
half_point = EtiquetasEscala(id_escala = self.escala.id, id_etiqueta = tag, posicion = 2)
|
| 12 |
-
|
| 13 |
-
tag = Etiqueta.objects.get(id=tags["punto_final"])
|
| 14 |
-
end_point = EtiquetasEscala(id_escala = self.escala.id, id_etiqueta = tag, posicion = 3)
|
| 15 |
-
|
| 16 |
-
elif self.escala.id_tipo_escala.nombre_escala == "estructurda":
|
| 17 |
-
tags.sort()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tecnicas/services/service_technique.py
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
class BuildTechnique():
|
| 2 |
-
def __init__(self, tipo, estilo, basic_data):
|
| 3 |
-
pass
|
|
|
|
|
|
|
|
|
|
|
|
tecnicas/templates/tecnicas/configuracion-panel-basic.html
CHANGED
|
@@ -43,9 +43,9 @@
|
|
| 43 |
<p>Número de Productos:</p>
|
| 44 |
{{ form_sesion.numero_productos }}
|
| 45 |
</label>
|
| 46 |
-
<label for="{{ form_sesion.
|
| 47 |
-
<p>Número de
|
| 48 |
-
{{ form_sesion.
|
| 49 |
</label>
|
| 50 |
<label for="{{ form_sesion.numero_repeticiones.id_for_label }}">
|
| 51 |
<p>Número de Repeticiones:</p>
|
|
|
|
| 43 |
<p>Número de Productos:</p>
|
| 44 |
{{ form_sesion.numero_productos }}
|
| 45 |
</label>
|
| 46 |
+
<label for="{{ form_sesion.numero_catadores.id_for_label }}">
|
| 47 |
+
<p>Número de Catadores:</p>
|
| 48 |
+
{{ form_sesion.numero_catadores }}
|
| 49 |
</label>
|
| 50 |
<label for="{{ form_sesion.numero_repeticiones.id_for_label }}">
|
| 51 |
<p>Número de Repeticiones:</p>
|
tecnicas/views/configuration_panel_words.py
CHANGED
|
@@ -13,7 +13,7 @@ def configurationsPanelWords(req:HttpRequest):
|
|
| 13 |
redirect(reverse("cata_system:seleccion_tecnica") + "?error=datos del formulario requerido no encontrados")
|
| 14 |
|
| 15 |
num_products = data_basic["numero_productos"]
|
| 16 |
-
num_cata = data_basic["
|
| 17 |
|
| 18 |
if req.method == "GET":
|
| 19 |
codes_products = generarCodigos(num_products)
|
|
|
|
| 13 |
redirect(reverse("cata_system:seleccion_tecnica") + "?error=datos del formulario requerido no encontrados")
|
| 14 |
|
| 15 |
num_products = data_basic["numero_productos"]
|
| 16 |
+
num_cata = data_basic["numero_catadores"]
|
| 17 |
|
| 18 |
if req.method == "GET":
|
| 19 |
codes_products = generarCodigos(num_products)
|