-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
658 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
from flask.ext.wtf import Form | ||
from wtforms import StringField, PasswordField, BooleanField, SubmitField, \ | ||
DateField | ||
from wtforms.validators import Required, Length, Email, Regexp, EqualTo | ||
from wtforms import ValidationError | ||
from .models import User | ||
|
||
|
||
class LoginForm(Form): | ||
email = StringField('Email', validators=[Required(), Length(1, 64), | ||
Email()]) | ||
password = PasswordField('Password', validators=[Required(), | ||
Length(1, 32)]) | ||
|
||
def validate(self): | ||
if not Form.validate(self): | ||
return False | ||
user = User.query.filter_by(email=self.email.data).first() | ||
if user is not None and not user.verify_password(self.password.data): | ||
self.password.errors.append('Incorrect password.') | ||
return False | ||
return True | ||
|
||
|
||
class PresentationForm(Form): | ||
name = StringField('Presentation name', validators=[Required(), | ||
Length(1, 60)]) | ||
filename = StringField('File name', validators=[Required(), | ||
Length(1, 255)]) | ||
is_active = BooleanField() | ||
number = StringField('Text-in phone number', validators=[Length(8, 32)]) | ||
email = StringField('Text-in email address', validators=[Length(4, 40), | ||
Email()]) | ||
choices = StringField('Choices (semicolon delimited)', | ||
validators=[Required()]) | ||
|
||
def validate(self): | ||
if not Form.validate(self): | ||
return False | ||
f = Presentation.query.filter_by(filename=self.filename.data).first() | ||
if f is not None: | ||
self.filename.append('File name must be new and unique.') | ||
return False | ||
return True |
Oops, something went wrong.