2019-02-03 16:52:42 +01:00
|
|
|
|
from flask_wtf import FlaskForm
|
2019-06-11 00:15:23 +02:00
|
|
|
|
from wtforms import StringField, PasswordField, BooleanField, TextAreaField, SubmitField, DecimalField, SelectField
|
2019-02-03 16:52:42 +01:00
|
|
|
|
from wtforms.fields.html5 import DateField
|
2019-06-11 00:15:23 +02:00
|
|
|
|
from wtforms.validators import DataRequired, InputRequired, Optional, Email, EqualTo
|
2019-06-05 01:44:38 +02:00
|
|
|
|
from flask_wtf.file import FileField # Cuz' wtforms' FileField is shitty
|
2019-06-11 00:15:23 +02:00
|
|
|
|
from app.models.trophies import Trophy
|
2019-02-03 16:52:42 +01:00
|
|
|
|
import app.utils.validators as vd
|
|
|
|
|
|
2019-06-05 01:44:38 +02:00
|
|
|
|
|
2019-02-03 16:52:42 +01:00
|
|
|
|
class RegistrationForm(FlaskForm):
|
2019-09-13 19:34:20 +02:00
|
|
|
|
username = StringField(
|
|
|
|
|
'Pseudonyme',
|
|
|
|
|
description='Ce nom est définitif !',
|
|
|
|
|
validators=[
|
|
|
|
|
DataRequired(),
|
|
|
|
|
vd.name_valid,
|
|
|
|
|
vd.name_available,
|
|
|
|
|
],
|
|
|
|
|
)
|
|
|
|
|
email = StringField(
|
|
|
|
|
'Adresse Email',
|
|
|
|
|
validators=[
|
|
|
|
|
DataRequired(),
|
|
|
|
|
Email(message="Addresse email invalide."),
|
|
|
|
|
vd.email,
|
|
|
|
|
],
|
|
|
|
|
)
|
|
|
|
|
password = PasswordField(
|
|
|
|
|
'Mot de passe',
|
|
|
|
|
validators=[
|
|
|
|
|
DataRequired(),
|
|
|
|
|
vd.password,
|
|
|
|
|
],
|
|
|
|
|
)
|
|
|
|
|
password2 = PasswordField(
|
|
|
|
|
'Répéter le mot de passe',
|
|
|
|
|
validators=[
|
|
|
|
|
DataRequired(),
|
|
|
|
|
EqualTo('password', message="Les mots de passe doivent être identiques."),
|
|
|
|
|
],
|
|
|
|
|
)
|
|
|
|
|
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'inscrire",
|
|
|
|
|
)
|
2019-02-03 16:52:42 +01:00
|
|
|
|
|
2019-06-05 01:44:38 +02:00
|
|
|
|
|
2019-02-03 16:52:42 +01:00
|
|
|
|
class UpdateAccountForm(FlaskForm):
|
2019-09-13 19:34:20 +02:00
|
|
|
|
avatar = FileField(
|
|
|
|
|
'Avatar',
|
|
|
|
|
validators=[
|
|
|
|
|
Optional(),
|
|
|
|
|
vd.avatar,
|
|
|
|
|
],
|
|
|
|
|
)
|
|
|
|
|
email = StringField(
|
|
|
|
|
'Adresse email',
|
|
|
|
|
validators=[
|
|
|
|
|
Optional(),
|
|
|
|
|
Email(message="Addresse email invalide."),
|
|
|
|
|
vd.email,
|
|
|
|
|
vd.old_password,
|
|
|
|
|
],
|
|
|
|
|
)
|
|
|
|
|
password = PasswordField(
|
|
|
|
|
'Mot de passe',
|
|
|
|
|
validators=[
|
|
|
|
|
Optional(),
|
|
|
|
|
vd.password,
|
|
|
|
|
vd.old_password,
|
|
|
|
|
],
|
|
|
|
|
)
|
|
|
|
|
password2 = PasswordField(
|
|
|
|
|
'Répéter le mot de passe',
|
|
|
|
|
validators=[
|
|
|
|
|
Optional(),
|
|
|
|
|
EqualTo('password', message="Les mots de passe doivent être identiques."),
|
|
|
|
|
],
|
|
|
|
|
)
|
|
|
|
|
old_password = PasswordField(
|
|
|
|
|
'Mot de passe actuel',
|
|
|
|
|
validators=[
|
|
|
|
|
Optional(),
|
|
|
|
|
],
|
|
|
|
|
)
|
|
|
|
|
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')
|
|
|
|
|
|
2019-06-05 01:44:38 +02:00
|
|
|
|
|
2019-02-04 18:48:31 +01:00
|
|
|
|
class DeleteAccountForm(FlaskForm):
|
2019-09-13 19:34:20 +02:00
|
|
|
|
delete = BooleanField(
|
|
|
|
|
'Confirmer la suppression',
|
|
|
|
|
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',
|
|
|
|
|
)
|
2019-02-06 12:44:44 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class AdminUpdateAccountForm(FlaskForm):
|
2019-09-13 19:34:20 +02:00
|
|
|
|
username = StringField(
|
|
|
|
|
'Pseudonyme',
|
|
|
|
|
validators=[
|
|
|
|
|
Optional(),
|
|
|
|
|
vd.name_valid,
|
|
|
|
|
],
|
|
|
|
|
)
|
|
|
|
|
avatar = FileField(
|
|
|
|
|
'Avatar',
|
|
|
|
|
validators=[
|
|
|
|
|
Optional(),
|
|
|
|
|
vd.avatar,
|
|
|
|
|
],
|
|
|
|
|
)
|
|
|
|
|
email = StringField(
|
|
|
|
|
'Adresse email',
|
|
|
|
|
validators=[
|
|
|
|
|
Optional(),
|
|
|
|
|
Email(message="Addresse email invalide."),
|
|
|
|
|
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,
|
|
|
|
|
],
|
|
|
|
|
)
|
|
|
|
|
xp = DecimalField(
|
|
|
|
|
'XP',
|
|
|
|
|
validators=[
|
|
|
|
|
Optional(),
|
|
|
|
|
]
|
|
|
|
|
)
|
|
|
|
|
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',
|
|
|
|
|
)
|
2019-02-06 12:44:44 +01:00
|
|
|
|
|
2019-06-05 01:44:38 +02:00
|
|
|
|
|
2019-08-10 00:07:50 +02:00
|
|
|
|
class AdminAccountEditTrophyForm(FlaskForm):
|
2019-08-19 16:15:32 +02:00
|
|
|
|
# Boolean inputs are generated on-the-fly from trophy list
|
2019-09-13 19:34:20 +02:00
|
|
|
|
submit = SubmitField(
|
|
|
|
|
'Modifier',
|
|
|
|
|
)
|
2019-06-11 00:15:23 +02:00
|
|
|
|
|
|
|
|
|
|
2019-02-06 12:44:44 +01:00
|
|
|
|
class AdminDeleteAccountForm(FlaskForm):
|
2019-09-13 19:34:20 +02:00
|
|
|
|
delete = BooleanField(
|
|
|
|
|
'Confirmer la suppression',
|
|
|
|
|
validators=[
|
|
|
|
|
DataRequired(),
|
|
|
|
|
],
|
|
|
|
|
description='Attention, cette opération est irréversible !',
|
|
|
|
|
)
|
|
|
|
|
submit = SubmitField(
|
|
|
|
|
'Supprimer le compte',
|
|
|
|
|
)
|