Skip to content

Commit

Permalink
polls: add new signal which is called after a user voted on a poll
Browse files Browse the repository at this point in the history
  • Loading branch information
goapunk committed Nov 6, 2024
1 parent 1796224 commit 3378c06
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions adhocracy4/polls/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
from .models import Question
from .models import Vote
from .serializers import PollSerializer
from .signals import poll_voted


class PollViewSet(
Expand Down Expand Up @@ -178,6 +179,8 @@ def vote(self, request, pk):
self.save_vote(question, vote_data, creator, content_id)

poll = self.get_object()
print("##########################################")
poll_voted.send(sender=None, poll=poll, creator=creator, content_id=content_id)
poll_serializer = self.get_serializer(poll)
poll_data = self.add_terms_of_use_info(request, poll_serializer.data)
if not self.request.user.is_authenticated:
Expand Down
3 changes: 3 additions & 0 deletions adhocracy4/polls/signals.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.dispatch import Signal

poll_voted = Signal()
3 changes: 3 additions & 0 deletions changelog/8381.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
### Added

- add a poll_voted signal which is sent when a user has voted on a poll.

0 comments on commit 3378c06

Please sign in to comment.