aboutsummaryrefslogtreecommitdiff
path: root/app/misc_func.py
diff options
context:
space:
mode:
authorNavan Chauhan <navanchauhan@gmail.com>2021-06-06 15:49:56 +0530
committerNavan Chauhan <navanchauhan@gmail.com>2021-06-06 15:49:56 +0530
commit812220acbfd41aea0382fcd9a37a989a4b091d66 (patch)
tree0f4277216efe81e6b8d21d9dfc39a3d343fac48e /app/misc_func.py
parentad92a42e8439337cfde346fa84e75a5f91164eac (diff)
parent62a5ca363415b0f6f98785b6c3522a71fc895a72 (diff)
fixing pull
Diffstat (limited to 'app/misc_func.py')
-rw-r--r--app/misc_func.py30
1 files changed, 17 insertions, 13 deletions
diff --git a/app/misc_func.py b/app/misc_func.py
index 5c410f4..c8bb77b 100644
--- a/app/misc_func.py
+++ b/app/misc_func.py
@@ -3,24 +3,28 @@ from flask import flash
from flask_mailman import EmailMultiAlternatives
from app import app, mail
+
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')
-
-# Sauce: https://github.com/alectrocute/flaskSaaS/blob/master/app/toolbox/email.py
-
-def send(to, subject, body, body_html,thread=True):
- sender = app.config["MAIL_FROM"]
- message = EmailMultiAlternatives(
- subject,body,sender,[to])
- message.attach_alternative(body_html,"text/html")
- thr = Thread(target=send_async, args=[app,message])
+ flash(
+ u"Error in the %s field - %s"
+ % (getattr(form, field).label.text, error),
+ "danger",
+ )
+
+
+# Sauce: https://github.com/alectrocute/flaskSaaS/blob/master/app/toolbox/email.py
+
+
+def send(to, subject, body, body_html, thread=True):
+ sender = app.config["MAIL_FROM"]
+ message = EmailMultiAlternatives(subject, body, sender, [to])
+ message.attach_alternative(body_html, "text/html")
+ thr = Thread(target=send_async, args=[app, message])
thr.start()
+
def send_async(app, message):
with app.app_context():
message.send() \ No newline at end of file