2021-02-20 00:39:22 +01:00
|
|
|
|
from flask_wtf import FlaskForm
|
2021-02-22 23:50:19 +01:00
|
|
|
|
from wtforms import StringField, SubmitField, TextAreaField, SelectField, \
|
|
|
|
|
BooleanField
|
2021-02-20 00:39:22 +01:00
|
|
|
|
from wtforms.fields.html5 import DateTimeField
|
2021-02-20 01:28:08 +01:00
|
|
|
|
from wtforms.validators import InputRequired, Optional
|
2021-02-20 00:39:22 +01:00
|
|
|
|
|
2021-02-20 01:28:08 +01:00
|
|
|
|
from datetime import datetime, timedelta
|
2021-02-20 00:39:22 +01:00
|
|
|
|
|
2021-02-20 01:28:08 +01:00
|
|
|
|
class PollForm(FlaskForm):
|
2021-02-20 00:39:22 +01:00
|
|
|
|
title = StringField(
|
|
|
|
|
'Question',
|
|
|
|
|
validators=[
|
|
|
|
|
InputRequired(),
|
2021-02-20 01:28:08 +01:00
|
|
|
|
]
|
2021-02-20 00:39:22 +01:00
|
|
|
|
)
|
2021-02-20 01:28:08 +01:00
|
|
|
|
choices = TextAreaField(
|
2021-02-20 00:39:22 +01:00
|
|
|
|
'Choix (un par ligne)',
|
|
|
|
|
validators=[
|
|
|
|
|
InputRequired(),
|
2021-02-20 01:28:08 +01:00
|
|
|
|
# TODO: add a validator to check if there is at least one choice
|
|
|
|
|
]
|
|
|
|
|
)
|
2021-02-22 22:49:11 +01:00
|
|
|
|
type = SelectField(
|
|
|
|
|
'Type',
|
|
|
|
|
choices=[
|
|
|
|
|
('simplepoll', 'Réponse unique'),
|
|
|
|
|
('multiplepoll', 'Réponses multiples')
|
|
|
|
|
]
|
|
|
|
|
)
|
2021-02-20 01:28:08 +01:00
|
|
|
|
start = DateTimeField(
|
|
|
|
|
'Début',
|
|
|
|
|
default=datetime.now(),
|
|
|
|
|
validators=[
|
|
|
|
|
Optional()
|
|
|
|
|
]
|
|
|
|
|
)
|
|
|
|
|
end = DateTimeField(
|
|
|
|
|
'Fin',
|
|
|
|
|
default=datetime.now() + timedelta(days=1),
|
|
|
|
|
validators=[
|
|
|
|
|
Optional()
|
|
|
|
|
]
|
2021-02-20 00:39:22 +01:00
|
|
|
|
)
|
|
|
|
|
submit = SubmitField(
|
2021-02-20 01:28:08 +01:00
|
|
|
|
'Créer le sondage'
|
2021-02-20 00:39:22 +01:00
|
|
|
|
)
|
2021-02-22 23:50:19 +01:00
|
|
|
|
|
|
|
|
|
class DeletePollForm(FlaskForm):
|
|
|
|
|
delete = BooleanField(
|
|
|
|
|
'Confirmer la suppression',
|
|
|
|
|
validators=[
|
|
|
|
|
InputRequired(),
|
|
|
|
|
],
|
|
|
|
|
description='Attention, cette opération est irréversible !'
|
|
|
|
|
)
|
|
|
|
|
submit = SubmitField(
|
|
|
|
|
'Supprimer le sondage'
|
|
|
|
|
)
|