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-20 08:56:15 -0300
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
a110cc889017164f818163b598d28bf3e5406b8a
a110cc88
1 parent
11a5a4ee
modificaciones en endpoint en el serializer de precio
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
3 deletions
project/apps/edicto/api.py
project/apps/edicto/serializers.py
project/apps/edicto/api.py
View file @
a110cc8
...
...
@@ -44,12 +44,17 @@ class EdictoViewSet(AuditoriaMixin, mixins.CreateModelMixin,
return
Response
(
serializer
.
data
)
class
PrecioViewSet
(
AuditoriaMixin
,
viewsets
.
ReadOnlyModelViewSet
):
class
PrecioViewSet
(
mixins
.
CreateModelMixin
,
mixins
.
RetrieveModelMixin
,
mixins
.
UpdateModelMixin
,
mixins
.
ListModelMixin
,
viewsets
.
GenericViewSet
,
):
serializer_class
=
PrecioSerializer
permission_classes
=
[
IsAuthenticated
,
IsAdminOrAuthorized
]
filter_backends
=
(
DjangoFilterBackend
,
filters
.
OrderingFilter
)
filterset_class
=
PrecioFilter
ordering_fields
=
(
'usuario'
,)
ordering_fields
=
(
'usuario'
,
'id'
,
)
ordering
=
'usuario'
queryset
=
Precio
.
objects
.
all
()
...
...
@@ -65,7 +70,7 @@ class ComprobanteViewSet(mixins.UpdateModelMixin,
queryset
=
ComprobantePago
.
objects
.
all
()
filter_backends
=
(
DjangoFilterBackend
,
filters
.
OrderingFilter
)
filter_class
=
ComprobanteFilter
ordering_fields
=
(
'id'
,
'monto_descuento'
,
'monto_total'
,
'fecha_pago'
)
ordering_fields
=
(
'id'
,
'monto_descuento'
,
'monto_total'
,
'fecha_pago'
)
ordering
=
'id'
...
...
project/apps/edicto/serializers.py
View file @
a110cc8
...
...
@@ -84,6 +84,20 @@ class PrecioSerializer(serializers.ModelSerializer):
included_serializers
=
{
'usuario'
:
UsuarioListaSerializer
}
def
validate
(
self
,
data
):
data
[
'usuario'
]
=
self
.
context
[
'request'
]
.
user
vigencia_hasta
=
data
.
get
(
'vigencia_hasta'
)
if
not
vigencia_hasta
:
precios_sin_vigencia
=
Precio
.
objects
.
filter
(
vigencia_hasta__isnull
=
True
)
if
precios_sin_vigencia
.
exists
():
raise
serializers
.
ValidationError
(
'Error al agregar: Ya existe un objeto Precio sin vigencia_hasta. '
'Debe proporcionar una fecha para vigencia_hasta antes de crear un nuevo objeto Precio.'
)
return
data
class
ComprobanteSerializer
(
serializers
.
ModelSerializer
):
class
Meta
:
...
...
Please
register
or
login
to post a comment