Spaces:
Sleeping
Sleeping
Se actulizan campos para crear, actualiza y listar Catadores
Browse files- tecnicas/forms/catador_form.py +144 -21
- tecnicas/static/js/catador-craete.js +0 -1
- tecnicas/templates/tecnicas/components/item-tester.html +5 -3
- tecnicas/templates/tecnicas/manage_tester/catador-buscar.html +56 -20
- tecnicas/templates/tecnicas/manage_tester/catador-crear.html +57 -16
- tecnicas/templates/tecnicas/manage_tester/catador-lista.html +1 -1
- tecnicas/views/tester_management/tester_create.py +40 -14
- tecnicas/views/tester_management/tester_search.py +54 -38
tecnicas/forms/catador_form.py
CHANGED
|
@@ -1,25 +1,148 @@
|
|
| 1 |
from django import forms
|
| 2 |
-
from
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
|
| 17 |
def clean(self):
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
print(
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
from django import forms
|
| 2 |
+
from django.contrib.auth.models import User
|
| 3 |
+
from django.core.validators import RegexValidator, EmailValidator
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
class CatadorForm(forms.Form):
|
| 7 |
+
styles_input = "ct-inputs-pos-cata bg-surface-ligt text-center w-full p-1 rounded-lg text-black disabled:bg-surface-alter-card"
|
| 8 |
+
|
| 9 |
+
nombre_usuario = forms.CharField(
|
| 10 |
+
label="Nombre de usuario",
|
| 11 |
+
max_length=30,
|
| 12 |
+
min_length=5,
|
| 13 |
+
required=True,
|
| 14 |
+
validators=[
|
| 15 |
+
RegexValidator(
|
| 16 |
+
regex=r'^(?![0-9._])[A-Za-z0-9._]+$',
|
| 17 |
+
message=(
|
| 18 |
+
"El nombre de usuario debe iniciar con una letra y solo puede "
|
| 19 |
+
"contener letras, números, puntos y guiones bajos."
|
| 20 |
+
),
|
| 21 |
+
code='invalid_username'
|
| 22 |
+
)
|
| 23 |
+
],
|
| 24 |
+
widget=forms.TextInput(
|
| 25 |
+
attrs={
|
| 26 |
+
"placeholder": "Ej. mario_hugo23",
|
| 27 |
+
"class": styles_input,
|
| 28 |
+
}
|
| 29 |
+
)
|
| 30 |
+
)
|
| 31 |
+
|
| 32 |
+
nombre = forms.CharField(
|
| 33 |
+
label="Nombre del catador",
|
| 34 |
+
max_length=50,
|
| 35 |
+
required=True,
|
| 36 |
+
validators=[
|
| 37 |
+
RegexValidator(
|
| 38 |
+
regex=r'^[A-Za-zÁÉÍÓÚáéíóúÑñ\s]+$',
|
| 39 |
+
message="El nombre solo puede contener letras y espacios."
|
| 40 |
+
)
|
| 41 |
+
],
|
| 42 |
+
widget=forms.TextInput(
|
| 43 |
+
attrs={
|
| 44 |
+
"placeholder": "Ej. Mario",
|
| 45 |
+
"class": styles_input,
|
| 46 |
+
}
|
| 47 |
+
)
|
| 48 |
+
)
|
| 49 |
+
|
| 50 |
+
apellido = forms.CharField(
|
| 51 |
+
label="Apellido del catador",
|
| 52 |
+
max_length=50,
|
| 53 |
+
required=True,
|
| 54 |
+
validators=[
|
| 55 |
+
RegexValidator(
|
| 56 |
+
regex=r'^[A-Za-zÁÉÍÓÚáéíóúÑñ\s]+$',
|
| 57 |
+
message="El apellido solo puede contener letras y espacios."
|
| 58 |
+
)
|
| 59 |
+
],
|
| 60 |
+
widget=forms.TextInput(
|
| 61 |
+
attrs={
|
| 62 |
+
"placeholder": "Ej. Sánchez",
|
| 63 |
+
"class": styles_input,
|
| 64 |
+
}
|
| 65 |
+
)
|
| 66 |
+
)
|
| 67 |
+
|
| 68 |
+
telefono = forms.CharField(
|
| 69 |
+
label="Teléfono",
|
| 70 |
+
max_length=10,
|
| 71 |
+
required=True,
|
| 72 |
+
validators=[
|
| 73 |
+
RegexValidator(
|
| 74 |
+
regex=r'^\d{10}$',
|
| 75 |
+
message="El teléfono debe contener solo números (puede incluir + al inicio)."
|
| 76 |
+
)
|
| 77 |
+
],
|
| 78 |
+
widget=forms.TextInput(
|
| 79 |
+
attrs={
|
| 80 |
+
"placeholder": "Ej. 5512345678",
|
| 81 |
+
"class": styles_input,
|
| 82 |
+
"type": "tel",
|
| 83 |
+
}
|
| 84 |
+
)
|
| 85 |
+
)
|
| 86 |
+
|
| 87 |
+
correo = forms.EmailField(
|
| 88 |
+
label="Correo electrónico",
|
| 89 |
+
required=True,
|
| 90 |
+
validators=[EmailValidator(
|
| 91 |
+
message="Introduce un correo electrónico válido.")],
|
| 92 |
+
widget=forms.EmailInput(
|
| 93 |
+
attrs={
|
| 94 |
+
"placeholder": "Ej. mario@example.com",
|
| 95 |
+
"class": styles_input,
|
| 96 |
+
}
|
| 97 |
+
)
|
| 98 |
+
)
|
| 99 |
+
|
| 100 |
+
fecha_nacimiento = forms.DateField(
|
| 101 |
+
label="Fecha de nacimiento",
|
| 102 |
+
required=True,
|
| 103 |
+
widget=forms.DateInput(
|
| 104 |
+
attrs={
|
| 105 |
+
"type": "date",
|
| 106 |
+
"class": styles_input,
|
| 107 |
+
}
|
| 108 |
+
),
|
| 109 |
+
error_messages={
|
| 110 |
+
"invalid": "Introduce una fecha válida (DD-MM-YYYY)."
|
| 111 |
}
|
| 112 |
+
)
|
| 113 |
+
|
| 114 |
+
GENERO_OPCIONES = [
|
| 115 |
+
('Hombre', 'Hombre'),
|
| 116 |
+
('Mujer', 'Mujer')
|
| 117 |
+
]
|
| 118 |
+
|
| 119 |
+
genero = forms.ChoiceField(
|
| 120 |
+
label="Género",
|
| 121 |
+
required=True,
|
| 122 |
+
choices=GENERO_OPCIONES,
|
| 123 |
+
widget=forms.RadioSelect(
|
| 124 |
+
attrs={
|
| 125 |
+
"class": "ct-inputs-pos-cata radio radio-warning checked:bg-btn-secondary mx-2 bg-surface-ligt disabled:bg-ct-error"
|
| 126 |
+
}
|
| 127 |
+
)
|
| 128 |
+
)
|
| 129 |
+
|
| 130 |
+
is_update = forms.BooleanField(
|
| 131 |
+
initial=False,
|
| 132 |
+
required=False,
|
| 133 |
+
widget=forms.HiddenInput()
|
| 134 |
+
)
|
| 135 |
|
| 136 |
def clean(self):
|
| 137 |
+
cleaned_data = super().clean()
|
| 138 |
+
username = cleaned_data.get("nombre_usuario")
|
| 139 |
+
is_update = cleaned_data.get("is_update")
|
| 140 |
+
|
| 141 |
+
print(username, is_update)
|
| 142 |
+
|
| 143 |
+
if not is_update:
|
| 144 |
+
if User.objects.filter(username__iexact=username).exists():
|
| 145 |
+
raise forms.ValidationError(
|
| 146 |
+
"Este nombre de usuario ya está registrado.")
|
| 147 |
+
|
| 148 |
+
return cleaned_data
|
tecnicas/static/js/catador-craete.js
CHANGED
|
@@ -7,7 +7,6 @@ for (let index = 0; index < inputs.length; index++) {
|
|
| 7 |
|
| 8 |
function hiddenErrorAndMessages(e) {
|
| 9 |
for (let index = 0; index < notifiactions.length; index++) {
|
| 10 |
-
console.log("Oculto");
|
| 11 |
notifiactions.item(index).classList.add("hidden");
|
| 12 |
}
|
| 13 |
}
|
|
|
|
| 7 |
|
| 8 |
function hiddenErrorAndMessages(e) {
|
| 9 |
for (let index = 0; index < notifiactions.length; index++) {
|
|
|
|
| 10 |
notifiactions.item(index).classList.add("hidden");
|
| 11 |
}
|
| 12 |
}
|
tecnicas/templates/tecnicas/components/item-tester.html
CHANGED
|
@@ -29,9 +29,11 @@
|
|
| 29 |
</div>
|
| 30 |
|
| 31 |
<div class="card-actions justify-end mt-3">
|
| 32 |
-
<
|
| 33 |
-
|
| 34 |
-
|
|
|
|
|
|
|
| 35 |
</div>
|
| 36 |
</div>
|
| 37 |
</div>
|
|
|
|
| 29 |
</div>
|
| 30 |
|
| 31 |
<div class="card-actions justify-end mt-3">
|
| 32 |
+
<a href="{% url 'cata_system:buscar_catador' %}?user={{ tester.user.username }}" class="w-full">
|
| 33 |
+
<button class="btn bg-btn-primary border-0 block w-full btn-push">
|
| 34 |
+
Actualizar datos
|
| 35 |
+
</button>
|
| 36 |
+
</a>
|
| 37 |
</div>
|
| 38 |
</div>
|
| 39 |
</div>
|
tecnicas/templates/tecnicas/manage_tester/catador-buscar.html
CHANGED
|
@@ -5,7 +5,7 @@
|
|
| 5 |
|
| 6 |
{% block content %}
|
| 7 |
<article class="cts-container-main">
|
| 8 |
-
<article class="cts-wrap-content">
|
| 9 |
<header class="flex-1 flex flex-col gap-7">
|
| 10 |
<div class="bg-surface-card p-8 text-black text-2xl font-bold rounded-2xl text-center capitalize">
|
| 11 |
<h1>buscando catatador</h1>
|
|
@@ -52,50 +52,86 @@
|
|
| 52 |
</p>
|
| 53 |
{% endif %}
|
| 54 |
|
| 55 |
-
{% if
|
| 56 |
<form action="" method="post" class="text-black">
|
| 57 |
{% csrf_token %}
|
| 58 |
<section class="grid grid-cols-2 max-sm:grid-cols-1 [&>label]:px-6 max-sm:[&>label]:px-2">
|
| 59 |
-
<label for="{{
|
| 60 |
class="text-lg flex flex-col px-2 w-full font-medium tracking-wide mb-4">
|
| 61 |
<p class="capitalize font-bold">Nombre de usuario:</p>
|
| 62 |
-
{{
|
| 63 |
-
{% if
|
| 64 |
-
<small class="capitalize bg-
|
| 65 |
-
|
| 66 |
</small>
|
| 67 |
{% endif %}
|
| 68 |
</label>
|
| 69 |
-
<label for="{{
|
| 70 |
class="text-lg flex flex-col px-2 w-full font-medium tracking-wide mb-4">
|
| 71 |
<p class="capitalize font-bold">nombre del catador:</p>
|
| 72 |
-
{{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 73 |
</label>
|
| 74 |
-
<label for="{{
|
| 75 |
class="text-lg flex flex-col px-2 w-full font-medium tracking-wide mb-4">
|
| 76 |
<p class="capitalize font-bold">apellido del catador:</p>
|
| 77 |
-
{{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 78 |
</label>
|
| 79 |
-
<label for="{{
|
| 80 |
class="text-lg flex flex-col px-2 w-full font-medium tracking-wide mb-4">
|
| 81 |
<p class="capitalize font-bold">telefono:</p>
|
| 82 |
-
{{
|
| 83 |
-
{% if
|
| 84 |
-
<small class="ct-notificacion capitalize bg-
|
| 85 |
-
{{
|
| 86 |
</small>
|
| 87 |
{% endif %}
|
| 88 |
</label>
|
| 89 |
-
<label for="{{
|
| 90 |
class="text-lg flex flex-col px-2 w-full font-medium tracking-wide mb-4">
|
| 91 |
<p class="capitalize font-bold">correo:</p>
|
| 92 |
-
{{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 93 |
</label>
|
| 94 |
-
<label for="{{
|
| 95 |
class="text-lg flex flex-col px-2 w-full font-medium tracking-wide mb-4">
|
| 96 |
<p class="capitalize font-bold">fecha de nacimiento:</p>
|
| 97 |
-
{{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 98 |
</label>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 99 |
</section>
|
| 100 |
<section class="cs-escalas-radio flex justify-center items-center gap-4">
|
| 101 |
<button type="button"
|
|
|
|
| 5 |
|
| 6 |
{% block content %}
|
| 7 |
<article class="cts-container-main">
|
| 8 |
+
<article class="cts-wrap-content max-w-4xl">
|
| 9 |
<header class="flex-1 flex flex-col gap-7">
|
| 10 |
<div class="bg-surface-card p-8 text-black text-2xl font-bold rounded-2xl text-center capitalize">
|
| 11 |
<h1>buscando catatador</h1>
|
|
|
|
| 52 |
</p>
|
| 53 |
{% endif %}
|
| 54 |
|
| 55 |
+
{% if form_cata %}
|
| 56 |
<form action="" method="post" class="text-black">
|
| 57 |
{% csrf_token %}
|
| 58 |
<section class="grid grid-cols-2 max-sm:grid-cols-1 [&>label]:px-6 max-sm:[&>label]:px-2">
|
| 59 |
+
<label for="{{ form_cata.nombre_usuario.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">Nombre de usuario:</p>
|
| 62 |
+
{{ form_cata.nombre_usuario }}
|
| 63 |
+
{% if form_cata.nombre_usuario.errors %}
|
| 64 |
+
<small class="ct-notificacion capitalize bg-surface-general text-white px-5 tracking-wider rounded">
|
| 65 |
+
{{ form_cata.nombre_usuario.errors}}
|
| 66 |
</small>
|
| 67 |
{% endif %}
|
| 68 |
</label>
|
| 69 |
+
<label for="{{ form_cata.nombre.id_for_label }}"
|
| 70 |
class="text-lg flex flex-col px-2 w-full font-medium tracking-wide mb-4">
|
| 71 |
<p class="capitalize font-bold">nombre del catador:</p>
|
| 72 |
+
{{ form_cata.nombre }}
|
| 73 |
+
{% if form_cata.nombre.errors %}
|
| 74 |
+
<small class="ct-notificacion capitalize bg-surface-general text-white px-5 tracking-wider rounded">
|
| 75 |
+
{{ form_cata.nombre.errors}}
|
| 76 |
+
</small>
|
| 77 |
+
{% endif %}
|
| 78 |
</label>
|
| 79 |
+
<label for="{{ form_cata.apellido.id_for_label }}"
|
| 80 |
class="text-lg flex flex-col px-2 w-full font-medium tracking-wide mb-4">
|
| 81 |
<p class="capitalize font-bold">apellido del catador:</p>
|
| 82 |
+
{{ form_cata.apellido }}
|
| 83 |
+
{% if form_cata.apellido.errors %}
|
| 84 |
+
<small class="ct-notificacion capitalize bg-surface-general text-white px-5 tracking-wider rounded">
|
| 85 |
+
{{ form_cata.apellido.errors}}
|
| 86 |
+
</small>
|
| 87 |
+
{% endif %}
|
| 88 |
</label>
|
| 89 |
+
<label for="{{ form_cata.telefono.id_for_label }}"
|
| 90 |
class="text-lg flex flex-col px-2 w-full font-medium tracking-wide mb-4">
|
| 91 |
<p class="capitalize font-bold">telefono:</p>
|
| 92 |
+
{{ form_cata.telefono }}
|
| 93 |
+
{% if form_cata.telefono.errors %}
|
| 94 |
+
<small class="ct-notificacion capitalize bg-surface-general text-white px-5 tracking-wider rounded">
|
| 95 |
+
{{ form_cata.telefono.errors}}
|
| 96 |
</small>
|
| 97 |
{% endif %}
|
| 98 |
</label>
|
| 99 |
+
<label for="{{ form_cata.correo.id_for_label }}"
|
| 100 |
class="text-lg flex flex-col px-2 w-full font-medium tracking-wide mb-4">
|
| 101 |
<p class="capitalize font-bold">correo:</p>
|
| 102 |
+
{{ form_cata.correo }}
|
| 103 |
+
{% if form_cata.correo.errors %}
|
| 104 |
+
<small class="ct-notificacion capitalize bg-surface-general text-white px-5 tracking-wider rounded">
|
| 105 |
+
{{ form_cata.correo.errors}}
|
| 106 |
+
</small>
|
| 107 |
+
{% endif %}
|
| 108 |
</label>
|
| 109 |
+
<label for="{{ form_cata.fecha_nacimiento.id_for_label }}"
|
| 110 |
class="text-lg flex flex-col px-2 w-full font-medium tracking-wide mb-4">
|
| 111 |
<p class="capitalize font-bold">fecha de nacimiento:</p>
|
| 112 |
+
{{ form_cata.fecha_nacimiento }}
|
| 113 |
+
{% if form_cata.fecha_nacimiento.errors %}
|
| 114 |
+
<small class="ct-notificacion capitalize bg-surface-general text-white px-5 tracking-wider rounded">
|
| 115 |
+
{{ form_cata.fecha_nacimiento.errors}}
|
| 116 |
+
</small>
|
| 117 |
+
{% endif %}
|
| 118 |
</label>
|
| 119 |
+
<div class="text-lg flex flex-col px-6 w-full font-medium tracking-wide mb-4">
|
| 120 |
+
<p class="capitalize font-bold">Género:</p>
|
| 121 |
+
<div class="flex items-center space-x-4">
|
| 122 |
+
{% for choice in form_cata.genero %}
|
| 123 |
+
<label class="flex items-center space-x-2 cursor-pointer">
|
| 124 |
+
{{ choice.tag }}
|
| 125 |
+
<span class="capitalize font-semibold">{{ choice.choice_label }}</span>
|
| 126 |
+
</label>
|
| 127 |
+
{% endfor %}
|
| 128 |
+
</div>
|
| 129 |
+
{% if form_cata.genero.errors %}
|
| 130 |
+
<small class="ct-notificacion capitalize bg-surface-general text-white px-5 tracking-wider rounded">
|
| 131 |
+
{{ form_cata.genero.errors}}
|
| 132 |
+
</small>
|
| 133 |
+
{% endif %}
|
| 134 |
+
</div>
|
| 135 |
</section>
|
| 136 |
<section class="cs-escalas-radio flex justify-center items-center gap-4">
|
| 137 |
<button type="button"
|
tecnicas/templates/tecnicas/manage_tester/catador-crear.html
CHANGED
|
@@ -5,35 +5,34 @@
|
|
| 5 |
|
| 6 |
{% block content %}
|
| 7 |
<article class="cts-container-main">
|
| 8 |
-
<article class="cts-wrap-content">
|
| 9 |
<header class="flex flex-col gap-7">
|
| 10 |
<div class="bg-surface-card p-8 text-black text-2xl font-bold rounded-2xl text-center">
|
| 11 |
<h1>Creando Catador</h1>
|
| 12 |
</div>
|
| 13 |
</header>
|
| 14 |
-
<section class="text-black">
|
|
|
|
| 15 |
{% if error %}
|
| 16 |
-
|
| 17 |
-
{{ error }}
|
| 18 |
-
</p>
|
| 19 |
{% endif %}
|
| 20 |
{% if message %}
|
| 21 |
-
|
| 22 |
-
{{ message }}
|
| 23 |
-
</p>
|
| 24 |
{% endif %}
|
|
|
|
| 25 |
<form action="" method="post" class="flex flex-col gap-5">
|
| 26 |
{% csrf_token %}
|
| 27 |
<h2 class="text-2xl mb-2 font-bold">Ingrese los datos</h2>
|
| 28 |
|
| 29 |
<section class="grid grid-cols-2 max-sm:grid-cols-1 [&>label]:px-6 max-sm:[&>label]:px-2">
|
| 30 |
-
<label for="{{ form_cata.
|
| 31 |
class="text-lg flex flex-col px-2 w-full font-medium tracking-wide mb-4">
|
| 32 |
<p class="capitalize font-bold">Nombre de usuario:</p>
|
| 33 |
-
{{ form_cata.
|
| 34 |
-
{% if form_cata.
|
| 35 |
-
<small
|
| 36 |
-
|
|
|
|
| 37 |
</small>
|
| 38 |
{% endif %}
|
| 39 |
</label>
|
|
@@ -41,18 +40,31 @@
|
|
| 41 |
class="text-lg flex flex-col px-2 w-full font-medium tracking-wide mb-4">
|
| 42 |
<p class="capitalize font-bold">nombre del catador:</p>
|
| 43 |
{{ form_cata.nombre }}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
</label>
|
| 45 |
<label for="{{ form_cata.apellido.id_for_label }}"
|
| 46 |
class="text-lg flex flex-col px-2 w-full font-medium tracking-wide mb-4">
|
| 47 |
<p class="capitalize font-bold">apellido del catador:</p>
|
| 48 |
{{ form_cata.apellido }}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
</label>
|
| 50 |
<label for="{{ form_cata.telefono.id_for_label }}"
|
| 51 |
class="text-lg flex flex-col px-2 w-full font-medium tracking-wide mb-4">
|
| 52 |
<p class="capitalize font-bold">telefono:</p>
|
| 53 |
{{ form_cata.telefono }}
|
| 54 |
{% if form_cata.telefono.errors %}
|
| 55 |
-
<small
|
|
|
|
| 56 |
{{ form_cata.telefono.errors}}
|
| 57 |
</small>
|
| 58 |
{% endif %}
|
|
@@ -61,12 +73,41 @@
|
|
| 61 |
class="text-lg flex flex-col px-2 w-full font-medium tracking-wide mb-4">
|
| 62 |
<p class="capitalize font-bold">correo:</p>
|
| 63 |
{{ form_cata.correo }}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 64 |
</label>
|
| 65 |
-
<label for="{{ form_cata.
|
| 66 |
class="text-lg flex flex-col px-2 w-full font-medium tracking-wide mb-4">
|
| 67 |
<p class="capitalize font-bold">fecha de nacimiento:</p>
|
| 68 |
-
{{ form_cata.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 69 |
</label>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 70 |
</section>
|
| 71 |
<section class="cs-escalas-radio flex justify-center items-center gap-4">
|
| 72 |
<button type="submit"
|
|
|
|
| 5 |
|
| 6 |
{% block content %}
|
| 7 |
<article class="cts-container-main">
|
| 8 |
+
<article class="cts-wrap-content max-w-4xl">
|
| 9 |
<header class="flex flex-col gap-7">
|
| 10 |
<div class="bg-surface-card p-8 text-black text-2xl font-bold rounded-2xl text-center">
|
| 11 |
<h1>Creando Catador</h1>
|
| 12 |
</div>
|
| 13 |
</header>
|
| 14 |
+
<section class="text-black space-y-4">
|
| 15 |
+
|
| 16 |
{% if error %}
|
| 17 |
+
{% include "../components/error-message.html" with message=error %}
|
|
|
|
|
|
|
| 18 |
{% endif %}
|
| 19 |
{% if message %}
|
| 20 |
+
{% include "../components/error-message.html" with message=message %}
|
|
|
|
|
|
|
| 21 |
{% endif %}
|
| 22 |
+
|
| 23 |
<form action="" method="post" class="flex flex-col gap-5">
|
| 24 |
{% csrf_token %}
|
| 25 |
<h2 class="text-2xl mb-2 font-bold">Ingrese los datos</h2>
|
| 26 |
|
| 27 |
<section class="grid grid-cols-2 max-sm:grid-cols-1 [&>label]:px-6 max-sm:[&>label]:px-2">
|
| 28 |
+
<label for="{{ form_cata.nombre_usuario.id_for_label }}"
|
| 29 |
class="text-lg flex flex-col px-2 w-full font-medium tracking-wide mb-4">
|
| 30 |
<p class="capitalize font-bold">Nombre de usuario:</p>
|
| 31 |
+
{{ form_cata.nombre_usuario }}
|
| 32 |
+
{% if form_cata.nombre_usuario.errors %}
|
| 33 |
+
<small
|
| 34 |
+
class="ct-notificacion capitalize bg-surface-general text-white px-5 tracking-wider rounded">
|
| 35 |
+
{{ form_cata.nombre_usuario.errors}}
|
| 36 |
</small>
|
| 37 |
{% endif %}
|
| 38 |
</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 |
+
{% if form_cata.nombre.errors %}
|
| 44 |
+
<small
|
| 45 |
+
class="ct-notificacion capitalize bg-surface-general text-white px-5 tracking-wider rounded">
|
| 46 |
+
{{ form_cata.nombre.errors}}
|
| 47 |
+
</small>
|
| 48 |
+
{% endif %}
|
| 49 |
</label>
|
| 50 |
<label for="{{ form_cata.apellido.id_for_label }}"
|
| 51 |
class="text-lg flex flex-col px-2 w-full font-medium tracking-wide mb-4">
|
| 52 |
<p class="capitalize font-bold">apellido del catador:</p>
|
| 53 |
{{ form_cata.apellido }}
|
| 54 |
+
{% if form_cata.apellido.errors %}
|
| 55 |
+
<small
|
| 56 |
+
class="ct-notificacion capitalize bg-surface-general text-white px-5 tracking-wider rounded">
|
| 57 |
+
{{ form_cata.apellido.errors}}
|
| 58 |
+
</small>
|
| 59 |
+
{% endif %}
|
| 60 |
</label>
|
| 61 |
<label for="{{ form_cata.telefono.id_for_label }}"
|
| 62 |
class="text-lg flex flex-col px-2 w-full font-medium tracking-wide mb-4">
|
| 63 |
<p class="capitalize font-bold">telefono:</p>
|
| 64 |
{{ form_cata.telefono }}
|
| 65 |
{% if form_cata.telefono.errors %}
|
| 66 |
+
<small
|
| 67 |
+
class="ct-notificacion capitalize bg-surface-general text-white px-5 tracking-wider rounded">
|
| 68 |
{{ form_cata.telefono.errors}}
|
| 69 |
</small>
|
| 70 |
{% endif %}
|
|
|
|
| 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_cata.correo }}
|
| 76 |
+
{% if form_cata.correo.errors %}
|
| 77 |
+
<small
|
| 78 |
+
class="ct-notificacion capitalize bg-surface-general text-white px-5 tracking-wider rounded">
|
| 79 |
+
{{ form_cata.correo.errors}}
|
| 80 |
+
</small>
|
| 81 |
+
{% endif %}
|
| 82 |
</label>
|
| 83 |
+
<label for="{{ form_cata.fecha_nacimiento.id_for_label }}"
|
| 84 |
class="text-lg flex flex-col px-2 w-full font-medium tracking-wide mb-4">
|
| 85 |
<p class="capitalize font-bold">fecha de nacimiento:</p>
|
| 86 |
+
{{ form_cata.fecha_nacimiento }}
|
| 87 |
+
{% if form_cata.fecha_nacimiento.errors %}
|
| 88 |
+
<small
|
| 89 |
+
class="ct-notificacion capitalize bg-surface-general text-white px-5 tracking-wider rounded">
|
| 90 |
+
{{ form_cata.fecha_nacimiento.errors}}
|
| 91 |
+
</small>
|
| 92 |
+
{% endif %}
|
| 93 |
</label>
|
| 94 |
+
<div class="text-lg flex flex-col px-6 w-full font-medium tracking-wide mb-4">
|
| 95 |
+
<p class="capitalize font-bold">Género:</p>
|
| 96 |
+
<div class="flex items-center space-x-4">
|
| 97 |
+
{% for choice in form_cata.genero %}
|
| 98 |
+
<label class="flex items-center space-x-2 cursor-pointer">
|
| 99 |
+
{{ choice.tag }}
|
| 100 |
+
<span class="capitalize font-semibold">{{ choice.choice_label }}</span>
|
| 101 |
+
</label>
|
| 102 |
+
{% endfor %}
|
| 103 |
+
</div>
|
| 104 |
+
{% if form_cata.genero.errors %}
|
| 105 |
+
<small
|
| 106 |
+
class="ct-notificacion capitalize bg-surface-general text-white px-5 tracking-wider rounded">
|
| 107 |
+
{{ form_cata.genero.errors}}
|
| 108 |
+
</small>
|
| 109 |
+
{% endif %}
|
| 110 |
+
</div>
|
| 111 |
</section>
|
| 112 |
<section class="cs-escalas-radio flex justify-center items-center gap-4">
|
| 113 |
<button type="submit"
|
tecnicas/templates/tecnicas/manage_tester/catador-lista.html
CHANGED
|
@@ -22,7 +22,7 @@
|
|
| 22 |
{% if error %}
|
| 23 |
{% include "../components/error-message.html" with message=error %}
|
| 24 |
{% else %}
|
| 25 |
-
<div class="
|
| 26 |
{% for tester in testers %}
|
| 27 |
{% include "../components/item-tester.html" with tester=tester %}
|
| 28 |
{% endfor %}
|
|
|
|
| 22 |
{% if error %}
|
| 23 |
{% include "../components/error-message.html" with message=error %}
|
| 24 |
{% else %}
|
| 25 |
+
<div class="grid gap-4 md:grid-cols-1 md:grid-cols-2 lg:grid-cols-3 justify-center">
|
| 26 |
{% for tester in testers %}
|
| 27 |
{% include "../components/item-tester.html" with tester=tester %}
|
| 28 |
{% endfor %}
|
tecnicas/views/tester_management/tester_create.py
CHANGED
|
@@ -1,34 +1,60 @@
|
|
| 1 |
from django.http import HttpRequest
|
| 2 |
from django.forms import ValidationError
|
| 3 |
from django.shortcuts import render
|
| 4 |
-
from
|
|
|
|
|
|
|
|
|
|
| 5 |
|
| 6 |
|
| 7 |
def testerCreate(req: HttpRequest):
|
| 8 |
if req.method == "GET":
|
| 9 |
-
|
| 10 |
|
| 11 |
context = {
|
| 12 |
-
"form_cata":
|
| 13 |
}
|
| 14 |
|
| 15 |
return render(req, "tecnicas/manage_tester/catador-crear.html", context)
|
| 16 |
elif req.method == "POST":
|
| 17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
context = {
|
| 19 |
-
"form_cata":
|
| 20 |
}
|
| 21 |
|
| 22 |
-
if
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
return render(req, "tecnicas/manage_tester/catador-crear.html", context)
|
| 32 |
else:
|
| 33 |
-
context["error"] = "
|
| 34 |
return render(req, "tecnicas/manage_tester/catador-crear.html", context)
|
|
|
|
| 1 |
from django.http import HttpRequest
|
| 2 |
from django.forms import ValidationError
|
| 3 |
from django.shortcuts import render
|
| 4 |
+
from django.contrib.auth.models import User
|
| 5 |
+
from django.db import transaction, DatabaseError
|
| 6 |
+
from tecnicas.models import Catador
|
| 7 |
+
from tecnicas.forms import CatadorForm
|
| 8 |
|
| 9 |
|
| 10 |
def testerCreate(req: HttpRequest):
|
| 11 |
if req.method == "GET":
|
| 12 |
+
form_tester = CatadorForm()
|
| 13 |
|
| 14 |
context = {
|
| 15 |
+
"form_cata": form_tester
|
| 16 |
}
|
| 17 |
|
| 18 |
return render(req, "tecnicas/manage_tester/catador-crear.html", context)
|
| 19 |
elif req.method == "POST":
|
| 20 |
+
new_values = {}
|
| 21 |
+
|
| 22 |
+
for key, value in req.POST.items():
|
| 23 |
+
new_values[key] = value
|
| 24 |
+
|
| 25 |
+
new_values["is_update"] = False
|
| 26 |
+
|
| 27 |
+
form_tester = CatadorForm(new_values)
|
| 28 |
context = {
|
| 29 |
+
"form_cata": form_tester
|
| 30 |
}
|
| 31 |
|
| 32 |
+
if form_tester.is_valid():
|
| 33 |
+
with transaction.atomic():
|
| 34 |
+
try:
|
| 35 |
+
user = User.objects.create(
|
| 36 |
+
username=form_tester.cleaned_data.get(
|
| 37 |
+
"nombre_usuario"),
|
| 38 |
+
first_name=form_tester.cleaned_data.get("nombre"),
|
| 39 |
+
last_name=form_tester.cleaned_data.get("apellido"),
|
| 40 |
+
email=form_tester.cleaned_data.get("correo")
|
| 41 |
+
)
|
| 42 |
+
user.set_unusable_password()
|
| 43 |
+
user.save()
|
| 44 |
|
| 45 |
+
tester = Catador.objects.create(
|
| 46 |
+
user=user,
|
| 47 |
+
nacimiento=form_tester.cleaned_data.get(
|
| 48 |
+
"fecha_nacimiento"),
|
| 49 |
+
genero=form_tester.cleaned_data.get("genero"),
|
| 50 |
+
telefono=form_tester.cleaned_data.get("telefono")
|
| 51 |
+
)
|
| 52 |
+
except (ValidationError, DatabaseError):
|
| 53 |
+
context["error"] = "nombre de usuario en uso"
|
| 54 |
+
return render(req, "tecnicas/manage_tester/catador-crear.html", context)
|
| 55 |
+
context["message"] = "Datos guardados, consúltelo en Listar Catadores"
|
| 56 |
+
context["form_cata"] = CatadorForm()
|
| 57 |
return render(req, "tecnicas/manage_tester/catador-crear.html", context)
|
| 58 |
else:
|
| 59 |
+
context["error"] = "Datos no validos"
|
| 60 |
return render(req, "tecnicas/manage_tester/catador-crear.html", context)
|
tecnicas/views/tester_management/tester_search.py
CHANGED
|
@@ -1,25 +1,32 @@
|
|
| 1 |
from django.http import HttpRequest
|
| 2 |
from django.shortcuts import render, get_object_or_404
|
| 3 |
-
from django.
|
| 4 |
-
from django.
|
| 5 |
-
from
|
| 6 |
-
from
|
|
|
|
| 7 |
|
| 8 |
-
|
|
|
|
| 9 |
if req.method == "GET":
|
| 10 |
context = {}
|
| 11 |
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
user = False
|
| 16 |
-
|
| 17 |
-
if not user:
|
| 18 |
return render(req, "tecnicas/manage_tester/catador-buscar.html")
|
| 19 |
-
|
| 20 |
try:
|
| 21 |
-
tester = Catador.objects.get(
|
| 22 |
-
context["
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
except Catador.DoesNotExist:
|
| 24 |
context["error"] = "usuario no encontrado"
|
| 25 |
|
|
@@ -27,30 +34,39 @@ def testerSearch(req : HttpRequest):
|
|
| 27 |
elif req.method == "POST":
|
| 28 |
context = {}
|
| 29 |
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
except:
|
| 33 |
-
infoTester = False
|
| 34 |
|
| 35 |
-
|
|
|
|
| 36 |
|
| 37 |
-
|
| 38 |
-
context["error"] = "ha ocurrido un error en recueperar los datos"
|
| 39 |
-
return render(req, "tecnicas/manage_tester/catador-buscar.html", context)
|
| 40 |
-
|
| 41 |
-
user = get_object_or_404(Catador, usuarioCatador=nameUser)
|
| 42 |
-
|
| 43 |
-
modelForm = CatadorForm(infoTester, instance=user)
|
| 44 |
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
from django.http import HttpRequest
|
| 2 |
from django.shortcuts import render, get_object_or_404
|
| 3 |
+
from django.forms import ValidationError
|
| 4 |
+
from django.db import transaction, DatabaseError
|
| 5 |
+
from django.contrib.auth.models import User
|
| 6 |
+
from tecnicas.forms import CatadorForm
|
| 7 |
+
from tecnicas.models import Catador
|
| 8 |
|
| 9 |
+
|
| 10 |
+
def testerSearch(req: HttpRequest):
|
| 11 |
if req.method == "GET":
|
| 12 |
context = {}
|
| 13 |
|
| 14 |
+
if "user" in req.GET:
|
| 15 |
+
username = req.GET["user"]
|
| 16 |
+
else:
|
|
|
|
|
|
|
|
|
|
| 17 |
return render(req, "tecnicas/manage_tester/catador-buscar.html")
|
| 18 |
+
|
| 19 |
try:
|
| 20 |
+
tester = Catador.objects.get(user__username=username)
|
| 21 |
+
context["form_cata"] = CatadorForm({
|
| 22 |
+
'nombre_usuario': tester.user.username,
|
| 23 |
+
'nombre': tester.user.first_name,
|
| 24 |
+
'apellido': tester.user.last_name,
|
| 25 |
+
'telefono': tester.telefono,
|
| 26 |
+
'correo': tester.user.email,
|
| 27 |
+
'fecha_nacimiento': tester.nacimiento,
|
| 28 |
+
'genero': tester.genero,
|
| 29 |
+
})
|
| 30 |
except Catador.DoesNotExist:
|
| 31 |
context["error"] = "usuario no encontrado"
|
| 32 |
|
|
|
|
| 34 |
elif req.method == "POST":
|
| 35 |
context = {}
|
| 36 |
|
| 37 |
+
username = req.GET["user"]
|
| 38 |
+
new_values = {}
|
|
|
|
|
|
|
| 39 |
|
| 40 |
+
for key, value in req.POST.items():
|
| 41 |
+
new_values[key] = value
|
| 42 |
|
| 43 |
+
new_values["is_update"] = True
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
|
| 45 |
+
tester = get_object_or_404(Catador, user__username=username)
|
| 46 |
+
form_tester = CatadorForm(new_values)
|
| 47 |
+
|
| 48 |
+
if form_tester.is_valid():
|
| 49 |
+
with transaction.atomic():
|
| 50 |
+
try:
|
| 51 |
+
user = User.objects.get(username=username)
|
| 52 |
+
user.username = form_tester.cleaned_data.get(
|
| 53 |
+
"nombre_usuario")
|
| 54 |
+
user.first_name = form_tester.cleaned_data.get("nombre")
|
| 55 |
+
user.last_name = form_tester.cleaned_data.get("apellido")
|
| 56 |
+
user.email = form_tester.cleaned_data.get("correo")
|
| 57 |
+
user.save()
|
| 58 |
+
|
| 59 |
+
tester.nacimiento = form_tester.cleaned_data.get(
|
| 60 |
+
"fecha_nacimiento")
|
| 61 |
+
tester.genero = form_tester.cleaned_data.get("genero")
|
| 62 |
+
tester.telefono = form_tester.cleaned_data.get("telefono")
|
| 63 |
+
tester.save()
|
| 64 |
+
except (ValidationError, DatabaseError):
|
| 65 |
+
context["error"] = "nombre de usuario en uso"
|
| 66 |
+
return render(req, "tecnicas/manage_tester/catador-crear.html", context)
|
| 67 |
+
context["message"] = "Datos actualizados, consúltelo en Listar Catadores"
|
| 68 |
+
context["form_cata"] = form_tester
|
| 69 |
+
return render(req, "tecnicas/manage_tester/catador-crear.html", context)
|
| 70 |
+
else:
|
| 71 |
+
context["error"] = "Datos no validos"
|
| 72 |
+
return render(req, "tecnicas/manage_tester/catador-crear.html", context)
|