|
|
@ -2,9 +2,9 @@ |
|
|
|
'''Helper utilities and decorators.''' |
|
|
|
'''Helper utilities and decorators.''' |
|
|
|
from flask import flash |
|
|
|
from flask import flash |
|
|
|
|
|
|
|
|
|
|
|
def flash_errors(form): |
|
|
|
def flash_errors(form, category="warning"): |
|
|
|
'''Flash all errors for a form.''' |
|
|
|
'''Flash all errors for a form.''' |
|
|
|
for field, errors in form.errors.items(): |
|
|
|
for field, errors in form.errors.items(): |
|
|
|
for error in errors: |
|
|
|
for error in errors: |
|
|
|
flash("Error in {0} field - {1}" |
|
|
|
flash("{0} - {1}" |
|
|
|
.format(getattr(form, field).label.text, error), 'warning') |
|
|
|
.format(getattr(form, field).label.text, error), category) |
|
|
|