mirror of
https://github.com/lucaspalomodevelop/eventcally.git
synced 2026-03-13 00:07:22 +00:00
Add Max-Length validator to form fields #469
This commit is contained in:
parent
11beeeb30a
commit
416e71399f
@ -11,10 +11,16 @@ from project.models import AdminUnitRelation, Image, Location
|
||||
|
||||
|
||||
class AdminUnitLocationForm(FlaskForm):
|
||||
street = StringField(lazy_gettext("Street"), validators=[Optional()])
|
||||
postalCode = StringField(lazy_gettext("Postal code"), validators=[DataRequired()])
|
||||
city = StringField(lazy_gettext("City"), validators=[DataRequired()])
|
||||
state = StringField(lazy_gettext("State"), validators=[Optional()])
|
||||
street = StringField(
|
||||
lazy_gettext("Street"), validators=[Optional(), Length(max=255)]
|
||||
)
|
||||
postalCode = StringField(
|
||||
lazy_gettext("Postal code"), validators=[DataRequired(), Length(max=255)]
|
||||
)
|
||||
city = StringField(
|
||||
lazy_gettext("City"), validators=[DataRequired(), Length(max=255)]
|
||||
)
|
||||
state = StringField(lazy_gettext("State"), validators=[Optional(), Length(max=255)])
|
||||
latitude = DecimalField(
|
||||
lazy_gettext("Latitude"), places=16, validators=[Optional()]
|
||||
)
|
||||
@ -43,10 +49,10 @@ class BaseAdminUnitForm(FlaskForm):
|
||||
),
|
||||
],
|
||||
)
|
||||
url = URLField(lazy_gettext("Link URL"), validators=[Optional()])
|
||||
email = EmailField(lazy_gettext("Email"), validators=[Optional()])
|
||||
phone = TelField(lazy_gettext("Phone"), validators=[Optional()])
|
||||
fax = TelField(lazy_gettext("Fax"), validators=[Optional()])
|
||||
url = URLField(lazy_gettext("Link URL"), validators=[Optional(), Length(max=255)])
|
||||
email = EmailField(lazy_gettext("Email"), validators=[Optional(), Length(max=255)])
|
||||
phone = TelField(lazy_gettext("Phone"), validators=[Optional(), Length(max=255)])
|
||||
fax = TelField(lazy_gettext("Fax"), validators=[Optional(), Length(max=255)])
|
||||
logo = FormField(Base64ImageForm, lazy_gettext("Logo"), default=lambda: Image())
|
||||
location = FormField(AdminUnitLocationForm, default=lambda: Location())
|
||||
|
||||
@ -107,7 +113,9 @@ class UpdateAdminUnitForm(BaseAdminUnitForm):
|
||||
|
||||
|
||||
class UpdateAdminUnitWidgetForm(FlaskForm):
|
||||
widget_font = StringField(lazy_gettext("Font"), validators=[Optional()])
|
||||
widget_font = StringField(
|
||||
lazy_gettext("Font"), validators=[Optional(), Length(max=255)]
|
||||
)
|
||||
widget_background_color = StringField(
|
||||
lazy_gettext("Background Color"),
|
||||
default="#ffffff",
|
||||
|
||||
@ -2,13 +2,15 @@ from flask_babel import lazy_gettext
|
||||
from flask_wtf import FlaskForm
|
||||
from wtforms import SubmitField
|
||||
from wtforms.fields import EmailField
|
||||
from wtforms.validators import DataRequired
|
||||
from wtforms.validators import DataRequired, Length
|
||||
|
||||
from project.forms.widgets import MultiCheckboxField
|
||||
|
||||
|
||||
class InviteAdminUnitMemberForm(FlaskForm):
|
||||
email = EmailField(lazy_gettext("Email"), validators=[DataRequired()])
|
||||
email = EmailField(
|
||||
lazy_gettext("Email"), validators=[DataRequired(), Length(max=255)]
|
||||
)
|
||||
roles = MultiCheckboxField(lazy_gettext("Roles"))
|
||||
submit = SubmitField(lazy_gettext("Invite"))
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@ from flask_babel import lazy_gettext
|
||||
from flask_wtf import FlaskForm
|
||||
from markupsafe import Markup
|
||||
from wtforms import HiddenField, StringField
|
||||
from wtforms.validators import Optional
|
||||
from wtforms.validators import Length, Optional
|
||||
|
||||
from project.imageutils import (
|
||||
get_bytes_from_image,
|
||||
@ -17,7 +17,7 @@ from project.imageutils import (
|
||||
|
||||
class BaseImageForm(FlaskForm):
|
||||
copyright_text = StringField(
|
||||
lazy_gettext("Copyright text"), validators=[Optional()]
|
||||
lazy_gettext("Copyright text"), validators=[Optional(), Length(max=255)]
|
||||
)
|
||||
|
||||
|
||||
|
||||
@ -101,12 +101,12 @@ class OrganizerForm(EventPlaceForm):
|
||||
class EventOrganizerForm(FlaskForm):
|
||||
name = StringField(
|
||||
lazy_gettext("Organizator"),
|
||||
validators=[Optional()],
|
||||
validators=[Optional(), Length(max=255)],
|
||||
)
|
||||
url = URLField(lazy_gettext("Link URL"), validators=[Optional()])
|
||||
email = EmailField(lazy_gettext("Email"), validators=[Optional()])
|
||||
phone = StringField(lazy_gettext("Phone"), validators=[Optional()])
|
||||
fax = StringField(lazy_gettext("Fax"), validators=[Optional()])
|
||||
url = URLField(lazy_gettext("Link URL"), validators=[Optional(), Length(max=255)])
|
||||
email = EmailField(lazy_gettext("Email"), validators=[Optional(), Length(max=255)])
|
||||
phone = StringField(lazy_gettext("Phone"), validators=[Optional(), Length(max=255)])
|
||||
fax = StringField(lazy_gettext("Fax"), validators=[Optional(), Length(max=255)])
|
||||
|
||||
|
||||
class SharedEventForm(FlaskForm):
|
||||
@ -122,14 +122,14 @@ class SharedEventForm(FlaskForm):
|
||||
)
|
||||
external_link = URLField(
|
||||
lazy_gettext("Link URL"),
|
||||
validators=[Optional()],
|
||||
validators=[Optional(), Length(max=255)],
|
||||
description=lazy_gettext(
|
||||
"Enter a link to an external website containing more information about the event."
|
||||
),
|
||||
)
|
||||
ticket_link = URLField(
|
||||
lazy_gettext("Ticket Link URL"),
|
||||
validators=[Optional()],
|
||||
validators=[Optional(), Length(max=255)],
|
||||
description=lazy_gettext("Enter a link where tickets can be purchased."),
|
||||
)
|
||||
tags = StringField(
|
||||
|
||||
@ -2,17 +2,21 @@ from flask_babel import lazy_gettext
|
||||
from flask_wtf import FlaskForm
|
||||
from wtforms import DecimalField, FormField, StringField, SubmitField, TextAreaField
|
||||
from wtforms.fields import URLField
|
||||
from wtforms.validators import DataRequired, Optional
|
||||
from wtforms.validators import DataRequired, Length, Optional
|
||||
|
||||
from project.forms.common import Base64ImageForm
|
||||
from project.models import Image, Location
|
||||
|
||||
|
||||
class EventPlaceLocationForm(FlaskForm):
|
||||
street = StringField(lazy_gettext("Street"), validators=[Optional()])
|
||||
postalCode = StringField(lazy_gettext("Postal code"), validators=[Optional()])
|
||||
city = StringField(lazy_gettext("City"), validators=[Optional()])
|
||||
state = StringField(lazy_gettext("State"), validators=[Optional()])
|
||||
street = StringField(
|
||||
lazy_gettext("Street"), validators=[Optional(), Length(max=255)]
|
||||
)
|
||||
postalCode = StringField(
|
||||
lazy_gettext("Postal code"), validators=[Optional(), Length(max=255)]
|
||||
)
|
||||
city = StringField(lazy_gettext("City"), validators=[Optional(), Length(max=255)])
|
||||
state = StringField(lazy_gettext("State"), validators=[Optional(), Length(max=255)])
|
||||
latitude = DecimalField(
|
||||
lazy_gettext("Latitude"), places=16, validators=[Optional()]
|
||||
)
|
||||
@ -22,8 +26,10 @@ class EventPlaceLocationForm(FlaskForm):
|
||||
|
||||
|
||||
class BaseEventPlaceForm(FlaskForm):
|
||||
name = StringField(lazy_gettext("Name"), validators=[DataRequired()])
|
||||
url = URLField(lazy_gettext("Link URL"), validators=[Optional()])
|
||||
name = StringField(
|
||||
lazy_gettext("Name"), validators=[DataRequired(), Length(max=255)]
|
||||
)
|
||||
url = URLField(lazy_gettext("Link URL"), validators=[Optional(), Length(max=255)])
|
||||
photo = FormField(Base64ImageForm, lazy_gettext("Photo"), default=lambda: Image())
|
||||
description = TextAreaField(lazy_gettext("Description"), validators=[Optional()])
|
||||
location = FormField(EventPlaceLocationForm)
|
||||
|
||||
@ -8,7 +8,7 @@ from wtforms import (
|
||||
SubmitField,
|
||||
)
|
||||
from wtforms.fields import EmailField, TelField
|
||||
from wtforms.validators import DataRequired, Optional
|
||||
from wtforms.validators import DataRequired, Length, Optional
|
||||
|
||||
from project.forms.common import get_accept_tos_markup
|
||||
from project.forms.event import EventDateDefinitionFormMixin, SharedEventForm
|
||||
@ -24,19 +24,19 @@ from project.models import (
|
||||
class CreateEventSuggestionForm(SharedEventForm, EventDateDefinitionFormMixin):
|
||||
contact_name = StringField(
|
||||
lazy_gettext("Name"),
|
||||
validators=[DataRequired()],
|
||||
validators=[DataRequired(), Length(max=255)],
|
||||
description=lazy_gettext("Please enter your name for the review."),
|
||||
)
|
||||
contact_phone = TelField(
|
||||
lazy_gettext("Phone"),
|
||||
validators=[Optional()],
|
||||
validators=[Optional(), Length(max=255)],
|
||||
description=lazy_gettext(
|
||||
"Please enter your phone number or email address for the review."
|
||||
),
|
||||
)
|
||||
contact_email = EmailField(
|
||||
lazy_gettext("Email"),
|
||||
validators=[Optional()],
|
||||
validators=[Optional(), Length(max=255)],
|
||||
description=lazy_gettext(
|
||||
"Please enter your email address or phone number for the review."
|
||||
),
|
||||
|
||||
@ -2,17 +2,21 @@ from flask_babel import lazy_gettext
|
||||
from flask_wtf import FlaskForm
|
||||
from wtforms import DecimalField, FormField, StringField, SubmitField
|
||||
from wtforms.fields import EmailField, TelField, URLField
|
||||
from wtforms.validators import DataRequired, Optional
|
||||
from wtforms.validators import DataRequired, Length, Optional
|
||||
|
||||
from project.forms.common import Base64ImageForm
|
||||
from project.models import Image, Location
|
||||
|
||||
|
||||
class OrganizerLocationForm(FlaskForm):
|
||||
street = StringField(lazy_gettext("Street"), validators=[Optional()])
|
||||
postalCode = StringField(lazy_gettext("Postal code"), validators=[Optional()])
|
||||
city = StringField(lazy_gettext("City"), validators=[Optional()])
|
||||
state = StringField(lazy_gettext("State"), validators=[Optional()])
|
||||
street = StringField(
|
||||
lazy_gettext("Street"), validators=[Optional(), Length(max=255)]
|
||||
)
|
||||
postalCode = StringField(
|
||||
lazy_gettext("Postal code"), validators=[Optional(), Length(max=255)]
|
||||
)
|
||||
city = StringField(lazy_gettext("City"), validators=[Optional(), Length(max=255)])
|
||||
state = StringField(lazy_gettext("State"), validators=[Optional(), Length(max=255)])
|
||||
latitude = DecimalField(
|
||||
lazy_gettext("Latitude"), places=16, validators=[Optional()]
|
||||
)
|
||||
@ -22,10 +26,12 @@ class OrganizerLocationForm(FlaskForm):
|
||||
|
||||
|
||||
class BaseOrganizerForm(FlaskForm):
|
||||
name = StringField(lazy_gettext("Name"), validators=[DataRequired()])
|
||||
url = URLField(lazy_gettext("Link URL"), validators=[Optional()])
|
||||
email = EmailField(lazy_gettext("Email"), validators=[Optional()])
|
||||
phone = TelField(lazy_gettext("Phone"), validators=[Optional()])
|
||||
name = StringField(
|
||||
lazy_gettext("Name"), validators=[DataRequired(), Length(max=255)]
|
||||
)
|
||||
url = URLField(lazy_gettext("Link URL"), validators=[Optional(), Length(max=255)])
|
||||
email = EmailField(lazy_gettext("Email"), validators=[Optional(), Length(max=255)])
|
||||
phone = TelField(lazy_gettext("Phone"), validators=[Optional(), Length(max=255)])
|
||||
fax = TelField(lazy_gettext("Fax"), validators=[Optional()])
|
||||
logo = FormField(Base64ImageForm, lazy_gettext("Logo"), default=lambda: Image())
|
||||
location = FormField(OrganizerLocationForm)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user