Merge pull request #2855 from emanuelschuetze/issue2623

Validates open posts field of assignment form (Fixes #2623)
This commit is contained in:
Norman Jäckel 2017-01-14 16:16:35 +01:00 committed by GitHub
commit 560b820b57
2 changed files with 12 additions and 0 deletions

View File

@ -22,6 +22,15 @@ from .models import (
) )
def posts_validator(data):
"""
Validator for open posts. It checks that the values for the open posts are greater than 0.
"""
if (data['open_posts'] and data['open_posts'] is not None and data['open_posts'] < 1):
raise ValidationError({'detail': _('Value for {} must be greater than 0').format('open_posts')})
return data
class AssignmentRelatedUserSerializer(ModelSerializer): class AssignmentRelatedUserSerializer(ModelSerializer):
""" """
Serializer for assignment.models.AssignmentRelatedUser objects. Serializer for assignment.models.AssignmentRelatedUser objects.
@ -198,6 +207,7 @@ class AssignmentFullSerializer(ModelSerializer):
'polls', 'polls',
'agenda_item_id', 'agenda_item_id',
'tags',) 'tags',)
validators = (posts_validator,)
class AssignmentShortSerializer(AssignmentFullSerializer): class AssignmentShortSerializer(AssignmentFullSerializer):
@ -220,3 +230,4 @@ class AssignmentShortSerializer(AssignmentFullSerializer):
'polls', 'polls',
'agenda_item_id', 'agenda_item_id',
'tags',) 'tags',)
validators = (posts_validator,)

View File

@ -180,6 +180,7 @@ angular.module('OpenSlidesApp.assignments.site', [
templateOptions: { templateOptions: {
label: gettextCatalog.getString('Number of persons to be elected'), label: gettextCatalog.getString('Number of persons to be elected'),
type: 'number', type: 'number',
min: 1,
required: true required: true
} }
}, },