aboutsummaryrefslogtreecommitdiff
path: root/app/misc_func.py
diff options
context:
space:
mode:
authorNavan Chauhan <navanchauhan@gmail.com>2021-06-06 15:44:45 +0530
committerGitHub <noreply@github.com>2021-06-06 15:44:45 +0530
commit62a5ca363415b0f6f98785b6c3522a71fc895a72 (patch)
tree6fb829110658369321bab897707132f76f9b1b2c /app/misc_func.py
parent57207efe38174666d40964b74856537c6f5314ab (diff)
parent6595d53212eaa4b9319da7196f5e2286d30eb462 (diff)
Merge pull request #1 from navanchauhan/deepsource-transform-10f49d7d
Format code with black
Diffstat (limited to 'app/misc_func.py')
-rw-r--r--app/misc_func.py32
1 files changed, 18 insertions, 14 deletions
diff --git a/app/misc_func.py b/app/misc_func.py
index 73e920d..d560337 100644
--- a/app/misc_func.py
+++ b/app/misc_func.py
@@ -3,25 +3,29 @@ 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()
- print("Mail Sent") \ No newline at end of file
+ print("Mail Sent")