diff --git a/openslides/poll/serializers.py b/openslides/poll/serializers.py index 82d4a6a6f..e9432537a 100644 --- a/openslides/poll/serializers.py +++ b/openslides/poll/serializers.py @@ -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 diff --git a/tests/integration/assignments/test_viewset.py b/tests/integration/assignments/test_viewset.py index 5c3ff649c..e209a23fe 100644 --- a/tests/integration/assignments/test_viewset.py +++ b/tests/integration/assignments/test_viewset.py @@ -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) diff --git a/tests/integration/motions/test_viewset.py b/tests/integration/motions/test_viewset.py index 81c14df24..aa02f9163 100644 --- a/tests/integration/motions/test_viewset.py +++ b/tests/integration/motions/test_viewset.py @@ -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)