From: Andrea C. <svn...@pl...> - 2012-05-29 11:59:01
|
Author: micecchi Date: Tue May 29 11:58:52 2012 New Revision: 250053 Modified: collective.dancingcustomconfirm/trunk/README.txt collective.dancingcustomconfirm/trunk/collective/dancingcustomconfirm/configure.zcml collective.dancingcustomconfirm/trunk/collective/dancingcustomconfirm/monkey.py Log: added forgot template Modified: collective.dancingcustomconfirm/trunk/README.txt ============================================================================== --- collective.dancingcustomconfirm/trunk/README.txt (original) +++ collective.dancingcustomconfirm/trunk/README.txt Tue May 29 11:58:52 2012 @@ -1,9 +1,12 @@ Introduction ============ -A customization for *Singing&Dancing* that allows to easily customize subscription confirm email. +A customization for *Singing&Dancing* that allows to easily customize subscription confirm and forgot email. If there is a registered view with the id "*confirm_newsletter_subscription*", this is used as mail template, otherwise is used S&D default template. +If there is a registered view with the id "*forgot_newsletter_subscription*", this is used as mail template, otherwise is used S&D default template. + + Dependencies ============ Modified: collective.dancingcustomconfirm/trunk/collective/dancingcustomconfirm/configure.zcml ============================================================================== --- collective.dancingcustomconfirm/trunk/collective/dancingcustomconfirm/configure.zcml (original) +++ collective.dancingcustomconfirm/trunk/collective/dancingcustomconfirm/configure.zcml Tue May 29 11:58:52 2012 @@ -11,18 +11,25 @@ <genericsetup:registerProfile name="default" - title="SeD: Custom confirm email" + title="Singing and Dancing: Custom confirm email" directory="profiles/default" description="Install profile SeD: Custom confirm email" provides="Products.GenericSetup.interfaces.EXTENSION" /> - <!-- monkey patch to fix HTMLComposer --> + <!-- monkey patch to fix subscription HTMLComposer --> <monkey:patch description="patch to fix the default confirm mail template" class="collective.dancing.composer.HTMLComposer" original="render_confirmation" replacement=".monkey.render_confirmation" /> - + + <!-- monkey patch to fix forgot HTMLComposer --> + <monkey:patch + description="patch to fix the default forgot mail template" + class="collective.dancing.composer.HTMLComposer" + original="render_forgot_secret" + replacement=".monkey.render_forgot_secret" + /> </configure> Modified: collective.dancingcustomconfirm/trunk/collective/dancingcustomconfirm/monkey.py ============================================================================== --- collective.dancingcustomconfirm/trunk/collective/dancingcustomconfirm/monkey.py (original) +++ collective.dancingcustomconfirm/trunk/collective/dancingcustomconfirm/monkey.py Tue May 29 11:58:52 2012 @@ -7,6 +7,7 @@ from collective.singing.mail import create_html_mail from collective.singing.message import Message + def render_confirmation(self, subscription): """ Custom render_confirmation method. @@ -21,10 +22,10 @@ _(u"Confirm your subscription with ${channel-title}", mapping={'channel-title': subscription.channel.title}), target_language=self.language) - to_addr=subscription_vars[template_var('to_addr')] - vars['to_addr']=to_addr - portal=getSite() - confirm_template=portal.restrictedTraverse('confirm_newsletter_subscription', + to_addr = subscription_vars[template_var('to_addr')] + vars['to_addr'] = to_addr + portal = getSite() + confirm_template = portal.restrictedTraverse('confirm_newsletter_subscription', self.confirm_template) html = confirm_template(**vars) html = utils.compactify(html) @@ -40,4 +41,37 @@ # status=None prevents message from ending up in any queue return Message( - message, subscription, status=None) \ No newline at end of file + message, subscription, status=None) + + +def render_forgot_secret(self, subscription): + """ + Custom render_forgot method. + If there is a registered template with id "forgot_newsletter_subscription" use it. + If there isn't, use the default template. + """ + vars = self._vars(subscription) + subscription_vars = self._subscription_vars(subscription) + portal = getSite() + if 'forgot_secret_subject' not in vars: + vars['forgot_secret_subject'] = translate( + _(u"Change your subscriptions with ${site_title}", + mapping={'site_title': vars['channel_title']}), + target_language=self.language) + forgot_template = portal.restrictedTraverse('forgot_newsletter_subscription', + self.forgot_template) + html = forgot_template(**vars) + html = utils.compactify(html) + html = string.Template(html).safe_substitute(subscription_vars) + + message = create_html_mail( + vars['forgot_secret_subject'], + html, + from_addr=vars['from_addr'], + to_addr=subscription_vars[template_var('to_addr')], + headers=vars.get('more_headers'), + encoding=self.encoding) + + # status=None prevents message from ending up in any queue + return Message( + message, subscription, status=None) |