chartManD commited on
Commit
ef40ea8
·
1 Parent(s): d660bac

Refactorizando creacion de nappgin, eleccion de modalidad

Browse files
tecnicas/controllers/views_controller/create_session/panels_create/panel_create_napping_controller.py CHANGED
@@ -1,6 +1,6 @@
1
  from .panel_create_controller import PanelCreateController
2
  from django.http import HttpRequest, JsonResponse
3
- from tecnicas.models import Tecnica, TipoTecnica, EstiloPalabra, Producto, SesionSensorial
4
  from django.db import transaction
5
  from tecnicas.utils import deleteDataSession
6
 
@@ -64,6 +64,25 @@ class PanelCreateNappingController(PanelCreateController):
64
  # Third step: Create session and relat with the technique #
65
  #
66
  # /////////////////////////////////////////////////////// #
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
67
  session = SesionSensorial.objects.create(
68
  nombre_sesion=data_basic["nombre_sesion"] if data_basic["nombre_sesion"] != "" else None,
69
  tecnica=technique,
 
1
  from .panel_create_controller import PanelCreateController
2
  from django.http import HttpRequest, JsonResponse
3
+ from tecnicas.models import Tecnica, TipoTecnica, EstiloPalabra, Producto, SesionSensorial, Modalidad, TecnicaModalidad
4
  from django.db import transaction
5
  from tecnicas.utils import deleteDataSession
6
 
 
64
  # Third step: Create session and relat with the technique #
65
  #
66
  # /////////////////////////////////////////////////////// #
67
+ mod = Modalidad.objects.get(
68
+ nombre=data_basic["modalidad"])
69
+
70
+ if not mod:
71
+ raise ValueError("Modalidad no encontrada")
72
+
73
+ technique_mod = TecnicaModalidad.objects.create(
74
+ tecnica=technique,
75
+ modalidad=mod
76
+ )
77
+
78
+ if not technique_mod:
79
+ raise ValueError("Error al guardar la técnica")
80
+
81
+ # /////////////////////////////////////////////////////// #
82
+ #
83
+ # Fourth step: Create session and relat with the technique #
84
+ #
85
+ # /////////////////////////////////////////////////////// #
86
  session = SesionSensorial.objects.create(
87
  nombre_sesion=data_basic["nombre_sesion"] if data_basic["nombre_sesion"] != "" else None,
88
  tecnica=technique,
tecnicas/forms/create_session/sesion_basic_napping.py CHANGED
@@ -1,4 +1,5 @@
1
  from django import forms
 
2
 
3
 
4
  class SesionBasicNappingForm(forms.Form):
@@ -22,3 +23,16 @@ class SesionBasicNappingForm(forms.Form):
22
  "class": "bg-surface-ligt border-b-1 text-center w-full p-1",
23
  "placeholder": "Este campo es opcional"
24
  }), required=False)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  from django import forms
2
+ from tecnicas.models import Modalidad
3
 
4
 
5
  class SesionBasicNappingForm(forms.Form):
 
23
  "class": "bg-surface-ligt border-b-1 text-center w-full p-1",
24
  "placeholder": "Este campo es opcional"
25
  }), required=False)
26
+
27
+ def __init__(self, *args, **kwargs):
28
+ super(SesionBasicNappingForm, self).__init__(*args, **kwargs)
29
+ names_mod = [
30
+ ("sin modalidad", "sin modalidad"),
31
+ ("sorting", "sorting"),
32
+ ("perfil ultra flash", "perfil ultra flash")
33
+ ]
34
+
35
+ self.fields['modalidad'] = forms.CharField(widget=forms.RadioSelect(choices=names_mod, attrs={
36
+ "class": "radio radio-lg radio-info",
37
+ "placeholder": "Seleccione una modalidad",
38
+ }), required=True, initial=names_mod[0])
tecnicas/templates/tecnicas/create_sesion/panel-basic-napping.html CHANGED
@@ -28,14 +28,14 @@
28
  </section>
29
  <section class="flex flex-row flex-wrap justify-center gap-4">
30
  <label for="{{ form_sesion.numero_productos.id_for_label }}"
31
- class="text-lg flex flex-col items-center px-2 font-medium tracking-wide">
32
  <p class="tracking-normal text-base font-bold">
33
  Número de Productos:
34
  </p>
35
  {{ form_sesion.numero_productos }}
36
  </label>
37
  <label for="{{ form_sesion.numero_catadores.id_for_label }}"
38
- class="text-lg flex flex-col items-center px-2 font-medium tracking-wide">
39
  <p class="tracking-normal text-base font-bold">
40
  Número de Catadores:
41
  </p>
@@ -51,6 +51,21 @@
51
  </section>
52
  </article>
53
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
54
  <article class="w-full flex max-sm:flex-col flex-wrap items-center justify-center gap-4">
55
  <button type="submit" class="cts-btn-general cts-btn-primary btn-push flex-1/4 w-full">
56
  Continuar
 
28
  </section>
29
  <section class="flex flex-row flex-wrap justify-center gap-4">
30
  <label for="{{ form_sesion.numero_productos.id_for_label }}"
31
+ class="text-lg flex flex-col items-center px-2 font-medium tracking-wide flex-1">
32
  <p class="tracking-normal text-base font-bold">
33
  Número de Productos:
34
  </p>
35
  {{ form_sesion.numero_productos }}
36
  </label>
37
  <label for="{{ form_sesion.numero_catadores.id_for_label }}"
38
+ class="text-lg flex flex-col items-center px-2 font-medium tracking-wide flex-1">
39
  <p class="tracking-normal text-base font-bold">
40
  Número de Catadores:
41
  </p>
 
51
  </section>
52
  </article>
53
 
54
+ <article class="space-y-4">
55
+ <h2 class="text-2xl font-bold">Elije Modalidad</h2>
56
+ <section class="flex flex-row gap-4 justify-around flex-wrap">
57
+ {% for choice in form_sesion.modalidad %}
58
+ <label for="{{choice.id_for_label}}"
59
+ class="cts-btn-general-compress cts-btn-secondary btn-push px-4 py-2 uppercase flex-1 flex items-center justify-around gap-2">
60
+ {{ choice.tag }}
61
+ <p class="italic text-center flex-1">
62
+ {{ choice.choice_label }}
63
+ </p>
64
+ </label>
65
+ {% endfor %}
66
+ </section>
67
+ </article>
68
+
69
  <article class="w-full flex max-sm:flex-col flex-wrap items-center justify-center gap-4">
70
  <button type="submit" class="cts-btn-general cts-btn-primary btn-push flex-1/4 w-full">
71
  Continuar