From 085d2f58cb7b27ec1ba26601d02e7e4fc13fe275 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Norman=20J=C3=A4ckel?= Date: Tue, 19 Feb 2019 13:21:44 +0100 Subject: [PATCH] Added history information for motion change recommendations. --- openslides/motions/views.py | 41 +++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/openslides/motions/views.py b/openslides/motions/views.py index eaaf2b06b..b7293173b 100644 --- a/openslides/motions/views.py +++ b/openslides/motions/views.py @@ -1058,6 +1058,47 @@ class MotionChangeRecommendationViewSet(ModelViewSet): except DjangoValidationError as err: return Response({"detail": err.message}, status=400) + def perform_create(self, serializer): + """ + Customized method to add history information. + """ + instance = serializer.save() + # Fire autoupdate again to save information to OpenSlides history. + inform_changed_data( + instance, + information=["Motion change recommendation created"], + user_id=self.request.user.pk, + ) + + def perform_update(self, serializer): + """ + Customized method to add history information. + """ + instance = serializer.save() + # Fire autoupdate again to save information to OpenSlides history. + inform_changed_data( + instance, + information=["Motion change recommendation updated"], + user_id=self.request.user.pk, + ) + + def destroy(self, request, *args, **kwargs): + """ + Customized method to add history information. + """ + instance = self.get_object() + + result = super().destroy(request, *args, **kwargs) + + # Fire autoupdate again to save information to OpenSlides history. + inform_deleted_data( + [(instance.get_collection_string(), instance.pk)], + information=["Motion change recommendation deleted"], + user_id=request.user.pk, + ) + + return result + class MotionCommentSectionViewSet(ModelViewSet): """