32 lines
1.1 KiB
Python
32 lines
1.1 KiB
Python
from flask_wtf import FlaskForm
|
|
from wtforms import StringField, SubmitField, TextAreaField, MultipleFileField
|
|
from wtforms.validators import DataRequired, Length
|
|
import app.utils.validators as vd
|
|
|
|
class CommentForm(FlaskForm):
|
|
message = TextAreaField('Message', validators=[DataRequired()])
|
|
attachments = MultipleFileField('Pièces-jointes',
|
|
validators=[vd.file.optional, vd.file.count, vd.file.extension,
|
|
vd.file.size, vd.file.namelength])
|
|
submit = SubmitField('Commenter')
|
|
preview = SubmitField('Prévisualiser')
|
|
|
|
class AnonymousCommentForm(CommentForm):
|
|
pseudo = StringField('Pseudo',
|
|
validators=[DataRequired(), vd.name_valid, vd.name_available])
|
|
|
|
class CommentEditForm(CommentForm):
|
|
submit = SubmitField('Modifier')
|
|
|
|
class AnonymousCommentEditForm(CommentEditForm, AnonymousCommentForm):
|
|
pass
|
|
|
|
|
|
class TopicCreationForm(CommentForm):
|
|
title = StringField('Nom du sujet',
|
|
validators=[DataRequired(), Length(min=3, max=32)])
|
|
submit = SubmitField('Créer le sujet')
|
|
|
|
class AnonymousTopicCreationForm(TopicCreationForm, AnonymousCommentForm):
|
|
pass
|