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.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,52 +1979,57 @@ 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,
"assignment_id": 1,
"description": "test_description_paiquei5ahpie1wu8ohW",
"global_abstain": True,
"global_no": True,
"groups_id": [GROUP_DELEGATE_PK],
"id": 1,
"majority_method": "two_thirds",
"onehundred_percent_base": "cast",
"options_id": [1],
"pollmethod": "YNA",
"state": 4,
"title": self.poll.title,
"type": "named",
"votes_amount": 1,
"votescast": "1.000000",
"votesinvalid": "0.000000",
"votesvalid": "1.000000",
"user_has_voted": user == self.user,
"voted_id": [self.user.id],
},
"assignments/assignment-vote:1": {
"pollstate": AssignmentPoll.STATE_PUBLISHED,
"id": 1,
"weight": "1.000000",
"value": "A",
"user_id": 3,
"option_id": 1,
},
"assignments/assignment-option:1": {
"abstain": "1.000000",
"id": 1,
"no": "0.000000",
"poll_id": 1,
"pollstate": AssignmentPoll.STATE_PUBLISHED,
"yes": "0.000000",
"user_id": 1,
"weight": 1,
},
"allow_multiple_votes_per_candidate": False,
"amount_global_abstain": None,
"amount_global_no": None,
"assignment_id": 1,
"description": "test_description_paiquei5ahpie1wu8ohW",
"global_abstain": True,
"global_no": True,
"groups_id": [GROUP_DELEGATE_PK],
"id": 1,
"majority_method": "two_thirds",
"onehundred_percent_base": "cast",
"options_id": [1],
"pollmethod": "YNA",
"state": 4,
"title": self.poll.title,
"type": "named",
"votes_amount": 1,
"votescast": "1.000000",
"votesinvalid": "0.000000",
"votesvalid": "1.000000",
"user_has_voted": user == self.user,
"voted_id": [self.user.id],
},
)
self.assertEqual(
autoupdate[0]["assignments/assignment-vote:1"],
{
"pollstate": AssignmentPoll.STATE_PUBLISHED,
"id": 1,
"weight": "1.000000",
"value": "A",
"user_id": 3,
"option_id": 1,
},
)
self.assertEqual(
autoupdate[0]["assignments/assignment-option:1"],
{
"abstain": "1.000000",
"id": 1,
"no": "0.000000",
"poll_id": 1,
"pollstate": AssignmentPoll.STATE_PUBLISHED,
"yes": "0.000000",
"user_id": 1,
"weight": 1,
},
)
self.assertIn("users/user:3", autoupdate[0])
class VoteAssignmentPollPseudoanonymousAutoupdates(