chartManD commited on
Commit
9cd83a1
·
1 Parent(s): 80eb754

Se crea formulario para crear catadores

Browse files
tecnicas/forms/__init__.py CHANGED
@@ -1,4 +1,5 @@
1
  from .sesion_basic_form import SesionBasicForm
2
  from .sesion_tags_form import SesionTagsForm
3
  from .etiqueta_form import EtiquetaForm
4
- from .palabras_form import PalabrasForm
 
 
1
  from .sesion_basic_form import SesionBasicForm
2
  from .sesion_tags_form import SesionTagsForm
3
  from .etiqueta_form import EtiquetaForm
4
+ from .palabras_form import PalabrasForm
5
+ from .catador_form import CatadorForm
tecnicas/forms/catador_form.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from django import forms
2
+ from ..models import Catador
3
+
4
+ class CatadorForm(forms.ModelForm):
5
+ class Meta:
6
+ model = Catador
7
+ fields = "__all__"
8
+ widgets = {
9
+ "usuarioCatador": forms.TextInput( attrs={ "class": "ct-inputs-pos-cata bg-gray-500 text-center w-full p-1 rounded-lg text-white" } ),
10
+ "nombre": forms.TextInput( attrs={ "class": "ct-inputs-pos-cata bg-gray-500 text-center w-full p-1 rounded-lg text-white" } ),
11
+ "apellido": forms.TextInput( attrs={ "class": "ct-inputs-pos-cata bg-gray-500 text-center w-full p-1 rounded-lg text-white" } ),
12
+ "telefono": forms.NumberInput( attrs={ "class": "ct-inputs-pos-cata bg-gray-500 text-center w-full p-1 rounded-lg text-white", "max": "10", "min": "10" } ),
13
+ "correo": forms.EmailInput( attrs={ "class": "ct-inputs-pos-cata bg-gray-500 text-center w-full p-1 rounded-lg text-white" } ),
14
+ "fechaNacimiento": forms.DateTimeInput( attrs={ "class": "ct-inputs-pos-cata bg-gray-500 text-center w-full p-1 rounded-lg text-white", "type": "date", }, format="%d-%m-%y" ),
15
+ }
16
+
17
+ def clean(self):
18
+ data_cleand = super().clean()
19
+
20
+ phone = data_cleand["telefono"]
21
+ size_phone = len(str(abs(phone)))
22
+ print("tamano de telefono", size_phone)
23
+ if size_phone != 10:
24
+ self.add_error("telefono", "telefono debe tener 10 digitos")
25
+ return data_cleand
tecnicas/static/img/{people.webp → pn_gc_people.webp} RENAMED
File without changes
tecnicas/templates/tecnicas/catador-crear.html ADDED
@@ -0,0 +1,102 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {% extends 'tecnicas/base.html' %}
2
+
3
+ {% block title %}Crear Catador{% endblock %}
4
+
5
+ {% block content %}
6
+ <article class="w-full flex flex-col justify-center items-center bg-gray-600 my-10">
7
+ <article class="flex flex-col gap-4 bg-gray-400 md:p-10 p-5 rounded-2xl lg:w-4xl w-full">
8
+ <header class="flex-1 flex flex-col gap-7">
9
+ <div class="bg-gray-300 p-8 text-2xl font-bold rounded-2xl text-center">
10
+ <h1>Creando Catador</h1>
11
+ </div>
12
+ </header>
13
+ <section>
14
+ {% if error %}
15
+ <p class="ct-notificacion bg-red-400 py-4 text-2xl tracking-wide font-bold text-center capitalize">
16
+ {{ error }}
17
+ </p>
18
+ {% endif %}
19
+ {% if message %}
20
+ <p class="ct-notificacion bg-green-500 py-4 text-2xl tracking-wide font-bold text-center capitalize">
21
+ {{ message }}
22
+ </p>
23
+ {% endif %}
24
+ <form action="" method="post" class="flex flex-col gap-5">
25
+ {% csrf_token %}
26
+ <h2 class="text-2xl mb-2 font-bold">Ingrese los datos</h2>
27
+
28
+ <section class="grid grid-cols-2 max-sm:grid-cols-1 [&>label]:px-6 max-sm:[&>label]:px-2">
29
+ <label for="{{ form_cata.usuarioCatador.id_for_label }}"
30
+ class="text-lg flex flex-col px-2 w-full font-medium tracking-wide mb-4">
31
+ <p class="capitalize font-bold">Nombre de usuario:</p>
32
+ {{ form_cata.usuarioCatador }}
33
+ {% if form_cata.usuarioCatador.errors %}
34
+ <small class="capitalize bg-red-400 px-5 tracking-wider rounded">
35
+ el nombre de usuario ya esta en uso
36
+ </small>
37
+ {% endif %}
38
+ </label>
39
+ <label for="{{ form_cata.nombre.id_for_label }}"
40
+ class="text-lg flex flex-col px-2 w-full font-medium tracking-wide mb-4">
41
+ <p class="capitalize font-bold">nombre del catador:</p>
42
+ {{ form_cata.nombre }}
43
+ </label>
44
+ <label for="{{ form_cata.apellido.id_for_label }}"
45
+ class="text-lg flex flex-col px-2 w-full font-medium tracking-wide mb-4">
46
+ <p class="capitalize font-bold">apellido del catador:</p>
47
+ {{ form_cata.apellido }}
48
+ </label>
49
+ <label for="{{ form_cata.telefono.id_for_label }}"
50
+ class="text-lg flex flex-col px-2 w-full font-medium tracking-wide mb-4">
51
+ <p class="capitalize font-bold">telefono:</p>
52
+ {{ form_cata.telefono }}
53
+ {% if form_cata.telefono.errors %}
54
+ <small class="ct-notificacion capitalize bg-red-400 px-5 tracking-wider rounded">
55
+ {{ form_cata.telefono.errors}}
56
+ </small>
57
+ {% endif %}
58
+ </label>
59
+ <label for="{{ form_cata.correo.id_for_label }}"
60
+ class="text-lg flex flex-col px-2 w-full font-medium tracking-wide mb-4">
61
+ <p class="capitalize font-bold">correo:</p>
62
+ {{ form_cata.correo }}
63
+ </label>
64
+ <label for="{{ form_cata.fechaNacimiento.id_for_label }}"
65
+ class="text-lg flex flex-col px-2 w-full font-medium tracking-wide mb-4">
66
+ <p class="capitalize font-bold">fecha de nacimiento:</p>
67
+ {{ form_cata.fechaNacimiento }}
68
+ </label>
69
+ </section>
70
+ <section class="cs-escalas-radio flex justify-center items-center gap-4">
71
+ <button type="submit"
72
+ class="uppercase text-lg tracking-wider font-medium p-2 px-4 border-b-2 active:border-b-0 active:border-t-2 border-green-800 transition-all rounded-xl bg-green-600 active:bg-green-400 text-white w-fit">
73
+ crear catador
74
+ </button>
75
+ <button type="submit"
76
+ class="uppercase text-lg tracking-wider font-medium p-2 px-4 border-b-2 active:border-b-0 active:border-t-2 border-yellow-800 transition-all rounded-xl bg-yellow-600 active:bg-yellow-400 text-white w-fit">
77
+ regresar
78
+ </button>
79
+ </section>
80
+ </form>
81
+ </section>
82
+ </article>
83
+ </article>
84
+ {% endblock %}
85
+
86
+ {% block extra_js %}
87
+ <script>
88
+ const notifiactions = document.getElementsByClassName("ct-notificacion")
89
+ const inputs = document.getElementsByClassName("ct-inputs-pos-cata")
90
+
91
+ for (let index = 0; index < inputs.length; index++) {
92
+ inputs.item(index).addEventListener("change", hiddenErrorAndMessages)
93
+ }
94
+
95
+ function hiddenErrorAndMessages (e) {
96
+ for (let index = 0; index < notifiactions.length; index++) {
97
+ console.log("Oculto")
98
+ notifiactions.item(index).classList.add("hidden")
99
+ }
100
+ }
101
+ </script>
102
+ {% endblock %}
tecnicas/templates/tecnicas/catadores-panel.html CHANGED
@@ -14,21 +14,23 @@
14
  class="text-white bg-blue-600 hover:bg-blue-700 active:outline-none active:ring-4 active:ring-blue-300 font-medium rounded-xl text-xl p-4 text-center uppercase">Panel
