26 lines
932 B
Python
26 lines
932 B
Python
from flask_wtf import FlaskForm
|
|
from wtforms import StringField, FormField, SubmitField, TextAreaField, \
|
|
MultipleFileField
|
|
from wtforms.validators import DataRequired, Length, Optional
|
|
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])
|
|
submit = SubmitField('Commenter')
|
|
|
|
class AnonymousCommentForm(CommentForm):
|
|
pseudo = StringField('Pseudo',
|
|
validators=[DataRequired(), vd.name_valid, vd.name_available])
|
|
|
|
|
|
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
|