fixes the voting autoupdate bug

This commit is contained in:
Joshua Sangmeister 2020-04-17 15:58:56 +02:00
parent 6cdf9a5582
commit 42fbe93314
2 changed files with 49 additions and 43 deletions

View File

@ -156,6 +156,7 @@ class BasePollViewSet(ModelViewSet):
poll.state = BasePoll.STATE_PUBLISHED poll.state = BasePoll.STATE_PUBLISHED
poll.save() poll.save()
inform_changed_data(vote.user for vote in poll.get_votes().all() if vote.user)
inform_changed_data(poll.get_votes()) inform_changed_data(poll.get_votes())
inform_changed_data(poll.get_options()) inform_changed_data(poll.get_options())
return Response() return Response()

View File

@ -1979,9 +1979,8 @@ class VoteAssignmentPollNamedAutoupdates(VoteAssignmentPollAutoupdatesBaseClass)
self.assertAutoupdate(poll, user=user) self.assertAutoupdate(poll, user=user)
autoupdate = self.get_last_autoupdate(user=user) autoupdate = self.get_last_autoupdate(user=user)
self.assertEqual( self.assertEqual(
autoupdate[0], autoupdate[0]["assignments/assignment-poll:1"],
{ {
"assignments/assignment-poll:1": {
"allow_multiple_votes_per_candidate": False, "allow_multiple_votes_per_candidate": False,
"amount_global_abstain": None, "amount_global_abstain": None,
"amount_global_no": None, "amount_global_no": None,
@ -2005,7 +2004,10 @@ class VoteAssignmentPollNamedAutoupdates(VoteAssignmentPollAutoupdatesBaseClass)
"user_has_voted": user == self.user, "user_has_voted": user == self.user,
"voted_id": [self.user.id], "voted_id": [self.user.id],
}, },
"assignments/assignment-vote:1": { )
self.assertEqual(
autoupdate[0]["assignments/assignment-vote:1"],
{
"pollstate": AssignmentPoll.STATE_PUBLISHED, "pollstate": AssignmentPoll.STATE_PUBLISHED,
"id": 1, "id": 1,
"weight": "1.000000", "weight": "1.000000",
@ -2013,7 +2015,10 @@ class VoteAssignmentPollNamedAutoupdates(VoteAssignmentPollAutoupdatesBaseClass)
"user_id": 3, "user_id": 3,
"option_id": 1, "option_id": 1,
}, },
"assignments/assignment-option:1": { )
self.assertEqual(
autoupdate[0]["assignments/assignment-option:1"],
{
"abstain": "1.000000", "abstain": "1.000000",
"id": 1, "id": 1,
"no": "0.000000", "no": "0.000000",
@ -2023,8 +2028,8 @@ class VoteAssignmentPollNamedAutoupdates(VoteAssignmentPollAutoupdatesBaseClass)
"user_id": 1, "user_id": 1,
"weight": 1, "weight": 1,
}, },
},
) )
self.assertIn("users/user:3", autoupdate[0])
class VoteAssignmentPollPseudoanonymousAutoupdates( class VoteAssignmentPollPseudoanonymousAutoupdates(