Merge pull request #2855 from emanuelschuetze/issue2623
Validates open posts field of assignment form (Fixes #2623)
This commit is contained in:
commit
560b820b57
@ -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,)
|
||||||
|
@ -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
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user