Clear entitled votes after reset

This commit is contained in:
Finn Stutzenstein 2021-06-10 08:46:14 +02:00
parent d9d07c3c9b
commit bd3c8e09d8
No known key found for this signature in database
GPG Key ID: 9042F605C6324654
3 changed files with 7 additions and 0 deletions

View File

@ -253,6 +253,7 @@ class BasePoll(models.Model):
option.reset()
self.voted.clear()
self.entitled_users_at_stop = None
# Reset state
self.state = BasePoll.STATE_CREATED

View File

@ -7,3 +7,5 @@ pytest<5.4.2
pytest-django<3.9.0
pytest-asyncio<0.11.0
pytest-cov<2.8.2
types-bleach
types-pkg_resources

View File

@ -1394,6 +1394,7 @@ class ResetMotionPoll(TestCase):
pollmethod="YNA",
type=BasePoll.TYPE_ANALOG,
state=MotionPoll.STATE_FINISHED,
entitled_users_at_stop=[[{"some": ["important", "data"]}]],
)
self.poll.create_options()
self.option = self.poll.options.get()
@ -1416,6 +1417,7 @@ class ResetMotionPoll(TestCase):
self.assertEqual(poll.votesvalid, None)
self.assertEqual(poll.votesinvalid, None)
self.assertEqual(poll.votescast, None)
self.assertEqual(poll.entitled_users_at_stop, None)
option = poll.options.get()
self.assertEqual(option.yes, Decimal("0"))
self.assertEqual(option.no, Decimal("0"))
@ -1430,6 +1432,7 @@ class ResetMotionPoll(TestCase):
self.assertHttpStatusVerbose(response, status.HTTP_200_OK)
poll = MotionPoll.objects.get()
self.assertFalse(poll.is_pseudoanonymized)
self.assertEqual(poll.entitled_users_at_stop, None)
def test_reset_pseudoanonymous(self):
self.poll.type = BasePoll.TYPE_PSEUDOANONYMOUS
@ -1439,6 +1442,7 @@ class ResetMotionPoll(TestCase):
self.assertHttpStatusVerbose(response, status.HTTP_200_OK)
poll = MotionPoll.objects.get()
self.assertTrue(poll.is_pseudoanonymized)
self.assertEqual(poll.entitled_users_at_stop, None)
class TestMotionPollWithVoteDelegationAutoupdate(TestCase):