summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Sulfrian <alex@spline.inf.fu-berlin.de>2014-11-18 05:45:16 +0100
committerAlexander Sulfrian <alex@spline.inf.fu-berlin.de>2014-11-19 02:15:56 +0100
commitbdb756fdc7e8391a786cf9e896ac78400b2d925e (patch)
tree37fe9fcc59ceff88c793d0f29ecd94e666250ad3
parentbd264ff3f5467c7bdf3973b6134c8e8d6242e0d9 (diff)
downloadpadlite-teams-bdb756fdc7e8391a786cf9e896ac78400b2d925e.tar.gz
padlite-teams-bdb756fdc7e8391a786cf9e896ac78400b2d925e.tar.bz2
padlite-teams-bdb756fdc7e8391a786cf9e896ac78400b2d925e.zip
forms: use models_form from wtfpeewee for CreateGroup
-rw-r--r--forms.py22
1 files changed, 12 insertions, 10 deletions
diff --git a/forms.py b/forms.py
index a2c36fb..1944eaa 100644
--- a/forms.py
+++ b/forms.py
@@ -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()]);