From b15a57bbdd124dfda6ce0fc2fdd4b9a33366d0a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Norman=20J=C3=A4ckel?= Date: Sat, 19 Jan 2019 10:27:50 +0100 Subject: [PATCH] Added timestamp fields for motions. --- CHANGELOG.rst | 1 + .../migrations/0019_auto_20190119_1025.py | 25 +++++++++++++++++++ openslides/motions/models.py | 10 ++++++++ openslides/motions/serializers.py | 2 ++ 4 files changed, 38 insertions(+) create mode 100644 openslides/motions/migrations/0019_auto_20190119_1025.py diff --git a/CHANGELOG.rst b/CHANGELOG.rst index d3064d3b6..14c656979 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -35,6 +35,7 @@ Motions: - Added new permission to create amendments [#4128]. - Added multi select action to manage submitters, tags, states and recommendations [#4037, #4132]. + - Added timestampes for motions [#4134]. User: - Added new admin group which grants all permissions. Users of existing group diff --git a/openslides/motions/migrations/0019_auto_20190119_1025.py b/openslides/motions/migrations/0019_auto_20190119_1025.py new file mode 100644 index 000000000..9b5f8ec53 --- /dev/null +++ b/openslides/motions/migrations/0019_auto_20190119_1025.py @@ -0,0 +1,25 @@ +# Generated by Django 2.1.5 on 2019-01-19 09:25 + +import django.utils.timezone +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('motions', '0018_auto_20190118_2101'), + ] + + operations = [ + migrations.AddField( + model_name='motion', + name='created', + field=models.DateTimeField(auto_now_add=True, default=django.utils.timezone.now), + preserve_default=False, + ), + migrations.AddField( + model_name='motion', + name='last_modified', + field=models.DateTimeField(auto_now=True), + ), + ] diff --git a/openslides/motions/models.py b/openslides/motions/models.py index 2071e0a37..01f915911 100644 --- a/openslides/motions/models.py +++ b/openslides/motions/models.py @@ -244,6 +244,16 @@ class Motion(RESTModelMixin, models.Model): Users who support this motion. """ + created = models.DateTimeField(auto_now_add=True) + """ + Timestamp when motion is created. + """ + + last_modified = models.DateTimeField(auto_now=True) + """ + Timestamp when motion is modified. + """ + # In theory there could be one then more agenda_item. But we support only # one. See the property agenda_item. agenda_items = GenericRelation(Item, related_name="motions") diff --git a/openslides/motions/serializers.py b/openslides/motions/serializers.py index 7208e8583..acc348585 100644 --- a/openslides/motions/serializers.py +++ b/openslides/motions/serializers.py @@ -434,6 +434,8 @@ class MotionSerializer(ModelSerializer): "log_messages", "sort_parent", "weight", + "created", + "last_modified", ) read_only_fields = ( "state",