diff --git a/openslides/assignments/views.py b/openslides/assignments/views.py index 53acf6033..b2318b6a1 100644 --- a/openslides/assignments/views.py +++ b/openslides/assignments/views.py @@ -162,14 +162,15 @@ class AssignmentViewSet(ModelViewSet): detail = _('You can not nominate someone to this election because it is finished.') raise ValidationError({'detail': detail}) if assignment.phase == assignment.PHASE_VOTING and not request.user.has_perm('assignments.can_manage'): - # To nominate other during voting you have to be a manager. + # To nominate another user during voting you have to be a manager. self.permission_denied(request) if not request.user.has_perm('assignments.can_manage'): if assignment.is_blocked(user): raise ValidationError({'detail': _('User %s does not want to be a candidate. Only a manager can do this.') % user}) if assignment.is_elected(user): raise ValidationError({'detail': _('User %s is already elected.') % user}) - # If the user is already a candidate he can be nominated nevertheless. + if assignment.is_candidate(user): + raise ValidationError({'detail': _('User %s is already nominated.') % user}) assignment.set_candidate(user) return _('User %s was nominated successfully.') % user diff --git a/tests/integration/assignments/test_viewset.py b/tests/integration/assignments/test_viewset.py index 6f8b5d005..06892faee 100644 --- a/tests/integration/assignments/test_viewset.py +++ b/tests/integration/assignments/test_viewset.py @@ -151,8 +151,7 @@ class CandidatureOther(TestCase): reverse('assignment-candidature-other', args=[self.assignment.pk]), {'user': self.user.pk}) - self.assertEqual(response.status_code, 200) - self.assertTrue(Assignment.objects.get(pk=self.assignment.pk).candidates.filter(username='test_user_eeheekai4Phue6cahtho').exists()) + self.assertEqual(response.status_code, 400) def test_nominate_other_when_finished(self): self.assignment.set_phase(Assignment.PHASE_FINISHED)