From 8f50caf481272762205f6471c030d1e010a94a24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Norman=20J=C3=A4ckel?= Date: Wed, 13 Mar 2019 09:40:04 +0100 Subject: [PATCH] Hotfix for #4491: Autoupdate for motion when change recommendation changes. --- openslides/motions/models.py | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/openslides/motions/models.py b/openslides/motions/models.py index df7da3869..7c9674a09 100644 --- a/openslides/motions/models.py +++ b/openslides/motions/models.py @@ -771,6 +771,13 @@ class MotionChangeRecommendation(RESTModelMixin, models.Model): creation_time = models.DateTimeField(auto_now=True) """Time when the change recommendation was saved.""" + class Meta: + default_permissions = () + + def __str__(self): + """Return a string, representing this object.""" + return f"Recommendation for Motion {self.motion_id}, line {self.line_from} - {self.line_to}" + def collides_with_other_recommendation(self, recommendations): for recommendation in recommendations: if not ( @@ -794,14 +801,21 @@ class MotionChangeRecommendation(RESTModelMixin, models.Model): f"The recommendation collides with an existing one (line {self.line_from} - {self.line_to})." ) - return super().save(*args, **kwargs) + result = super().save(*args, **kwargs) - class Meta: - default_permissions = () + # Hotfix for #4491: Trigger extra autoupdate for motion so that the serializer + # field vor motion change recommendations gets updated too. + inform_changed_data(self.motion) - def __str__(self): - """Return a string, representing this object.""" - return f"Recommendation for Motion {self.motion_id}, line {self.line_from} - {self.line_to}" + return result + + def delete(self, *args, **kwargs): + # Hotfix for #4491: Trigger extra autoupdate for motion so that the serializer + # field vor motion change recommendations gets updated too. + motion = self.motion + result = super().delete(*args, **kwargs) + inform_changed_data(motion) + return result class Category(RESTModelMixin, models.Model):