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):
"""
Serializer for assignment.models.AssignmentRelatedUser objects.
@ -198,6 +207,7 @@ class AssignmentFullSerializer(ModelSerializer):
'polls',
'agenda_item_id',
'tags',)
validators = (posts_validator,)
class AssignmentShortSerializer(AssignmentFullSerializer):
@ -220,3 +230,4 @@ class AssignmentShortSerializer(AssignmentFullSerializer):
'polls',
'agenda_item_id',
'tags',)
validators = (posts_validator,)

View File

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