Merge pull request #4104 from normanjaeckel/HistoryTimestamp

Used the same timestamp for multiple history objects.
This commit is contained in:
Norman Jäckel 2019-01-19 14:03:47 +01:00 committed by GitHub
commit 5aedf62018
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 23 additions and 2 deletions

View File

@ -0,0 +1,18 @@
# Generated by Django 2.1.5 on 2019-01-19 08:58
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('core', '0010_auto_20190118_1908'),
]
operations = [
migrations.AlterField(
model_name='history',
name='now',
field=models.DateTimeField(),
),
]

View File

@ -266,6 +266,7 @@ class HistoryManager(models.Manager):
""" """
with transaction.atomic(): with transaction.atomic():
instances = [] instances = []
history_time = now()
for element in elements: for element in elements:
if ( if (
element["disable_history"] element["disable_history"]
@ -280,6 +281,7 @@ class HistoryManager(models.Manager):
element_id=get_element_id( element_id=get_element_id(
element["collection_string"], element["id"] element["collection_string"], element["id"]
), ),
now=history_time,
information=element["information"], information=element["information"],
user_id=element["user_id"], user_id=element["user_id"],
full_data=data, full_data=data,
@ -329,7 +331,7 @@ class History(RESTModelMixin, models.Model):
element_id = models.CharField(max_length=255) element_id = models.CharField(max_length=255)
now = models.DateTimeField(auto_now_add=True) now = models.DateTimeField()
information = models.CharField(max_length=255) information = models.CharField(max_length=255)

View File

@ -176,3 +176,4 @@ class HistorySerializer(ModelSerializer):
class Meta: class Meta:
model = History model = History
fields = ("id", "element_id", "now", "information", "user") fields = ("id", "element_id", "now", "information", "user")
read_only_fields = ("now",)

View File

@ -569,7 +569,7 @@ class MotionViewSet(ModelViewSet):
person=request.user, person=request.user,
skip_autoupdate=True, skip_autoupdate=True,
) )
inform_changed_data(motion, information=f"State set to {motion.state.name}.") inform_changed_data(motion, information=f"State set to {motion.state.name}.", user_id=request.user.pk)
return Response({"detail": message}) return Response({"detail": message})
@list_route(methods=["post"]) @list_route(methods=["post"])