Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Enzo Yair
/
turismo-api
Go to a project
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
Enzo Yair
2024-10-01 18:43:46 -0300
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
e2cae1c8cea4139b8c7f653d665d4dbb25aa302e
e2cae1c8
1 parent
19e417d4
Finalización de logica admin
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
46 additions
and
10 deletions
project/apps/evento/forms.py
project/apps/evento/migrations/0001_initial.py
project/apps/evento/models.py
project/apps/evento/forms.py
View file @
e2cae1c
...
...
@@ -15,6 +15,7 @@ class EventoForms(forms.ModelForm):
'categoria'
,
'fecha_inicio'
,
'hora_inicio'
,
'fecha_final'
,
'hora_fin'
,
'fechas'
,
'descripcion'
,
...
...
@@ -38,5 +39,34 @@ class EventoForms(forms.ModelForm):
raise
ValidationError
(
_
(
'La dirección no es un enlace válido de Google Maps.'
)
)
return
direccion
def
clean_fecha_final
(
self
):
fecha_inicio
=
self
.
cleaned_data
.
get
(
'fecha_inicio'
)
fecha_final
=
self
.
cleaned_data
.
get
(
'fecha_final'
)
if
fecha_inicio
and
fecha_final
:
if
fecha_final
<
fecha_inicio
:
raise
ValidationError
(
_
(
'La fecha final no puede ser anterior a la fecha de inicio.'
)
)
return
fecha_final
def
clean_hora_fin
(
self
):
clean
=
super
()
.
clean
()
fecha_inicio
=
clean
.
get
(
'fecha_inicio'
)
hora_inicio
=
clean
.
get
(
'hora_inicio'
)
fecha_final
=
clean
.
get
(
'fecha_final'
)
hora_fin
=
clean
.
get
(
'hora_fin'
)
if
fecha_inicio
and
fecha_final
and
fecha_final
==
fecha_inicio
:
if
hora_inicio
and
hora_fin
and
hora_fin
<=
hora_inicio
:
raise
ValidationError
(
_
(
'La hora de finalización debe ser posterior a la hora de inicio.'
)
)
return
hora_fin
...
...
project/apps/evento/migrations/0001_initial.py
View file @
e2cae1c
# Generated by Django 4.2.9 on 2024-10-01
15:20
# Generated by Django 4.2.9 on 2024-10-01
21:42
import
django.core.validators
from
django.db
import
migrations
,
models
...
...
@@ -29,16 +29,17 @@ class Migration(migrations.Migration):
fields
=
[
(
'id'
,
models
.
BigAutoField
(
auto_created
=
True
,
primary_key
=
True
,
serialize
=
False
,
verbose_name
=
'ID'
)),
(
'fecha_inicio'
,
models
.
DateField
(
verbose_name
=
'Fecha de inicio del evento'
)),
(
'hora_inicio'
,
models
.
TimeField
(
blank
=
True
,
verbose_name
=
'Hora de apertura'
)),
(
'hora_fin'
,
models
.
TimeField
(
blank
=
True
,
verbose_name
=
'Hora de cierre'
)),
(
'hora_inicio'
,
models
.
TimeField
(
verbose_name
=
'Hora de apertura'
)),
(
'fecha_final'
,
models
.
DateField
(
verbose_name
=
'Fecha de cierre del evento'
)),
(
'hora_fin'
,
models
.
TimeField
(
verbose_name
=
'Hora de cierre'
)),
(
'titulo'
,
models
.
CharField
(
max_length
=
350
)),
(
'categoria'
,
models
.
SlugField
(
max_length
=
150
)),
(
'direccion'
,
models
.
URLField
(
max_length
=
150
,
verbose_name
=
'ubicación
'
)),
(
'direccion'
,
models
.
URLField
(
help_text
=
'Ingrese la url obtenida por google maps'
,
max_length
=
150
,
verbose_name
=
'Ubicación del evento
'
)),
(
'descripcion'
,
models
.
TextField
(
verbose_name
=
'Descripción'
)),
(
'url'
,
models
.
URLField
(
blank
=
True
,
max_length
=
300
,
verbose_name
=
'Dirección Web'
)),
(
'imagen'
,
models
.
ImageField
(
blank
=
True
,
upload_to
=
'static/eventos'
,
validators
=
[
django
.
core
.
validators
.
FileExtensionValidator
(
allowed_extensions
=
[
'jpg'
,
'png'
])],
verbose_name
=
'Banner promocional'
)),
(
'dependencia'
,
models
.
ManyToManyField
(
blank
=
True
,
related_name
=
'evento_dependencia'
,
to
=
'organismo.dependencia'
)),
(
'fechas'
,
models
.
ManyToManyField
(
related_name
=
'evento_fechas'
,
to
=
'evento.fechaevento'
,
verbose_name
=
'Días disponibles'
)),
(
'fechas'
,
models
.
ManyToManyField
(
blank
=
True
,
related_name
=
'evento_fechas'
,
to
=
'evento.fechaevento'
,
verbose_name
=
'Días disponibles'
)),
(
'organismo'
,
models
.
ManyToManyField
(
blank
=
True
,
related_name
=
'evento_organismo'
,
to
=
'organismo.organismo'
)),
],
options
=
{
...
...
project/apps/evento/models.py
View file @
e2cae1c
...
...
@@ -24,17 +24,22 @@ class Evento(models.Model):
blank
=
True
)
fecha_inicio
=
models
.
DateField
(
verbose_name
=
'Fecha de inicio del evento'
)
hora_inicio
=
models
.
TimeField
(
blank
=
True
,
verbose_name
=
'Hora de apertura'
)
hora_fin
=
models
.
TimeField
(
blank
=
True
,
verbose_name
=
'Hora de cierre'
)
hora_inicio
=
models
.
TimeField
(
blank
=
False
,
verbose_name
=
'Hora de apertura'
)
fecha_final
=
models
.
DateField
(
verbose_name
=
'Fecha de cierre del evento'
)
hora_fin
=
models
.
TimeField
(
blank
=
False
,
verbose_name
=
'Hora de cierre'
)
fechas
=
models
.
ManyToManyField
(
'FechaEvento'
,
related_name
=
'evento_fechas'
,
blank
=
Fals
e
,
blank
=
Tru
e
,
verbose_name
=
'Días disponibles'
,
)
titulo
=
models
.
CharField
(
max_length
=
350
,
null
=
False
)
categoria
=
models
.
SlugField
(
max_length
=
150
,
null
=
False
)
direccion
=
models
.
URLField
(
max_length
=
150
,
verbose_name
=
'ubicación'
)
direccion
=
models
.
URLField
(
max_length
=
150
,
verbose_name
=
'Ubicación del evento'
,
help_text
=
'Ingrese la url obtenida por google maps'
)
descripcion
=
models
.
TextField
(
null
=
False
,
verbose_name
=
'Descripción'
)
url
=
models
.
URLField
(
max_length
=
300
,
...
...
Please
register
or
login
to post a comment