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

Se implementa la busqueda de un catador por nombre de usuario

Browse files
tecnicas/forms/catador_form.py CHANGED
@@ -6,12 +6,12 @@ class CatadorForm(forms.ModelForm):
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):
 
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 disabled:bg-gray-700" } ),
10
+ "nombre": forms.TextInput( attrs={ "class": "ct-inputs-pos-cata bg-gray-500 text-center w-full p-1 rounded-lg text-white disabled:bg-gray-700" } ),
11
+ "apellido": forms.TextInput( attrs={ "class": "ct-inputs-pos-cata bg-gray-500 text-center w-full p-1 rounded-lg text-white disabled:bg-gray-700" } ),
12
+ "telefono": forms.NumberInput( attrs={ "class": "ct-inputs-pos-cata bg-gray-500 text-center w-full p-1 rounded-lg text-white disabled:bg-gray-700", "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 disabled:bg-gray-700" } ),
14
+ "fechaNacimiento": forms.DateInput( attrs={ "class": "ct-inputs-pos-cata bg-gray-500 text-center w-full p-1 rounded-lg text-white disabled:bg-gray-700", "type": "date", } ),
15
  }
16
 
17
  def clean(self):
tecnicas/templates/tecnicas/catador-buscar.html ADDED
@@ -0,0 +1,142 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {% extends 'tecnicas/base.html' %}
2
+
3
+ {% block title %}Buscar 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 capitalize">
10
+ <h1>buscando catatador</h1>
11
+ </div>
12
+ </header>
13
+ <form action="" method="get" class="flex flex-col gap-5">
14
+ <h2 class="text-2xl mb-2 font-bold">Ingrese el nombre de usuario del catador</h2>
15
+ <section class="">
16
+ <label for="usuario" class="text-lg flex flex-col px-2 w-full font-medium tracking-wide mb-4">
17
+ <div class="flex flex-wrap gap-4 justify-center items-center">
18
+ <p class="capitalize font-bold">nombre de usuario:</p>
19
+ <input id="usuario" type="text" class="bg-gray-500 text-center w-fit p-1 rounded-lg text-white"
20
+ name="user" required>
21
+ <button type="submit"
22
+ 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">
23
+ buscar
24
+ </button>
25
+ <a href="{% url 'cata_system:panel_catadores' %}"
26
+ 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">
27
+ regresar
28
+ </a>
29
+ </div>
30
+ {% if catador.errors %}
31
+ <small class="capitalize bg-red-400 px-5 tracking-wider rounded">
32
+ {{ catador.errors }}
33
+ </small>
34
+ {% endif %}
35
+ </label>
36
+ </section>
37
+ </form>
38
+ {% if form_catador %}
39
+ <form action="" method="post">
40
+ {% csrf_token %}
41
+ <section class="grid grid-cols-2 max-sm:grid-cols-1 [&>label]:px-6 max-sm:[&>label]:px-2">
42
+ <label for="{{ form_catador.usuarioCatador.id_for_label }}"
43
+ class="text-lg flex flex-col px-2 w-full font-medium tracking-wide mb-4">
44
+ <p class="capitalize font-bold">Nombre de usuario:</p>
45
+ {{ form_catador.usuarioCatador }}
46
+ {% if form_catador.usuarioCatador.errors %}
47
+ <small class="capitalize bg-red-400 px-5 tracking-wider rounded">
48
+ el nombre de usuario ya esta en uso
49
+ </small>
50
+ {% endif %}
51
+ </label>
52
+ <label for="{{ form_catador.nombre.id_for_label }}"
53
+ class="text-lg flex flex-col px-2 w-full font-medium tracking-wide mb-4">
54
+ <p class="capitalize font-bold">nombre del catador:</p>
55
+ {{ form_catador.nombre }}
56
+ </label>
57
+ <label for="{{ form_catador.apellido.id_for_label }}"
58
+ class="text-lg flex flex-col px-2 w-full font-medium tracking-wide mb-4">
59
+ <p class="capitalize font-bold">apellido del catador:</p>
60
+ {{ form_catador.apellido }}
61
+ </label>
62
+ <label for="{{ form_catador.telefono.id_for_label }}"
63
+ class="text-lg flex flex-col px-2 w-full font-medium tracking-wide mb-4">
64
+ <p class="capitalize font-bold">telefono:</p>
65
+ {{ form_catador.telefono }}
66
+ {% if form_catador.telefono.errors %}
67
+ <small class="ct-notificacion capitalize bg-red-400 px-5 tracking-wider rounded">
68
+ {{ form_catador.telefono.errors}}
69
+ </small>
70
+ {% endif %}
71
+ </label>
72
+ <label for="{{ form_catador.correo.id_for_label }}"
73
+ class="text-lg flex flex-col px-2 w-full font-medium tracking-wide mb-4">
74
+ <p class="capitalize font-bold">correo:</p>
75
+ {{ form_catador.correo }}
76
+ </label>
77
+ <label for="{{ form_catador.fechaNacimiento.id_for_label }}"
78
+ class="text-lg flex flex-col px-2 w-full font-medium tracking-wide mb-4">
79
+ <p class="capitalize font-bold">fecha de nacimiento:</p>
80
+ {{ form_catador.fechaNacimiento }}
81
+ </label>
82
+ </section>
83
+ <section class="cs-escalas-radio flex justify-center items-center gap-4">
84
+ <button type="button"
85
+ class="ct-btn-actualizar uppercase text-lg tracking-wider font-medium p-2 px-4 border-b-2 active:border-b-0 active:border-t-2 border-purple-800 transition-all rounded-xl bg-purple-600 active:bg-purple-400 text-white w-fit"
86
+ onclick="enableInputs()">
87
+ actualizar
88
+ </button>
89
+ <button type="button"
90
+ class="ct-btn-guardar 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 hidden">
91
+ guardar
92
+ </button>
93
+ <button type="button"
94
+ class="ct-btn-cancel 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 hidden"
95
+ onclick="changeButtons(disableInputs)">
96
+ cancelar
97
+ </button>
98
+ </section>
99
+ </form>
100
+ {% endif %}
101
+ </article>
102
+ </article>
103
+ {% endblock %}
104
+
105
+ {% block extra_js %}
106
+ <script>
107
+ const inputs = document.getElementsByClassName("ct-inputs-pos-cata")
108
+ disableInputs()
109
+
110
+ function disableInputs () {
111
+ for (let index = 0; index < inputs.length; index++) {
112
+ inputs.item(index).disabled = true
113
+ }
114
+ }
115
+
116
+ function enableInputs () {
117
+ for (let index = 0; index < inputs.length; index++) {
118
+ inputs.item(index).disabled = false
119
+ }
120
+ changeButtons()
121
+ }
122
+
123
+ function changeButtons (callBack = function () { }) {
124
+ const btnUpdate = document.getElementsByClassName("ct-btn-actualizar")[0]
125
+ const btnSave = document.getElementsByClassName("ct-btn-guardar")[0]
126
+ const btnCancel = document.getElementsByClassName("ct-btn-cancel")[0]
127
+
128
+ if (btnUpdate.classList.contains("hidden")) {
129
+ btnUpdate.classList.remove("hidden")
130
+ btnSave.classList.add("hidden")
131
+ btnCancel.classList.add("hidden")
132
+ } else {
133
+ btnUpdate.classList.add("hidden")
134
+ btnSave.classList.remove("hidden")
135
+ btnCancel.classList.remove("hidden")
136
+ }
137
+
138
+ callBack()
139
+ }
140
+
141
+ </script>
142
+ {% endblock %}
tecnicas/templates/tecnicas/catador-crear.html CHANGED
@@ -72,10 +72,10 @@
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>
 
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
+ <a href="{% url 'cata_system:panel_catadores' %}"
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
+ </a>
79
  </section>
