Used the same timestamp for multiple history objects.

This commit is contained in:
Norman Jäckel 2019-01-12 20:49:28 +01:00
parent 1cdeb3bcb8
commit de7b531933
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():
instances = []
history_time = now()
for element in elements:
if (
element["disable_history"]
@ -280,6 +281,7 @@ class HistoryManager(models.Manager):
element_id=get_element_id(
element["collection_string"], element["id"]
),
now=history_time,
information=element["information"],
user_id=element["user_id"],
full_data=data,
@ -329,7 +331,7 @@ class History(RESTModelMixin, models.Model):
element_id = models.CharField(max_length=255)
now = models.DateTimeField(auto_now_add=True)
now = models.DateTimeField()
information = models.CharField(max_length=255)

View File

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

View File

@ -568,7 +568,7 @@ class MotionViewSet(ModelViewSet):
person=request.user,
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})
@detail_route(methods=["put"])