Fixed error in poll default_votes_validator. Fixed #1967.
This commit is contained in:
parent
ad7653fb76
commit
198f09801c
@ -10,6 +10,8 @@ def default_votes_validator(data):
|
||||
than or equal to -2.
|
||||
"""
|
||||
for key in data:
|
||||
if key in ('votesvalid', 'votesinvalid', 'votescast') and data[key] < -2:
|
||||
if (key in ('votesvalid', 'votesinvalid', 'votescast') and
|
||||
data[key] is not None and
|
||||
data[key] < -2):
|
||||
raise ValidationError({'detail': _('Value for {} must not be less than -2').format(key)})
|
||||
return data
|
||||
|
@ -307,3 +307,10 @@ class UpdateAssignmentPoll(TestCase):
|
||||
{'assignment_id': self.assignment.pk,
|
||||
'votescast': '-3'})
|
||||
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
|
||||
|
||||
def test_empty_value_for_votesvalid(self):
|
||||
response = self.client.put(
|
||||
reverse('assignmentpoll-detail', args=[self.poll.pk]),
|
||||
{'assignment_id': self.assignment.pk,
|
||||
'votesvalid': ''})
|
||||
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||
|
@ -395,3 +395,10 @@ class UpdateMotionPoll(TestCase):
|
||||
{'motion_id': self.motion.pk,
|
||||
'votescast': '-3'})
|
||||
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
|
||||
|
||||
def test_empty_value_for_votesvalid(self):
|
||||
response = self.client.put(
|
||||
reverse('motionpoll-detail', args=[self.poll.pk]),
|
||||
{'motion_id': self.motion.pk,
|
||||
'votesvalid': ''})
|
||||
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||
|
Loading…
Reference in New Issue
Block a user