Skip to content

Commit

Permalink
refactor mailnotification templates to make them overrideable with Br…
Browse files Browse the repository at this point in the history
…owserViews or jbot
  • Loading branch information
petschki committed Apr 25, 2024
1 parent 76e5f0f commit 6f32114
Show file tree
Hide file tree
Showing 10 changed files with 344 additions and 344 deletions.
2 changes: 1 addition & 1 deletion src/bda/plone/orders/browser/templates/order_done.pt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<p tal:content="view/text">Text goes here</p>

<a href=""
class="payment_button standalone"
class="btn btn-primary"
tal:attributes="href context/absolute_url"
i18n:translate="order_done_continue">continue</a>

Expand Down
1 change: 1 addition & 0 deletions src/bda/plone/orders/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<include file="profiles.zcml" />
<include file="upgrades.zcml" />
<include package=".browser" />
<include package=".mailnotifytemplates" />
<include package=".restapi" />

<!-- roles -->
Expand Down
11 changes: 2 additions & 9 deletions src/bda/plone/orders/mailnotify.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,18 @@
from bda.plone.orders.mailtemplates import get_order_templates
from bda.plone.orders.mailtemplates import get_reservation_templates
from bda.plone.orders.mailtemplates import get_stock_threshold_reached_templates
from chameleon import PageTemplateLoader
from decimal import Decimal
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.utils import formataddr
from plone import api
from Products.CMFPlone.utils import safe_unicode
from zope.component import getMultiAdapter
from zope.component.hooks import getSite
from zope.globalrequest import getRequest
from zope.i18n import translate

import logging
import os
import textwrap


Expand Down Expand Up @@ -306,9 +305,6 @@ def __call__(
)


MAIL_TEMPLATES_DIRECTORY = os.path.join(os.path.dirname(__file__), "mailtemplates")


def create_html_mail_body(context, template_name, template_data):
"""Creates a rendered mail body
Expand All @@ -321,10 +317,7 @@ def create_html_mail_body(context, template_name, template_data):
template_data
Dict containing data passed to template.
"""
templates = PageTemplateLoader(
MAIL_TEMPLATES_DIRECTORY, translate=ZPTTranslator(), debug=True
)
template = templates["{}.pt".format(template_name)]
template = getMultiAdapter((context, getRequest()), name=template_name)
template_data["ascur"] = ascur
return template(**template_data)

Expand Down
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,28 @@

<head></head>

<body>
<body tal:define="
order options/order;
booking options/booking;
">
<h1 i18n:translate="order_mail_booking_cancelled_heading">
One of your bookings was cancelled
</h1>

<strong i18n:translate="order_mail_date">Date</strong>:
<tal:date replace="order['date']" />
${order/date}
<br />

<strong i18n:translate="order_mail_ordernumber">Ordernumber</strong>:
<tal:ordernumber replace="order['ordernumber']" />
${order/ordernumber}
<br />

<strong i18n:translate="order_mail_cancelled_item">Cancelled item</strong>:
<tal:cancelled_item replace="booking['title']" />
${booking7title']}
<br />

<strong i18n:translate="order_mail_order_details">Order details</strong>:
<a href="${order['portal_url'] + '/@@showorder?ordernumber=' + order['ordernumber']}"
<a href="${order/portal_url}/@@showorder?ordernumber=${order/ordernumber}"
i18n:translate="order_mail_click_here">
Click here
</a>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@

<head></head>

<body>
<body tal:define="
order options/order;
booking options/booking;
">
<h1 i18n:translate="order_mail_booking_reserved_to_ordered_heading">
Your reserved item is now available and our order is being processed
</h1>

<strong i18n:translate="order_mail_date">Date</strong>:
<tal:date replace="order['date']" />
${order/date}
<br />

<strong i18n:translate="order_mail_ordernumber">Ordernumber</strong>:
Expand Down
34 changes: 34 additions & 0 deletions src/bda/plone/orders/mailnotifytemplates/configure.zcml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<configure xmlns="http://namespaces.zope.org/zope"
xmlns:plone="http://namespaces.plone.org/plone"
xmlns:browser="http://namespaces.zope.org/browser"
xmlns:zcml="http://namespaces.zope.org/zcml">

<browser:page
for="*"
name="booking_cancelled"
template="booking_cancelled.pt"
permission="zope2.View"
layer="..interfaces.IOrdersExtensionLayer" />

<browser:page
for="*"
name="booking_reserved_to_ordered"
template="booking_reserved_to_ordered.pt"
permission="zope2.View"
layer="..interfaces.IOrdersExtensionLayer" />

<browser:page
for="*"
name="order_success"
template="order_success.pt"
permission="zope2.View"
layer="..interfaces.IOrdersExtensionLayer" />

<browser:page
for="*"
name="stock_threshold_reached"
template="stock_threshold_reached.pt"
permission="zope2.View"
layer="..interfaces.IOrdersExtensionLayer" />

</configure>
Loading

0 comments on commit 6f32114

Please sign in to comment.