15
  principal</a>
16
  <div class="w-full h-60 bg-gray-200 rounded-2xl relative">
17
- <img src="{% static 'img/pn_gc_test.webp' %}"
18
- alt="un hombre en smokin probando vino" class="h-full w-full object-cover rounded-xl">
19
  </div>
20
  </header>
21
  <section class="flex-1 flex flex-col gap-7">
22
  <div class="w-full h-40 rounded-2xl">
23
- <img src="https://cdn.pixabay.com/photo/2020/06/08/16/19/woman-5275027_640.jpg"
24
- alt="varias personas en fila" class="w-full h-full object-cover rounded-xl">
25
  </div>
 
 
 
 
26
  <button type="button"
27
- class="flex-1 text-white bg-green-600 hover:bg-green-700 active:outline-none active:ring-4 active:ring-green-300 font-medium rounded-xl text-xl p-4 w-full text-center uppercase">Crear
28
- Cadator</button>
29
- <button type="button"
30
- class="flex-1 text-white bg-yellow-600 hover:bg-yellow-700 active:outline-none active:ring-4 active:ring-yellow-300 font-medium rounded-xl text-xl p-4 w-full text-center uppercase">Buscar
31
- Catador</button>
32
  </section>
33
  </article>
34
  </article>
 
14
  class="text-white bg-blue-600 hover:bg-blue-700 active:outline-none active:ring-4 active:ring-blue-300 font-medium rounded-xl text-xl p-4 text-center uppercase">Panel