80
  </form>
81
  </section>
tecnicas/templates/tecnicas/catadores-panel.html CHANGED
@@ -27,10 +27,10 @@
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>
 
27
  href="{% url 'cata_system:crear_catador' %}">
28
  Crear Cadator
29
  </a>
30
+ <a href="{% url 'cata_system:buscar_catador' %}"
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 flex justify-center items-center uppercase">
32
  Buscar Catador
33
+ </a>
34
  </section>
35
  </article>
36
  </article>
tecnicas/urls.py CHANGED
@@ -16,4 +16,5 @@ urlpatterns = [
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
  ]
 
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
+ path("buscar-catador", views.searchCatador, name="buscar_catador"),
20
  ]
tecnicas/views/__init__.py CHANGED
@@ -8,4 +8,5 @@ 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
 
 
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
12
+ from .catador_search import searchCatador
tecnicas/views/catador_search.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from django.http import HttpRequest
2
+ from django.shortcuts import render
3
+ from django.db import Error
4
+ from ..forms import CatadorForm
5
+ from ..models import Catador
6
+
7
+ def searchCatador(req : HttpRequest):
8
+ if req.method == "GET":
9
+ try:
10
+ user = req.GET["user"]
11
+ except:
12
+ user = False
13
+
14
+ context = {}
15
+ if user:
16
+ try:
17
+ catador = Catador.objects.get(usuarioCatador=user)
18
+ print(catador.fechaNacimiento)
19
+ context["form_catador"] = CatadorForm(instance=catador)
20
+ except Error:
21
+ context["error"] = "usuario no encontrado"
22
+
23
+ return render(req, "tecnicas/catador-buscar.html", context)
24
+
25
+ return render(req, "tecnicas/catador-buscar.html")