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-15 10:32:48 -0300
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
a6d3afc777a52dfa3b1c9d568c0cd9d100e29f94
a6d3afc7
1 parent
26265943
actualizacion a patch
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
31 additions
and
7 deletions
project/apps/edicto/api.py
project/apps/edicto/migrations/0016_remove_edicto_id_alter_edicto_uuid.py
project/apps/edicto/models.py
project/apps/edicto/serializer.py
project/apps/edicto/api.py
View file @
a6d3afc
...
...
@@ -14,7 +14,6 @@ from .utils import contador
class
EdictoViewSet
(
mixins
.
CreateModelMixin
,
mixins
.
RetrieveModelMixin
,
mixins
.
UpdateModelMixin
,
mixins
.
ListModelMixin
,
viewsets
.
GenericViewSet
):
...
...
@@ -36,9 +35,9 @@ class EdictoViewSet(mixins.CreateModelMixin,
usuario_movimiento
=
usuario
,
)
def
update
(
self
,
request
,
*
args
,
**
kwargs
):
def
partial_
update
(
self
,
request
,
*
args
,
**
kwargs
):
instance
=
self
.
get_object
()
serializer
=
self
.
get_serializer
(
instance
,
data
=
request
.
data
)
serializer
=
self
.
get_serializer
(
instance
,
data
=
request
.
data
,
partial
=
True
)
serializer
.
is_valid
(
raise_exception
=
True
)
edicto
=
request
.
data
.
get
(
'cuerpo_edicto'
)
...
...
project/apps/edicto/migrations/0016_remove_edicto_id_alter_edicto_uuid.py
0 → 100644
View file @
a6d3afc
# Generated by Django 4.1.9 on 2023-09-15 12:36
from
django.db
import
migrations
,
models
import
uuid
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'edicto'
,
'0015_edicto_usuario_movi'
),
]
operations
=
[
migrations
.
RemoveField
(
model_name
=
'edicto'
,
name
=
'id'
,
),
migrations
.
AlterField
(
model_name
=
'edicto'
,
name
=
'uuid'
,
field
=
models
.
UUIDField
(
default
=
uuid
.
uuid4
,
editable
=
False
,
primary_key
=
True
,
serialize
=
False
,
unique
=
True
),
),
]
...
...
project/apps/edicto/models.py
View file @
a6d3afc
...
...
@@ -25,7 +25,7 @@ class Precio (models.Model):
class
Edicto
(
models
.
Model
):
uuid
=
models
.
UUIDField
(
unique
=
True
,
editable
=
False
,
default
=
uuid4
)
uuid
=
models
.
UUIDField
(
unique
=
True
,
editable
=
False
,
default
=
uuid4
,
primary_key
=
True
)
usuario
=
models
.
ForeignKey
(
Usuario
,
on_delete
=
models
.
CASCADE
,
verbose_name
=
'Usuario'
)
cuerpo_edicto
=
models
.
TextField
(
blank
=
False
,
null
=
False
)
archivo
=
models
.
FileField
(
upload_to
=
"uploads/
%
Y/
%
m/
%
d/"
,
null
=
False
,
blank
=
False
)
...
...
project/apps/edicto/serializer.py
View file @
a6d3afc
...
...
@@ -15,8 +15,7 @@ class EdictoSerializer(serializers.ModelSerializer):
class
Meta
:
model
=
Edicto
fields
=
(
'uuid'
,
'usuario'
,
fields
=
(
'usuario'
,
'usuario_movimiento'
,
'estado'
,
'cuerpo_edicto'
,
...
...
@@ -31,6 +30,9 @@ class EdictoSerializer(serializers.ModelSerializer):
'fecha_modificacion'
)
extra_kwargs
=
{
'archivo'
:
{
'read_only'
:
True
}
}
read_only_fields
=
(
'usuario'
,
'usuario_movimiento'
,
'fecha_publicacion'
,
'cantidad_palabras'
,
...
...
@@ -40,7 +42,7 @@ class EdictoSerializer(serializers.ModelSerializer):
def
to_representation
(
self
,
instance
):
data
=
super
()
.
to_representation
(
instance
)
if
instance
.
fecha_modificacion
is
not
None
and
self
.
context
[
'request'
]
.
method
==
'P
UT
'
:
if
instance
.
fecha_modificacion
is
not
None
and
self
.
context
[
'request'
]
.
method
==
'P
ATCH
'
:
data
[
'fecha_modificacion'
]
=
instance
.
fecha_modificacion
else
:
data
[
'fecha_modificacion'
]
=
None
...
...
Please
register
or
login
to post a comment