Code source de Planète Casio https://planet-casio.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

account.py 3.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. from flask_wtf import FlaskForm
  2. from wtforms import StringField, PasswordField, BooleanField, TextAreaField, SubmitField, DecimalField
  3. from wtforms.fields.html5 import DateField
  4. from wtforms.validators import DataRequired, Optional, Email, EqualTo
  5. from flask_wtf.file import FileField # Cuz' wtforms' FileField is shitty
  6. import app.utils.validators as vd
  7. class RegistrationForm(FlaskForm):
  8. username = StringField('Pseudonyme', validators=[DataRequired(), vd.name_valid, vd.name_available])
  9. email = StringField('Adresse Email', validators=[DataRequired(), Email(), vd.email])
  10. password = PasswordField('Mot de passe', validators=[DataRequired(), vd.password])
  11. password2 = PasswordField('Répéter le mot de passe', validators=[DataRequired(), EqualTo('password')])
  12. guidelines = BooleanField('J’accepte les <a href="#">CGU</a>', validators=[DataRequired()])
  13. newsletter = BooleanField('Inscription à la newsletter', description='Un mail par trimestre environ, pour être prévenu des concours, évènements et nouveautés.')
  14. submit = SubmitField('S\'enregistrer')
  15. class UpdateAccountForm(FlaskForm):
  16. avatar = FileField('Avatar', validators=[Optional(), vd.avatar])
  17. email = StringField('Adresse email', validators=[Optional(), Email(), vd.email, vd.old_password])
  18. password = PasswordField('Mot de passe', validators=[Optional(), vd.password, vd.old_password])
  19. password2 = PasswordField('Répéter le mot de passe', validators=[Optional(), EqualTo('password')])
  20. old_password = PasswordField('Mot de passe actuel', validators=[Optional()])
  21. birthday = DateField('Anniversaire', validators=[Optional()])
  22. signature = TextAreaField('Signature', validators=[Optional()])
  23. biography = TextAreaField('Présentation', validators=[Optional()])
  24. newsletter = BooleanField('Inscription à la newsletter', description='Un mail par trimestre environ, pour être prévenu des concours, évènements et nouveautés.')
  25. submit = SubmitField('Mettre à jour')
  26. class DeleteAccountForm(FlaskForm):
  27. delete = BooleanField('Confirmer la suppression', validators=[DataRequired()], description='Attention, cette opération est irréversible !')
  28. old_password = PasswordField('Mot de passe', validators=[DataRequired(), vd.old_password])
  29. submit = SubmitField('Supprimer le compte')
  30. class AdminUpdateAccountForm(FlaskForm):
  31. username = StringField('Pseudonyme', validators=[Optional(), vd.name_valid])
  32. avatar = FileField('Avatar', validators=[Optional(), vd.avatar])
  33. email = StringField('Adresse email', validators=[Optional(), Email(), vd.email])
  34. password = PasswordField('Mot de passe', validators=[Optional(), vd.password])
  35. xp = DecimalField('XP', validators=[Optional()])
  36. innovation = DecimalField('Innovation', validators=[Optional()])
  37. birthday = DateField('Anniversaire', validators=[Optional()])
  38. signature = TextAreaField('Signature', validators=[Optional()])
  39. biography = TextAreaField('Présentation', validators=[Optional()])
  40. newsletter = BooleanField('Inscription à la newsletter', description='Un mail par trimestre environ, pour être prévenu des concours, évènements et nouveautés.')
  41. submit = SubmitField('Mettre à jour')
  42. class AdminDeleteAccountForm(FlaskForm):
  43. delete = BooleanField('Confirmer la suppression', validators=[DataRequired()], description='Attention, cette opération est irréversible !')
  44. submit = SubmitField('Supprimer le compte')