2019-02-03 16:52:42 +01:00
from flask_wtf import FlaskForm
from wtforms import StringField , PasswordField , BooleanField , TextAreaField , SubmitField , FileField
from wtforms . fields . html5 import DateField
from wtforms . validators import DataRequired , Optional , Email , EqualTo
import app . utils . validators as vd
class RegistrationForm ( FlaskForm ) :
2019-02-04 18:48:31 +01:00
username = StringField ( ' Pseudonyme ' , validators = [ DataRequired ( ) , vd . name ] )
email = StringField ( ' Adresse Email ' , validators = [ DataRequired ( ) , Email ( ) , vd . email ] )
2019-02-03 16:52:42 +01:00
password = PasswordField ( ' Mot de passe ' , validators = [ DataRequired ( ) , vd . password ] )
password2 = PasswordField ( ' Répéter le mot de passe ' , validators = [ DataRequired ( ) , EqualTo ( ' password ' ) ] )
guidelines = BooleanField ( ' J’ accepte les <a href= " # " >CGU</a> ' , validators = [ DataRequired ( ) ] )
newsletter = BooleanField ( ' Inscription à la newsletter ' , description = ' Un mail par trimestre environ, pour être prévenu des concours, évènements et nouveautés. ' )
submit = SubmitField ( ' S \' enregistrer ' )
class UpdateAccountForm ( FlaskForm ) :
2019-02-04 18:48:31 +01:00
avatar = FileField ( ' Avatar ' , validators = [ Optional ( ) , vd . avatar ] )
email = StringField ( ' Adresse Email ' , validators = [ Optional ( ) , Email ( ) , vd . email , vd . old_password ] )
2019-02-04 17:02:25 +01:00
password = PasswordField ( ' Mot de passe : ' , validators = [ Optional ( ) , vd . password , vd . old_password ] )
2019-02-03 16:52:42 +01:00
password2 = PasswordField ( ' Répéter le mot de passe ' , validators = [ Optional ( ) , EqualTo ( ' password ' ) ] )
2019-02-04 18:48:31 +01:00
old_password = PasswordField ( ' Mot de passe actuel ' , validators = [ Optional ( ) ] )
2019-02-03 16:52:42 +01:00
birthday = DateField ( ' Anniversaire ' , validators = [ Optional ( ) ] )
signature = TextAreaField ( ' Signature ' , validators = [ Optional ( ) ] )
biography = TextAreaField ( ' Présentation ' , validators = [ Optional ( ) ] )
newsletter = BooleanField ( ' Inscription à la newsletter ' , description = ' Un mail par trimestre environ, pour être prévenu des concours, évènements et nouveautés. ' )
2019-02-04 18:48:31 +01:00
submit = SubmitField ( ' Mettre à jour ' )
class DeleteAccountForm ( FlaskForm ) :
delete = BooleanField ( ' Supprimer le compte ' , validators = [ DataRequired ( ) ] , description = ' Attention, cette opération est irréversible ! ' )
old_password = PasswordField ( ' Mot de passe ' , validators = [ DataRequired ( ) , vd . old_password ] )
submit = SubmitField ( ' Supprimer le compte ' )