Commit 4f73389a authored by Adrián Ribao's avatar Adrián Ribao
Browse files

Improved email backend

parent a0779c9e
......@@ -4,10 +4,18 @@ from django.core.mail import EmailMultiAlternatives
from django.template import Context, loader
import html2text
import json
#import pynliner
from premailer import Premailer
#from django.template.loader import get_template
class EmailBackend(NotificationBackendBase):
"""
Requires:
* subject
* template_name
"""
name = 'email'
def __init__(self, subject, template_name, *args, **kwargs):
......@@ -18,10 +26,11 @@ class EmailBackend(NotificationBackendBase):
def render_template_email(self, data):
template = loader.get_template(self.template_name)
json_data = json.loads(data)[0]
#import pdb
#pdb.set_trace()
render = template.render(Context(json_data))
return render
#output = pynliner.fromString(render)
p = Premailer(render)
output = p.transform()
return output
def convert_email_to_text(self, html):
h = html2text.HTML2Text()
......
......@@ -7,7 +7,6 @@ if NOTIFINTIME_GREEN:
else:
import zmq
class ZeroMQBackend(NotificationBackendBase):
name = 'zeromq'
......
......@@ -65,7 +65,6 @@ class NotificationBase(object):
Process the message
"""
message = json.loads(message)
print message
return message
def receive(self, backend_name, *args, **kwargs):
......
......@@ -44,5 +44,9 @@ setup(
classifiers=CLASSIFIERS,
install_requires=[
'pyzmq',
#'pynliner',
#'cssutils',
'premailer',
'cssselect',
],
)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment