Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Marta Miranda
/
boletin_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
2023-10-04 12:49:04 -0300
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
b06e1aef865acf3e929210eea073c25e9e5cebcf
b06e1aef
1 parent
a9961780
feature/#73
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
3 deletions
project/apps/edicto/admin.py
project/apps/edicto/admin.py
View file @
b06e1ae
from
django.contrib
import
admin
from
.models
import
Edicto
,
Precio
# Register your models here.
admin
.
site
.
register
(
Precio
)
class
PrecioAdmin
(
admin
.
ModelAdmin
):
def
save_model
(
self
,
request
,
obj
,
form
,
change
):
if
change
:
super
()
.
save_model
(
request
,
obj
,
form
,
change
)
else
:
precios_con_vigencia
=
Precio
.
objects
.
exclude
(
vigencia_hasta
=
None
)
.
count
()
if
precios_con_vigencia
>
0
and
obj
.
vigencia_hasta
is
None
:
form
.
add_error
(
'vigencia_hasta'
,
'Debe proporcionar una fecha para vigencia_hasta antes de crear un nuevo objeto Precio.'
)
else
:
obj
.
usuario
=
request
.
user
super
()
.
save_model
(
request
,
obj
,
form
,
change
)
admin
.
site
.
register
(
Precio
,
PrecioAdmin
)
admin
.
site
.
register
(
Edicto
)
admin
.
site
.
register
(
Edicto
)
\ No newline at end of file
...
...
Please
register
or
login
to post a comment