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 17:23:07 -0300
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
5193c0511046d8d0de6e542930865718e519340a
5193c051
1 parent
7b7d8e90
control de fecha_modificacion
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
26 additions
and
2 deletions
project/apps/edicto/api.py
project/apps/edicto/migrations/0016_alter_edicto_fecha_modificacion.py
project/apps/edicto/models.py
project/apps/edicto/serializer.py
project/apps/edicto/api.py
View file @
5193c05
...
...
@@ -45,9 +45,13 @@ 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
=
datetime
.
now
()
,
fecha_actualizacion
=
fecha
,
usuario_movimiento
=
usuario
,
)
...
...
project/apps/edicto/migrations/0016_alter_edicto_fecha_modificacion.py
0 → 100644
View file @
5193c05
# Generated by Django 4.1.9 on 2023-09-13 20:08
from
django.db
import
migrations
,
models
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'edicto'
,
'0015_edicto_usuario_movi'
),
]
operations
=
[
migrations
.
AlterField
(
model_name
=
'edicto'
,
name
=
'fecha_modificacion'
,
field
=
models
.
DateTimeField
(
blank
=
True
,
default
=
None
,
null
=
True
),
),
]
...
...
project/apps/edicto/models.py
View file @
5193c05
...
...
@@ -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
(
auto_now_add
=
True
)
fecha_modificacion
=
models
.
DateTimeField
(
default
=
None
,
null
=
True
,
blank
=
True
)
usuario_movimiento
=
models
.
ForeignKey
(
Usuario
,
on_delete
=
models
.
CASCADE
,
related_name
=
'udate_edicto'
)
class
Meta
:
...
...
project/apps/edicto/serializer.py
View file @
5193c05
...
...
@@ -28,12 +28,14 @@ class EdictoSerializer(serializers.ModelSerializer):
'fecha_creacion'
,
'observaciones'
,
'fecha_publicacion'
,
'fecha_modificacion'
)
read_only_fields
=
(
'usuario'
,
'usuario_movimiento'
,
'fecha_publicacion'
,
'cantidad_palabras'
,
'fecha_creacion'
,
'fecha_modificacion'
,
)
def
to_representation
(
self
,
instance
):
...
...
Please
register
or
login
to post a comment