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-13 18:17:58 -0300
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
6c2a402c472303a88827fd5a77364725402f9396
6c2a402c
1 parent
5193c051
fix en serializer edicto/fecha_movimiento
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
26 additions
and
9 deletions
project/apps/edicto/api.py
project/apps/edicto/migrations/0017_alter_edicto_fecha_modificacion.py
project/apps/edicto/models.py
project/apps/edicto/serializer.py
project/apps/edicto/api.py
View file @
6c2a402
...
...
@@ -45,13 +45,9 @@ class EdictoViewSet(mixins.CreateModelMixin,
edicto
=
request
.
data
.
get
(
'cuerpo_edicto'
)
cantidad_palabras
=
contador
(
edicto
)
usuario
=
self
.
request
.
user
if
request
.
method
==
'PUT'
:
fecha
=
datetime
.
now
()
else
:
fecha
=
none
serializer
.
save
(
cantidad_palabras
=
cantidad_palabras
,
fecha_
actualizacion
=
fecha
,
fecha_
modificacion
=
datetime
.
now
()
,
usuario_movimiento
=
usuario
,
)
...
...
project/apps/edicto/migrations/0017_alter_edicto_fecha_modificacion.py
0 → 100644
View file @
6c2a402
# Generated by Django 4.1.9 on 2023-09-13 20:55
from
django.db
import
migrations
,
models
import
django.utils.timezone
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'edicto'
,
'0016_alter_edicto_fecha_modificacion'
),
]
operations
=
[
migrations
.
AlterField
(
model_name
=
'edicto'
,
name
=
'fecha_modificacion'
,
field
=
models
.
DateTimeField
(
auto_now_add
=
True
,
default
=
django
.
utils
.
timezone
.
now
),
preserve_default
=
False
,
),
]
...
...
project/apps/edicto/models.py
View file @
6c2a402
...
...
@@ -37,7 +37,7 @@ class Edicto(models.Model):
fecha_publicacion
=
models
.
DateField
(
blank
=
True
,
null
=
True
)
observaciones
=
models
.
CharField
(
max_length
=
500
,
blank
=
True
,
null
=
True
)
fecha_creacion
=
models
.
DateField
(
auto_now_add
=
True
)
fecha_modificacion
=
models
.
DateTimeField
(
default
=
None
,
null
=
True
,
blank
=
True
)
fecha_modificacion
=
models
.
DateTimeField
(
auto_now_add
=
True
)
usuario_movimiento
=
models
.
ForeignKey
(
Usuario
,
on_delete
=
models
.
CASCADE
,
related_name
=
'udate_edicto'
)
class
Meta
:
...
...
project/apps/edicto/serializer.py
View file @
6c2a402
...
...
@@ -40,9 +40,10 @@ class EdictoSerializer(serializers.ModelSerializer):
def
to_representation
(
self
,
instance
):
data
=
super
()
.
to_representation
(
instance
)
user
=
self
.
context
[
'request'
]
.
user
if
not
user
.
is_staff
:
data
[
'fecha_publicacion'
]
=
instance
.
fecha_publicacion
if
instance
.
fecha_modificacion
is
not
None
and
self
.
context
[
'request'
]
.
method
==
'PUT'
:
data
[
'fecha_modificacion'
]
=
instance
.
fecha_modificacion
else
:
data
[
'fecha_modificacion'
]
=
None
return
data
@staticmethod
...
...
Please
register
or
login
to post a comment