Private
Public Access
1
0

Merge tag 'v6.29' into develop

moving to jinja for email templates
This commit is contained in:
Sander Roosendaal
2018-03-19 23:03:21 +01:00
18 changed files with 10 additions and 43 deletions

View File

@@ -26,7 +26,7 @@ from rowsandall_app.settings import SITE_URL
from rowsandall_app.settings_dev import SITE_URL as SITE_URL_DEV from rowsandall_app.settings_dev import SITE_URL as SITE_URL_DEV
from rowsandall_app.settings import PROGRESS_CACHE_SECRET from rowsandall_app.settings import PROGRESS_CACHE_SECRET
from rowsandall_app.settings import SETTINGS_NAME from rowsandall_app.settings import SETTINGS_NAME
os.environ.setdefault('DJANGO_SETTINGS_MODULE', SETTINGS_NAME)
import pandas as pd import pandas as pd
@@ -49,9 +49,11 @@ from django.core.mail import (
send_mail, send_mail,
EmailMessage,EmailMultiAlternatives, EmailMessage,EmailMultiAlternatives,
) )
from django.template.loader import get_template
from django.template import Context from django.template import Context
from django.db.utils import OperationalError from django.db.utils import OperationalError
from jinja2 import Template,Environment,FileSystemLoader
env = Environment(loader = FileSystemLoader(["rowers/templates"]))
import datautils import datautils
import utils import utils
@@ -72,8 +74,8 @@ def textify(html):
def send_template_email(from_email,to_email,subject, def send_template_email(from_email,to_email,subject,
template,context, template,context,
*args,**kwargs): *args,**kwargs):
htmly = get_template(template) htmly = env.get_template(template)
html_content = htmly.render(context) html_content = htmly.render(context)
text_content = textify(html_content) text_content = textify(html_content)
@@ -511,14 +513,13 @@ def handle_sendemail_unrecognizedowner(useremail, userfirstname,
fullemail = useremail fullemail = useremail
subject = "Unrecognized file from Rowsandall.com" subject = "Unrecognized file from Rowsandall.com"
htmly = get_template('unrecognizedemail.html')
d = {'first_name':userfirstname} d = {'first_name':userfirstname}
from_email = 'Rowsandall <info@rowsandall.com>' from_email = 'Rowsandall <info@rowsandall.com>'
res = send_template_email(from_email,[fullemail], res = send_template_email(from_email,[fullemail],
subject,'csvemail.html',d, subject,'unrecognizedemail.html',d,
**kwargs) **kwargs)
return 1 return 1

View File

@@ -1,6 +1,4 @@
{% extends "emailbase.html" %} {% extends "emailbase.html" %}
{% load staticfiles %}
{% load rowerfilters %}
{% block body %} {% block body %}
<p>Dear <strong>{{ first_name }}</strong>,</p> <p>Dear <strong>{{ first_name }}</strong>,</p>
@@ -46,9 +44,9 @@
</tr> </tr>
{% for set in btvalues %} {% for set in btvalues %}
<tr> <tr>
<th>{{ set|lookup:"delta" }}</th> <th>{{ set["delta"] }}</th>
<th>{{ set|lookup:"cpvalue" }}</th> <th>{{ set["cpvalue"] }}</th>
<th>{{ set|lookup:"pwr" }}</th> <th>{{ set["pwr"] }}</th>
</tr> </tr>
{% endfor %} {% endfor %}
</table> </table>

View File

@@ -1,6 +1,4 @@
{% extends "emailbase.html" %} {% extends "emailbase.html" %}
{% load staticfiles %}
{% load rowerfilters %}
{% block body %} {% block body %}
<p>Dear <strong>{{ first_name }}</strong>,</p> <p>Dear <strong>{{ first_name }}</strong>,</p>

View File

@@ -1,8 +1,6 @@
<html> <html>
<body> <body>
<font face="verdana, sans-serif"> <font face="verdana, sans-serif">
{% load staticfiles %}
{% load rowerfilters %}
<img src="https://rowsandall.com/static/img/logoemail.png" height="50"> <img src="https://rowsandall.com/static/img/logoemail.png" height="50">

View File

@@ -1,6 +1,4 @@
{% extends "emailbase.html" %} {% extends "emailbase.html" %}
{% load staticfiles %}
{% load rowerfilters %}
{% block body %} {% block body %}
<p>Dear <strong>{{ first_name }}</strong>,</p> <p>Dear <strong>{{ first_name }}</strong>,</p>

View File

@@ -1,6 +1,4 @@
{% extends "emailbase.html" %} {% extends "emailbase.html" %}
{% load staticfiles %}
{% load rowerfilters %}
{% block body %} {% block body %}
<p>Dear <strong>{{ first_name }}</strong>,</p> <p>Dear <strong>{{ first_name }}</strong>,</p>

View File

@@ -1,6 +1,4 @@
{% extends "emailbase.html" %} {% extends "emailbase.html" %}
{% load staticfiles %}
{% load rowerfilters %}
{% block body %} {% block body %}
<p>Dear <strong>{{ first_name }}</strong>,</p> <p>Dear <strong>{{ first_name }}</strong>,</p>

View File

@@ -1,6 +1,4 @@
{% extends "emailbase.html" %} {% extends "emailbase.html" %}
{% load staticfiles %}
{% load rowerfilters %}
{% block body %} {% block body %}
<p>Dear <strong>{{ first_name }}</strong>,</p> <p>Dear <strong>{{ first_name }}</strong>,</p>

View File

@@ -1,6 +1,4 @@
{% extends "emailbase.html" %} {% extends "emailbase.html" %}
{% load staticfiles %}
{% load rowerfilters %}
{% block body %} {% block body %}
<p>Dear <strong>{{ first_name }}</strong>,</p> <p>Dear <strong>{{ first_name }}</strong>,</p>

View File

@@ -1,6 +1,4 @@
{% extends "emailbase.html" %} {% extends "emailbase.html" %}
{% load staticfiles %}
{% load rowerfilters %}
{% block body %} {% block body %}
<p>Dear <strong>{{ managername }}</strong>,</p> <p>Dear <strong>{{ managername }}</strong>,</p>

View File

@@ -1,6 +1,4 @@
{% extends "emailbase.html" %} {% extends "emailbase.html" %}
{% load staticfiles %}
{% load rowerfilters %}
{% block body %} {% block body %}
<p>Dear <strong>{{ name }}</strong>,</p> <p>Dear <strong>{{ name }}</strong>,</p>

View File

@@ -1,6 +1,4 @@
{% extends "emailbase.html" %} {% extends "emailbase.html" %}
{% load staticfiles %}
{% load rowerfilters %}
{% block body %} {% block body %}
<p>Dear <strong>{{ managername }}</strong>,</p> <p>Dear <strong>{{ managername }}</strong>,</p>

View File

@@ -1,6 +1,4 @@
{% extends "emailbase.html" %} {% extends "emailbase.html" %}
{% load staticfiles %}
{% load rowerfilters %}
{% block body %} {% block body %}
<p>Dear <strong>{{ first_name }}</strong>,</p> <p>Dear <strong>{{ first_name }}</strong>,</p>

View File

@@ -1,6 +1,4 @@
{% extends "emailbase.html" %} {% extends "emailbase.html" %}
{% load staticfiles %}
{% load rowerfilters %}
{% block body %} {% block body %}
<p>Dear <strong>{{ first_name }}</strong>,</p> <p>Dear <strong>{{ first_name }}</strong>,</p>

View File

@@ -1,6 +1,4 @@
{% extends "emailbase.html" %} {% extends "emailbase.html" %}
{% load staticfiles %}
{% load rowerfilters %}
{% block body %} {% block body %}
<p>Dear <strong>{{ first_name }}</strong>,</p> <p>Dear <strong>{{ first_name }}</strong>,</p>

View File

@@ -1,6 +1,4 @@
{% extends "emailbase.html" %} {% extends "emailbase.html" %}
{% load staticfiles %}
{% load rowerfilters %}
{% block body %} {% block body %}
<p>Dear <strong>{{ name }}</strong>,</p> <p>Dear <strong>{{ name }}</strong>,</p>

View File

@@ -1,6 +1,4 @@
{% extends "emailbase.html" %} {% extends "emailbase.html" %}
{% load staticfiles %}
{% load rowerfilters %}
{% block body %} {% block body %}
<p>Dear <strong>{{ first_name }}</strong>,</p> <p>Dear <strong>{{ first_name }}</strong>,</p>

View File

@@ -1,6 +1,4 @@
{% extends "emailbase.html" %} {% extends "emailbase.html" %}
{% load staticfiles %}
{% load rowerfilters %}
{% block body %} {% block body %}
<p>Dear <strong>{{ first_name }}</strong>,</p> <p>Dear <strong>{{ first_name }}</strong>,</p>