diff options
author | Navan Chauhan <navanchauhan@gmail.com> | 2021-06-03 23:46:25 +0530 |
---|---|---|
committer | Navan Chauhan <navanchauhan@gmail.com> | 2021-06-03 23:46:25 +0530 |
commit | 0c4f67c51846815fbd080ded7de740f57fcde506 (patch) | |
tree | 1edb22fffdfba7222798c76d2a004c364396c390 | |
parent | 53ae62ef3f206907f89aa3088b83b638b59e6de5 (diff) |
moved flash form function
-rw-r--r-- | app/misc_func.py | 9 | ||||
-rw-r--r-- | app/views/main.py | 13 |
2 files changed, 12 insertions, 10 deletions
diff --git a/app/misc_func.py b/app/misc_func.py new file mode 100644 index 0000000..11e2bb2 --- /dev/null +++ b/app/misc_func.py @@ -0,0 +1,9 @@ +from flask import flash + +def flash_errors(form): + for field, errors in form.errors.items(): + for error in errors: + flash(u"Error in the %s field - %s" % ( + getattr(form, field).label.text, + error + ), 'danger')
\ No newline at end of file diff --git a/app/views/main.py b/app/views/main.py index 15f7db9..2460d39 100644 --- a/app/views/main.py +++ b/app/views/main.py @@ -1,7 +1,8 @@ from app import app from app.forms.app_forms import MyForm from flask import render_template, flash - +from app.views import auth +from app.misc_func import flash_errors theme = "original" @app.route("/") @@ -15,12 +16,4 @@ def contact_us(): if form.validate_on_submit(): return "Wuhu" flash_errors(form) - return render_template("contact.html",form=form) - -def flash_errors(form): - for field, errors in form.errors.items(): - for error in errors: - flash(u"Error in the %s field - %s" % ( - getattr(form, field).label.text, - error - ), 'danger')
\ No newline at end of file + return render_template("contact.html",form=form)
\ No newline at end of file |