forked from bsi-liberia/liberia-projects
-
Notifications
You must be signed in to change notification settings - Fork 0
/
updateemail.py
executable file
·33 lines (26 loc) · 1.07 KB
/
updateemail.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
from flask_mail import Message
from projectdashboard import app, mail
from projectdashboard.query import activity as qactivity
def send_async_email():
with app.app_context():
created, updated = qactivity.get_updates()
message_body = """Activity in the last 24 hours
%s projects created
%s projects updated""" % (len(created), len(updated))
if len(created):
message_body += "\n\nCreated projects\n - "
message_body += "\n - ".join(list(map(lambda p: "%s (%s, %s)" %
(p.title, p.user.username, p.recipient_country.name),
created)))
if len(updated):
message_body += "\n\nUpdated projects\n - "
message_body += "\n - ".join(list(map(lambda p: "%s (%s, %s)" %
(p.title, p.user.username, p.recipient_country.name),
updated)))
msg = Message(
subject = "MAEDI Base Projets - Update notification",
recipients = app.config["MAIL_RECIPIENTS"],
body = message_body
)
mail.send(msg)
send_async_email()