diff options
Diffstat (limited to 'forms.py')
-rw-r--r-- | forms.py | 22 |
1 files changed, 12 insertions, 10 deletions
@@ -1,17 +1,19 @@ -from wtforms import Form, BooleanField, TextField, HiddenField, validators +from wtforms import From, HiddenField, validators from utils import Unique from models import Group +from wtfpeewee.orm import model_form -class CreateGroup(Form): - name = TextField('group name', [ + +CreateGroup = model_form(Group, exclude=['api_id'], field_args={ + 'name': {'validators': [ validators.Required(), - validators.Regexp('^[a-zA-Z1-9_-]+$', - message=u'Invalid group name (only simple characters, numbers, - and _).'), - validators.Regexp('^[a-zA-Z1-9]', - message=u'Group name should not start with a special character.'), - Unique(Group, Group.name, - message=u'A group with this name already exists.')]) - public = BooleanField('public') + validators.Regexp('^[a-zA-Z1-9_-]+$', message=u'Invalid group name ' + '(only simple characters, numbers, - and _).'), + validators.Regexp('^[a-zA-Z1-9]', message=u'Group name should not ' + 'start with a special character.'), + Unique(Group, Group.name, message=u'A group with this name ' + 'already exists.')]}}) + class DeleteGroup(Form): id = HiddenField('group id', [validators.Required()]); |