diff options
Diffstat (limited to '')
-rw-r--r-- | kosten/app/forms.py | 4 | ||||
-rw-r--r-- | kosten/app/views/consts.py | 3 | ||||
-rw-r--r-- | kosten/app/views/expenses.py | 3 | ||||
-rw-r--r-- | kosten/app/views/user.py | 2 |
4 files changed, 9 insertions, 3 deletions
diff --git a/kosten/app/forms.py b/kosten/app/forms.py index 9bab284..818384d 100644 --- a/kosten/app/forms.py +++ b/kosten/app/forms.py @@ -31,6 +31,10 @@ class MonthField(HTML4DateField): req = [validators.input_required()] +def lenOf(col): + if hasattr(col.type, 'length') and col.type.length: + return [validators.length(max = col.type.length)] + class Form(FlaskForm): class Meta: locales = False diff --git a/kosten/app/views/consts.py b/kosten/app/views/consts.py index 5d6598d..3ac5175 100644 --- a/kosten/app/views/consts.py +++ b/kosten/app/views/consts.py @@ -39,7 +39,8 @@ class ConstForm(F.Form): description='EUR', places=2) - description = F.StringField('Beschreibung', F.req) + description = F.StringField('Beschreibung', + F.req + F.lenOf(ConstExpense.description)) category = F.QuerySelectField('Kategorie', get_label='name', diff --git a/kosten/app/views/expenses.py b/kosten/app/views/expenses.py index 0473cda..a7adfdb 100644 --- a/kosten/app/views/expenses.py +++ b/kosten/app/views/expenses.py @@ -26,7 +26,8 @@ class ExpenseForm(F.Form): description='EUR', places=2) - description = F.StringField('Beschreibung', F.req) + description = F.StringField('Beschreibung', + F.req + F.lenOf(SingleExpense.description)) category = F.QuerySelectField('Kategorie', get_label='name', diff --git a/kosten/app/views/user.py b/kosten/app/views/user.py index 9b75af8..0829fb9 100644 --- a/kosten/app/views/user.py +++ b/kosten/app/views/user.py @@ -14,7 +14,7 @@ mod = Blueprint('user', __name__) # Forms # class LoginForm(F.Form): - username = F.StringField('Username', F.req) + username = F.StringField('Username', F.req + F.lenOf(User.name)) pwd = F.PasswordField('Passwort', F.req) remember = F.BooleanField('Eingeloggt bleiben?') |