15
  principal</a>
16
  <div class="w-full h-60 bg-gray-200 rounded-2xl relative">
17
+ <img src="{% static 'img/pn_gc_test.webp' %}" alt="un hombre en smokin probando vino"
18
+ class="h-full w-full object-cover rounded-xl">
19
  </div>
20
  </header>
21
  <section class="flex-1 flex flex-col gap-7">
22
  <div class="w-full h-40 rounded-2xl">
23
+ <img src="{% static 'img/pn_gc_people.webp' %}" alt="varias personas en fila"
24
+ class="w-full h-full object-cover rounded-xl">
25
  </div>
26
+ <a class="flex-1 text-white tracking-wider font-bold bg-green-600 border-green-800 border-r-4 border-b-4 active:border-r-0 active:border-b-0 active:border-t-4 active:border-l-4 transition-all rounded-xl text-xl p-4 flex justify-center items-center uppercase"
27
+ href="{% url 'cata_system:crear_catador' %}">
28
+ Crear Cadator
29
+ </a>
30
  <button type="button"
31
+ class="flex-1 text-white tracking-wider font-bold bg-yellow-600 border-yellow-800 border-r-4 border-b-4 active:border-r-0 active:border-b-0 active:border-t-4 active:border-l-4 transition-all rounded-xl text-xl p-4 text-center uppercase">
32
+ Buscar Catador
33
+ </button>
 
 
34
  </section>
35
  </article>
36
  </article>
tecnicas/urls.py CHANGED
@@ -15,4 +15,5 @@ urlpatterns = [
15
  path("panel-configuracion-tags", views.configuracionPanelTags, name="panel_configuracion_tags"),
16
  path("panel-configuracion-words", views.configurationsPanelWords, name="panel_configuracion_words"),
17
  path("nueva-etiqueta", views.newTag, name="nueva_etiqueta"),
 
18
  ]
 
15
  path("panel-configuracion-tags", views.configuracionPanelTags, name="panel_configuracion_tags"),
16
  path("panel-configuracion-words", views.configurationsPanelWords, name="panel_configuracion_words"),
17
  path("nueva-etiqueta", views.newTag, name="nueva_etiqueta"),
18
+ path("crear-catador", views.crearCatador, name="crear_catador"),
19
  ]
tecnicas/views/__init__.py CHANGED
@@ -7,4 +7,5 @@ from .seleccion_tecnica import selecionTecnica
7
  from .configuration_panel_basic import configuracionPanelBasic
8
  from .configuration_panel_tags import configuracionPanelTags
9
  from .configuration_panel_words import configurationsPanelWords
10
- from .api_tag import newTag
 
 
7
  from .configuration_panel_basic import configuracionPanelBasic
8
  from .configuration_panel_tags import configuracionPanelTags
9
  from .configuration_panel_words import configurationsPanelWords
10
+ from .api_tag import newTag
11
+ from .catador_create import crearCatador
tecnicas/views/catador_create.py ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from django.http import HttpRequest
2
+ from django.forms import ValidationError
3
+ from django.shortcuts import render
4
+ from ..forms import CatadorForm
5
+
6
+ def crearCatador(req : HttpRequest):
7
+ if req.method == "GET":
8
+ formCatador = CatadorForm()
9
+
10
+ context = {
11
+ "form_cata": formCatador
12
+ }
13
+
14
+ return render(req, "tecnicas/catador-crear.html", context)
15
+ elif req.method == "POST":
16
+ formCatadorValues = CatadorForm(req.POST)
17
+ context = {
18
+ "form_cata": formCatadorValues
19
+ }
20
+
21
+ if formCatadorValues.is_valid():
22
+ try:
23
+ formCatadorValues.save()
24
+ context["message"] = "datos guardados"
25
+ context["form_cata"] = CatadorForm()
26
+ except ValidationError:
27
+ context["error"] = "nombre de usuario en uso"
28
+ return render(req, "tecnicas/catador-crear.html", context)
29
+
30
+ return render(req, "tecnicas/catador-crear.html", context)
31
+ else:
32
+ context["error"] = "datos no validos"
33
+ return render(req, "tecnicas/catador-crear.html", context)