summaryrefslogtreecommitdiffstats
path: root/forms.py
blob: 1944eaa059d97196ee16d82dc169ffc232737adf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
from wtforms import From, HiddenField, validators
from utils import Unique
from models import Group
from wtfpeewee.orm import model_form


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.')]}})


class DeleteGroup(Form):
    id = HiddenField('group id', [validators.Required()]);
    sure = HiddenField('are you sure');