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-09-08 11:34:45 -0300
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
4fd465cb7428c8a4c8b66469cc1d71ca129d1b73
4fd465cb
1 parent
8762df5c
correcion de api, models, y admin
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
20 deletions
project/apps/edicto/admin.py
project/apps/edicto/api.py
project/apps/edicto/models.py
project/apps/edicto/admin.py
View file @
4fd465c
...
...
@@ -12,12 +12,9 @@ class PrecioAdmin(admin.ModelAdmin):
precios_activos
=
Precio
.
objects
.
filter
(
vigencia_hasta__gte
=
timezone
.
now
()
.
date
())
if
not
change
:
today
=
timezone
.
now
()
.
date
()
if
obj
.
vigencia_desde
<=
today
:
if
not
precios_activos
.
exists
():
if
obj
.
vigencia_desde
<=
today
and
not
precios_activos
.
exists
():
obj
.
save
()
else
:
raise
ValidationError
(
"Ya existe un precio activo."
)
else
:
raise
ValidationError
(
"La fecha de inicio no es válida."
)
else
:
obj
.
save
()
...
...
project/apps/edicto/api.py
View file @
4fd465c
...
...
@@ -57,12 +57,7 @@ class PrecioViewSet(viewsets.ReadOnlyModelViewSet):
queryset
=
Precio
.
objects
.
all
()
class
PagoViewSets
(
mixins
.
CreateModelMixin
,
mixins
.
RetrieveModelMixin
,
mixins
.
UpdateModelMixin
,
mixins
.
DestroyModelMixin
,
mixins
.
ListModelMixin
,
viewsets
.
GenericViewSet
):
class
PagoViewSets
(
viewsets
.
ModelViewSet
):
serializer_class
=
PagoSerializer
permission_classes
=
[
IsAuthenticated
,
IsAdminOrAuthorized
]
queryset
=
ComprobantePago
.
objects
.
all
()
...
...
@@ -70,17 +65,16 @@ class PagoViewSets(mixins.CreateModelMixin,
def
perform_create
(
self
,
serializer
):
try
:
edicto
=
Edicto
.
objects
.
get
(
estado
=
'pendiente_de_pago'
)
precio
=
Precio
.
objects
.
latest
(
'id'
)
monto
=
calculadora
(
edicto
,
precio
)
if
edicto
.
usuario
!=
self
.
request
.
user
:
raise
UsuarioNoAutorizado
serializer
.
validated_data
[
'monto'
]
=
monto
serializer
.
validated_data
[
'edicto'
]
=
edicto
precio
=
Precio
.
objects
.
latest
(
'id'
)
monto
=
calculadora
(
edicto
,
precio
)
serializer
.
validated_data
.
update
({
'monto'
:
monto
,
'edicto'
:
edicto
})
serializer
.
save
()
except
Edicto
.
DoesNotExist
:
raise
EdictoNoEncontrado
except
Precio
.
DoesNotExist
:
raise
PrecioNoEncontrado
except
(
Edicto
.
DoesNotExist
,
Precio
.
DoesNotExist
):
raise
EdictoOPrecioNoEncontrado
class
ComprobanteViewSets
(
mixins
.
CreateModelMixin
,
...
...
project/apps/edicto/models.py
View file @
4fd465c
...
...
@@ -42,7 +42,7 @@ class Edicto(models.Model):
verbose_name_plural
=
'Edictos'
def
__str__
(
self
):
return
f
"{self.
cuerpo_edicto}
Edicto"
return
f
"{self.
usuario} -
Edicto"
class
ComprobantePago
(
models
.
Model
):
...
...
@@ -57,4 +57,4 @@ class ComprobantePago(models.Model):
verbose_name_plural
=
'ComprobantesPagos'
def
__str__
(
self
):
return
f
"{self.numero_comprobante} comprobante pago de {self.edicto.
cuerpo_edict
o}"
return
f
"{self.numero_comprobante} comprobante pago de {self.edicto.
usuari
o}"
...
...
Please
register
or
login
to post a comment