-
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.
Merge branch 'master' of github.com:makaimc/choose-your-own-adventure…
…-presentations
- Loading branch information
Showing
27 changed files
with
417 additions
and
723 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
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 |
---|---|---|
@@ -1,36 +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 | ||
DateField, IntegerField | ||
from wtforms.validators import Required, Length, Regexp, EqualTo | ||
from wtforms import ValidationError | ||
from .models import User, Presentation | ||
from .models import Wizard, Presentation | ||
|
||
|
||
class LoginForm(Form): | ||
email = StringField('Email', validators=[Required(), Length(1, 64), | ||
Email()]) | ||
password = PasswordField('Password', validators=[Required(), | ||
wizard_name = StringField('Wizard Name', | ||
validators=[Required(), Length(1, 32)]) | ||
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() | ||
user = Wizard.query.filter_by(wizard_name=self. | ||
wizard_name.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(), | ||
name = StringField('Presentation name', validators=[Required(), | ||
Length(1, 60)]) | ||
filename = StringField('File name', validators=[Required(), | ||
filename = StringField('File name', validators=[Required(), | ||
Length(1, 255)]) | ||
url_slug = StringField('Public URL slug', validators=[Required(), | ||
Length(1, 255)]) | ||
slug = StringField('URL slug', validators=[Required(), | ||
Length(1, 255)]) | ||
is_active = BooleanField() | ||
number = StringField('Text-in phone number', validators=[Length(0, 32)]) | ||
email = StringField('Text-in email address', validators=[Length(0, 40)]) | ||
choices = StringField('Choices (semicolon delimited)') | ||
voting_number = StringField('Text-in phone number', | ||
validators=[Length(0, 32)]) | ||
enable_browser_voting = BooleanField() | ||
|
||
|
||
class ChoiceForm(Form): | ||
name = StringField('Voting choice name', validators=[Required(), | ||
Length(1, 60)]) | ||
slug = StringField('URL slug', validators=[Required(), | ||
Length(1, 60)]) | ||
decision_point = IntegerField('Decision Point #', validators=[Required()]) |
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
Oops, something went wrong.