29 lines
951 B
Python
29 lines
951 B
Python
from flask_wtf import FlaskForm
|
|
from wtforms import StringField, IntegerField, TextAreaField, BooleanField, SubmitField
|
|
from wtforms.validators import DataRequired, Length, NumberRange, Optional
|
|
from flask_babel import lazy_gettext as _l
|
|
|
|
class BuildingForm(FlaskForm):
|
|
name = StringField(_l('Building Name'), validators=[
|
|
DataRequired(),
|
|
Length(min=2, max=100)
|
|
])
|
|
code = StringField(_l('Code'), validators=[
|
|
Optional(),
|
|
Length(max=50)
|
|
])
|
|
address = StringField(_l('Address'), validators=[
|
|
Optional(),
|
|
Length(max=255)
|
|
])
|
|
floors = IntegerField(_l('Number of Floors'), default=1, validators=[
|
|
DataRequired(),
|
|
NumberRange(min=1, max=100)
|
|
])
|
|
description = TextAreaField(_l('Description'), validators=[
|
|
Optional(),
|
|
Length(max=500)
|
|
])
|
|
is_active = BooleanField(_l('Active'), default=True)
|
|
submit = SubmitField(_l('Save Building'))
|