Merge pull request #5316 from jsangmeister/voting-autoupdate-fix

Fixes the voting autoupdate bug
This commit is contained in:
jsangmeister 2020-04-17 16:58:50 +02:00 committed by GitHub
commit ad4ed3443a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 49 additions and 43 deletions

View File

@ -156,6 +156,7 @@ class BasePollViewSet(ModelViewSet):
poll.state = BasePoll.STATE_PUBLISHED
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_options())
return Response()

View File

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