From fabe428118caa943eb062e8331400d7b6b1d4018 Mon Sep 17 00:00:00 2001 From: Spotlight Date: Thu, 17 Dec 2020 16:45:40 -0600 Subject: [PATCH] Add max title length --- forms.py | 4 ++-- models.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/forms.py b/forms.py index d0930cd9..5e55d750 100644 --- a/forms.py +++ b/forms.py @@ -1,7 +1,7 @@ from flask_wtf import FlaskForm from flask_wtf.file import FileRequired from wtforms import StringField, SubmitField, PasswordField, FileField, SelectField -from wtforms.validators import DataRequired +from wtforms.validators import DataRequired, Length class LoginForm(FlaskForm): @@ -17,7 +17,7 @@ class MiiUploadForm(FlaskForm): class MovieUploadForm(FlaskForm): movie = FileField("Movie", validators=[FileRequired()]) - title = StringField("Movie title", validators=[DataRequired()]) + title = StringField("Movie title", validators=[DataRequired(), Length(max=48)]) thumbnail = FileField("Movie thumbnail", validators=[FileRequired()]) # Choices for the select field are only evaluated once, so we must set it when necessary. category = SelectField("Movie category", validators=[DataRequired()]) diff --git a/models.py b/models.py index dd67591d..9dab083f 100644 --- a/models.py +++ b/models.py @@ -89,7 +89,7 @@ class MiiMsgInfo(db.Model): class Movies(db.Model): movie_id = db.Column(db.Integer, primary_key=True, unique=True) - title = db.Column(db.String, nullable=False) + title = db.Column(db.String(48), nullable=False) length = db.Column(db.String(8), nullable=False) aspect = db.Column(db.Boolean, nullable=False) genre = db.Column(db.Integer, nullable=False)