-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
some more cleanup around CMS story template rendering to make sure cr…
…edit is handled correctly and consistently for NHC as well as NWS. TODO: cleanup email template rendering, see #4
- Loading branch information
1 parent
bc8dfea
commit a41a040
Showing
4 changed files
with
39 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ | |
from smtplib import SMTP | ||
from email.message import EmailMessage | ||
import time | ||
from jinja2 import Environment, FileSystemLoader, select_autoescape | ||
|
||
import logging | ||
logger = logging.getLogger('util') | ||
|
@@ -17,6 +18,18 @@ | |
SMTP_PASSWORD = os.environ['SMTP_PASSWORD'] | ||
SENDER_EMAIL = 'Weatherbot <[email protected]>' | ||
|
||
JINJA_ENVIRONMENT = Environment( | ||
loader=FileSystemLoader('templates'), | ||
autoescape=select_autoescape() | ||
) | ||
|
||
|
||
def render_template(path, **kwargs): | ||
"""Given a relative template path and any context for rendering the template, | ||
do it all here, in one place. """ | ||
template = JINJA_ENVIRONMENT.get_template(path) | ||
return template.render(**kwargs) | ||
|
||
def send_email(recipients, subject, body , url=None, actually_send_email=False): | ||
if recipients is not None: | ||
msg = EmailMessage() | ||
|