From c3de6dc870d29c09dbe8c88189158218975bff47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Norman=20J=C3=A4ckel?= Date: Fri, 5 Feb 2021 12:22:52 +0100 Subject: [PATCH] Added information to poll start and stop. --- server/openslides/motions/views.py | 8 ++++++++ server/openslides/poll/views.py | 9 +++++++++ 2 files changed, 17 insertions(+) diff --git a/server/openslides/motions/views.py b/server/openslides/motions/views.py index 1db1fcd90..4444cac65 100644 --- a/server/openslides/motions/views.py +++ b/server/openslides/motions/views.py @@ -1194,6 +1194,14 @@ class MotionPollViewSet(BasePollViewSet): return result + def extend_history_information(self, information): + poll = self.get_object() + inform_changed_data( + poll.motion, + information=information, + user_id=self.request.user.pk, + ) + def handle_analog_vote(self, data, poll): option = poll.options.get() vote, _ = MotionVote.objects.get_or_create(option=option, value="Y") diff --git a/server/openslides/poll/views.py b/server/openslides/poll/views.py index 069386286..ab373baa7 100644 --- a/server/openslides/poll/views.py +++ b/server/openslides/poll/views.py @@ -116,6 +116,11 @@ class BasePollViewSet(ModelViewSet): poll.state = BasePoll.STATE_FINISHED poll.save() + def extend_history_information(self, information): + # Use this method to add history information when a poll is started and stopped. + # The implementation can be found in concret view set e. g. MotionPollViewSet. + pass + @detail_route(methods=["POST"]) @transaction.atomic def start(self, request, pk): @@ -126,6 +131,7 @@ class BasePollViewSet(ModelViewSet): poll.save() inform_changed_data(poll.get_votes()) + self.extend_history_information(["Voting started"]) return Response() @detail_route(methods=["POST"]) @@ -146,6 +152,7 @@ class BasePollViewSet(ModelViewSet): poll.save() inform_changed_data(poll.get_votes()) inform_changed_data(poll.get_options()) + self.extend_history_information(["Voting stopped"]) return Response() @detail_route(methods=["POST"]) @@ -181,6 +188,7 @@ class BasePollViewSet(ModelViewSet): raise ValidationError({"detail": "You can just anonymize named polls."}) poll.pseudoanonymize() + self.extend_history_information(["Voting anonymized"]) return Response() @detail_route(methods=["POST"]) @@ -188,6 +196,7 @@ class BasePollViewSet(ModelViewSet): def reset(self, request, pk): poll = self.get_object() poll.reset() + self.extend_history_information(["Voting reset"]) return Response() @detail_route(methods=["POST"])