From 7ff8023442aead94d87346f6d94c82e947837acf Mon Sep 17 00:00:00 2001 From: Burathar Date: Sun, 19 Jul 2020 17:03:00 +0200 Subject: [PATCH] Replace DataRequired with InputRequired, add CatchBunnyForm --- app/main/forms.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/app/main/forms.py b/app/main/forms.py index da0ab17..ec6206e 100644 --- a/app/main/forms.py +++ b/app/main/forms.py @@ -1,11 +1,11 @@ from flask_wtf import FlaskForm from wtforms import StringField, SubmitField, DateTimeField, BooleanField, HiddenField, FloatField, SelectField -from wtforms.validators import DataRequired, ValidationError, Length, NumberRange +from wtforms.validators import InputRequired, DataRequired, ValidationError, Length, NumberRange from pytz import timezone from app.models import Objective class CreateGameForm(FlaskForm): - game_name = StringField('Game Name', validators=[DataRequired(), Length(min=0, max=64)]) + game_name = StringField('Game Name', validators=[InputRequired(), Length(min=0, max=64)]) start_time_disabled = BooleanField('No start time') start_time = DateTimeField(id='datetimepicker_start', format="%d-%m-%Y %H:%M") end_time_disabled = BooleanField('No end time') @@ -41,15 +41,20 @@ class ObjectiveForm(FlaskForm): raise ValidationError('Please use a different name.') class PlayerUpdateForm(FlaskForm): - role = SelectField('Player Role', choices=[('none', 'none'), ('owner', 'owner'), ('hunter', 'hunter'), ('bunny', 'bunny')], validators=[DataRequired()]) + role = SelectField('Player Role', choices=[('none', 'none'), ('owner', 'owner'), ('hunter', 'hunter'), ('bunny', 'bunny')], validators=[InputRequired()]) submit = SubmitField('Update') class PlayerAddForm(FlaskForm): - name = StringField('Username', validators=[DataRequired(), Length(min=0, max=64)]) - role = SelectField('Player Role', choices=[('none', 'none'), ('owner', 'owner'), ('hunter', 'hunter'), ('bunny', 'bunny')], validators=[DataRequired()]) + name = StringField('Username', validators=[InputRequired(), Length(min=0, max=64)]) + role = SelectField('Player Role', choices=[('none', 'none'), ('owner', 'owner'), ('hunter', 'hunter'), ('bunny', 'bunny')], validators=[InputRequired()]) submit_add = SubmitField('Create') class UserCreateForm(FlaskForm): - name = StringField('Username', validators=[DataRequired(), Length(min=0, max=64)]) - role = SelectField('Player Role', choices=[('none', 'none'), ('owner', 'owner'), ('hunter', 'hunter'), ('bunny', 'bunny')], validators=[DataRequired()]) + name = StringField('Username', validators=[InputRequired(), Length(min=0, max=64)]) + role = SelectField('Player Role', choices=[('none', 'none'), ('owner', 'owner'), ('hunter', 'hunter'), ('bunny', 'bunny')], validators=[InputRequired()]) submit_create = SubmitField('Create') + +class CatchBunnyForm(FlaskForm): + bunny = SelectField('Bunny Name', coerce=int, validators=[InputRequired()]) + #photo + submit = SubmitField('Send')