From 8c8bd2287772edc5fd5ff827d9aab117d29f8406 Mon Sep 17 00:00:00 2001 From: Sketch <75850871+SketchMaster2001@users.noreply.github.com> Date: Wed, 3 Jul 2024 13:54:01 -0400 Subject: [PATCH] fix: Set max instead of absolute length for underground forms --- theunderground/forms.py | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/theunderground/forms.py b/theunderground/forms.py index 50ebe9bb..d8bda16b 100644 --- a/theunderground/forms.py +++ b/theunderground/forms.py @@ -81,7 +81,9 @@ class PayMovieUploadForm(FlaskForm): class CategoryForm(FlaskForm): - category_name = StringField("Category Name", validators=[DataRequired(), Length(max=61)]) + category_name = StringField( + "Category Name", validators=[DataRequired(), Length(max=61)] + ) room = SelectField("Room", validators=[DataRequired()]) thumbnail = FileField("Category Thumbnail") submit = SubmitField("Add") @@ -100,7 +102,7 @@ class RoomForm(FlaskForm): has_mascot = BooleanField("Mascot Enabled") intro_msg = TextAreaField("Intro Message", validators=[DataRequired()]) mii_msg = TextAreaField("Mii Message", validators=[DataRequired()]) - news = StringField("Company", validators=[DataRequired(), Length(41)]) + news = StringField("Company", validators=[DataRequired(), Length(max=41)]) # PostgreSQL treats an empty string ('') separately from NULL (None in Python). # https://stackoverflow.com/a/21853689 contact = StringField("Contact Information", filters=[lambda x: x or None]) @@ -117,20 +119,20 @@ class PreRoomData(FlaskForm): class RoomDeliveryData(FlaskForm): movie = FileField("Movie", validators=[FileRequired()]) - title = StringField("Title", validators=[DataRequired(), Length(47)]) + title = StringField("Title", validators=[DataRequired(), Length(max=47)]) tv = FileField("TV Screen Image", validators=[FileRequired()]) image = FileField("Image After Movie", validators=[FileRequired()]) upload = SubmitField("Upload") class RoomVoteData(FlaskForm): - title = StringField("Title", validators=[DataRequired(), Length(47)]) + title = StringField("Title", validators=[DataRequired(), Length(max=47)]) tv = FileField("TV Screen Image", validators=[FileRequired()]) image1 = FileField("Answer Photo 1", validators=[FileRequired()]) image2 = FileField("Answer Photo 2", validators=[FileRequired()]) image3 = FileField("Answer Photo 3", validators=[FileRequired()]) - question = StringField("Question", validators=[DataRequired(), Length(41)]) - mii_msg = StringField("Mii Message", validators=[DataRequired(), Length(51)]) + question = StringField("Question", validators=[DataRequired(), Length(max=41)]) + mii_msg = StringField("Mii Message", validators=[DataRequired(), Length(max=51)]) upload = SubmitField("Upload") @@ -139,7 +141,7 @@ class RoomMovieData(FlaskForm): "Movie ID(Make sure you know the ID of the movie you want)", validators=[DataRequired()], ) - title = StringField("Title", validators=[DataRequired(), Length(47)]) + title = StringField("Title", validators=[DataRequired(), Length(max=47)]) image = FileField("TV Screen Image", validators=[FileRequired()]) upload = SubmitField("Upload") @@ -150,8 +152,8 @@ class RoomLinkData(FlaskForm): choices=RoomContentBGMTypes.choices(), coerce=RoomContentBGMTypes.coerce, ) - title = StringField("Title", validators=[DataRequired(), Length(47)]) - link = StringField("Link", validators=[DataRequired(), Length(100)]) + title = StringField("Title", validators=[DataRequired(), Length(max=47)]) + link = StringField("Link", validators=[DataRequired(), Length(max=100)]) tv = FileField("TV Screen Image", validators=[FileRequired()]) image1 = FileField("Image After Movie", validators=[FileRequired()]) image2 = FileField("Link Image", validators=[FileRequired()]) @@ -165,7 +167,7 @@ class RoomPicData(FlaskForm): choices=RoomContentBGMTypes.choices(), coerce=RoomContentBGMTypes.coerce, ) - title = StringField("Title", validators=[DataRequired(), Length(47)]) + title = StringField("Title", validators=[DataRequired(), Length(max=47)]) tv = FileField("TV Screen Image", validators=[FileRequired()]) image1 = FileField("Image 1", validators=[FileRequired()]) image2 = FileField("Image 2", validators=[FileRequired()]) @@ -221,7 +223,7 @@ class IntroInfoForm(FlaskForm): "Link Type", choices=LinkTypes.choices(), coerce=LinkTypes.coerce ) link_id = IntegerField("Link ID") - cat_name = StringField("Category Name", validators=[Length(61)]) + cat_name = StringField("Category Name", validators=[Length(max=61)]) asset = FileField("Asset", validators=[FileRequired()]) upload = SubmitField("Create Intro Info!") @@ -237,7 +239,7 @@ class CreditsForm(FlaskForm): class RoomCouponData(FlaskForm): - title = StringField("Title", validators=[DataRequired(), Length(47)]) + title = StringField("Title", validators=[DataRequired(), Length(max=47)]) tv = FileField("TV Screen Image", validators=[FileRequired()]) image_after = FileField("Image After Movie", validators=[FileRequired()]) movie = FileField("Movie", validators=[FileRequired()])