Skip to content

Commit

Permalink
html may be modified by subscriber as well
Browse files Browse the repository at this point in the history
  • Loading branch information
jensens authored and agitator committed Nov 12, 2015
1 parent 5a3cb59 commit bbfa361
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
4 changes: 1 addition & 3 deletions Products/EasyNewsletter/interfaces.py
Expand Up @@ -102,6 +102,4 @@ def preview_html():

class IBeforePersonalizationEvent(Interface):

html = Attribute('html to be personalized')

data = Attribute('receiver specific data')
data = Attribute('issue specific data')
27 changes: 14 additions & 13 deletions Products/EasyNewsletter/issuedatafetcher.py
Expand Up @@ -29,8 +29,7 @@
@implementer(IBeforePersonalizationEvent)
class BeforePersonalizationEvent(object):

def __init__(self, html, data):
self.html = html
def __init__(self, data):
self.data = data


Expand Down Expand Up @@ -161,18 +160,20 @@ def _render_output_html(self):
return output_html

def _personalize(self, receiver, html):
tpl_context = {}
tpl_context['receiver'] = receiver
tpl_context['fullname'] = self._fullname(receiver)
tpl_context['salutation'] = self._salutation(receiver)
tpl_context['unsubscribe'] = self._unsubscribe_info(receiver)
tpl_context['UNSUBSCRIBE'] = tpl_context['unsubscribe']['html']
tpl_context['SUBSCRIBER_SALUTATION'] = self._subscriber_salutation(
data = {}
data['html'] = html
data['context'] = {}
data['context']['receiver'] = receiver
data['context']['fullname'] = self._fullname(receiver)
data['context']['salutation'] = self._salutation(receiver)
data['context']['unsubscribe'] = self._unsubscribe_info(receiver)
data['context']['UNSUBSCRIBE'] = data['context']['unsubscribe']['html']
data['context']['SUBSCRIBER_SALUTATION'] = self._subscriber_salutation(
receiver
)
notify(BeforePersonalizationEvent(html, tpl_context))
template = jinja2.Template(html.decode('utf8'))
return template.render(**tpl_context)
notify(BeforePersonalizationEvent(data))
template = jinja2.Template(data['html'].decode('utf8'))
return template.render(**data['context'])

def _personalize_texts(self, receiver, text, text_plain):
# DEPRECATED
Expand Down Expand Up @@ -289,7 +290,7 @@ def _create_plaintext_message(self, text):
# to keep the message readable.
anchorlist = "\n\n" + ("-" * plain_text_maxcols) + "\n\n"
for counter, item in enumerate(parser.anchorlist):
anchorlist += "[%d] %s\n" % (counter, item)
anchorlist += "[{0:d}] {1:s}\n".format(counter, item)

text = textout.getvalue() + anchorlist
del textout, formtext, parser, anchorlist
Expand Down
1 change: 1 addition & 0 deletions base.cfg
Expand Up @@ -40,6 +40,7 @@ recipe = zc.recipe.testrunner
eggs =
Products.EasyNewsletter[test]
ipdb

defaults = ['-s', 'Products.EasyNewsletter', '--auto-color', '--auto-progress']


Expand Down

0 comments on commit bbfa361

Please sign in to comment.