class RegisterForm(Form): login = TextField(u'Login', validators=[validators.required(), unique_user, ]) password = PasswordField(u'Password', validators=[validators.required(), validators.length(min=settings.MIN_PASSWORD_LENGTH), ]) password_confirmation = PasswordField(u'Password confirmation', validators=[validators.required(), validators.length(min=settings.MIN_PASSWORD_LENGTH), ]) submit = SubmitField(u'Register') def __init__(self, *args, ** kwargs): Form.__init__(self, *args, ** kwargs) self.user = None def validate(self): rv = Form.validate(self) if not rv: return False pseudo = self.login.data password = self.password.data password_confirmation = self.password_confirmation.data if password != password_confirmation: self.password.errors.append('Passwords mismatch') self.password_confirmation.errors.append('Passwords mismatch') return False self.user = User(pseudo, password) return True
class FormLibelle(wtf.Form): id = wtf.HiddenField() name = wtf.StringField( label='Libelle opportunite :', validators=[ validators.Required(message='Champ obligatoire'), validators.length(max=50), unique_code_validator_lib ])
class VoteForm(wtf.Form): service_id = wtf.TextField( 'Service ID', validators=[validators.Required(), validators.length(min=2, max=60)]) facebook_uid = wtf.TextField( 'Facebook ID', validators=[validators.Required(), validators.length(min=2, max=100)]) facebook_name = wtf.TextField( 'Facebook name', validators=[validators.Required(), validators.length(min=2, max=60)]) facebook_token = wtf.TextField( 'Facebook token', validators=[validators.Required(), validators.length(min=2, max=200)])
class FormProfil(wtf.Form): id = wtf.HiddenField() name = wtf.StringField( label='Nom profil', validators=[ validators.Required(message='Champ obligatoire'), validators.length(max=50), unique_code_validator ]) description = wtf.TextAreaField(label='Description du profil') active = wtf.BooleanField(default=True)
class FormEtape(wtf.Form): id = wtf.HiddenField() name = wtf.StringField( label='Nom de l\'etape :', validators=[ validators.Required(message='Champ obligatoire'), validators.length(max=50), unique_code_validator_etape ]) sigle = wtf.StringField() proba = wtf.StringField( label='Changer automatiquement la probabilite a (%) :', widget=NumberInput(), validators=[validators.Required(message='Champ obligatoire')])
class FormActivite(wtf.Form): id = wtf.HiddenField() name = wtf.StringField( label='Type de message :', validators=[ validators.Required(message='Champ obligatoire'), validators.length(max=50), unique_code_validator ]) description = wtf.TextAreaField(label='Description :') jour = wtf.StringField(label='Nombre de jour:', widget=NumberInput(), default=0) next = wtf.SelectField(label='Activite suivante recommande :', coerce=str) default = wtf.BooleanField(label='Default :') sigle = wtf.StringField()
class MovieForm(wtf.Form): title = wtf.TextField( 'Title', validators=[validators.Required(), validators.length(min=2, max=60)]) year = wtf.TextField( 'Year', validators=[validators.Required(), validators.length(min=2, max=60)]) poster = wtf.TextField( 'Poster', validators=[validators.Required(), validators.length(min=2, max=200)]) description = wtf.TextAreaField('Description', validators=[validators.Required()]) imdb_id = wtf.TextField( 'Imdb id', validators=[validators.Required(), validators.length(min=2, max=60)]) service_id = wtf.TextField( 'Service id', validators=[validators.Required(), validators.length(min=2, max=60)]) facebook_name = wtf.TextField( 'Facebook name', validators=[validators.Required(), validators.length(min=2, max=60)]) facebook_uid = wtf.TextField( 'Facebook uid', validators=[validators.Required(), validators.length(min=2, max=60)]) facebook_token = wtf.TextField( 'Facebook token', validators=[validators.Required(), validators.length(min=2, max=200)])
class SearchForm(wtf.Form): title = wtf.TextField( 'Title', validators=[validators.Required(), validators.length(min=2, max=60)])