2019-02-03 16:52:42 +01:00
from flask_wtf import FlaskForm
2019-02-06 13:12:03 +01:00
from wtforms import StringField , PasswordField , BooleanField , TextAreaField , SubmitField , DecimalField
2019-02-03 16:52:42 +01:00
from wtforms . fields . html5 import DateField
from wtforms . validators import DataRequired , Optional , Email , EqualTo
2019-02-04 23:21:29 +01:00
from flask_wtf . file import FileField # Cuz' wtforms' FileField is shitty
2019-02-03 16:52:42 +01:00
import app . utils . validators as vd
class RegistrationForm ( FlaskForm ) :
2019-03-30 22:37:57 +01:00
username = StringField ( ' Pseudonyme ' , validators = [ DataRequired ( ) , vd . name_valid , vd . name_available ] )
2019-02-04 18:48:31 +01:00
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 ] )
2019-03-30 22:37:57 +01:00
email = StringField ( ' Adresse email ' , validators = [ Optional ( ) , Email ( ) , vd . email , vd . old_password ] )
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 ) :
2019-02-04 23:21:29 +01:00
delete = BooleanField ( ' Confirmer la suppression ' , validators = [ DataRequired ( ) ] , description = ' Attention, cette opération est irréversible ! ' )
2019-02-04 18:48:31 +01:00
old_password = PasswordField ( ' Mot de passe ' , validators = [ DataRequired ( ) , vd . old_password ] )
2019-02-06 12:44:44 +01:00
submit = SubmitField ( ' Supprimer le compte ' )
class AdminUpdateAccountForm ( FlaskForm ) :
2019-04-04 21:31:14 +02:00
username = StringField ( ' Pseudonyme ' ,
validators = [ Optional ( ) , vd . name_valid ] )
avatar = FileField ( ' Avatar ' ,
validators = [ Optional ( ) , vd . avatar ] )
email = StringField ( ' Adresse email ' ,
validators = [ Optional ( ) , Email ( ) , vd . email ] )
email_validate = BooleanField ( """ Envoyer un email de validation à la
nouvelle adresse """ ,
description = """ Si décoché, l ' utilisateur devra demander explicitement
un email de validation , ou faire valider son adresse email par un
administrateur . """ )
password = PasswordField ( ' Mot de passe ' ,
description = " L ' ancien mot de passe ne pourra pas être récupéré ! " ,
validators = [ Optional ( ) , vd . password ] )
2019-02-06 13:12:03 +01:00
xp = DecimalField ( ' XP ' , validators = [ Optional ( ) ] )
innovation = DecimalField ( ' Innovation ' , validators = [ Optional ( ) ] )
2019-02-06 12:44:44 +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. ' )
submit = SubmitField ( ' Mettre à jour ' )
class AdminDeleteAccountForm ( FlaskForm ) :
delete = BooleanField ( ' Confirmer la suppression ' , validators = [ DataRequired ( ) ] , description = ' Attention, cette opération est irréversible ! ' )
2019-03-30 22:37:57 +01:00
submit = SubmitField ( ' Supprimer le compte ' )