forked from CGM_Public/pretix_original
E-mails: add additional information on order positions
This commit is contained in:
@@ -2,10 +2,12 @@ import inspect
|
|||||||
import logging
|
import logging
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
|
from itertools import groupby
|
||||||
from smtplib import SMTPResponseException
|
from smtplib import SMTPResponseException
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.core.mail.backends.smtp import EmailBackend
|
from django.core.mail.backends.smtp import EmailBackend
|
||||||
|
from django.db.models import Count
|
||||||
from django.dispatch import receiver
|
from django.dispatch import receiver
|
||||||
from django.template.loader import get_template
|
from django.template.loader import get_template
|
||||||
from django.utils.timezone import now
|
from django.utils.timezone import now
|
||||||
@@ -128,9 +130,21 @@ class TemplateBasedMailRenderer(BaseHTMLMailRenderer):
|
|||||||
|
|
||||||
if order:
|
if order:
|
||||||
htmlctx['order'] = order
|
htmlctx['order'] = order
|
||||||
|
positions = list(order.positions.select_related(
|
||||||
|
'item', 'variation', 'subevent', 'addon_to'
|
||||||
|
).annotate(
|
||||||
|
has_addons=Count('addons')
|
||||||
|
))
|
||||||
|
htmlctx['cart'] = [(k, list(v)) for k, v in groupby(
|
||||||
|
positions, key=lambda op: (
|
||||||
|
op.item, op.variation, op.subevent, op.attendee_name,
|
||||||
|
(op.pk if op.addon_to_id else None), (op.pk if op.has_addons else None)
|
||||||
|
)
|
||||||
|
)]
|
||||||
|
|
||||||
if position:
|
if position:
|
||||||
htmlctx['position'] = position
|
htmlctx['position'] = position
|
||||||
|
htmlctx['ev'] = position.subevent or self.event
|
||||||
|
|
||||||
tpl = get_template(self.template_name)
|
tpl = get_template(self.template_name)
|
||||||
body_html = inline_css(tpl.render(htmlctx))
|
body_html = inline_css(tpl.render(htmlctx))
|
||||||
|
|||||||
@@ -136,6 +136,31 @@
|
|||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
color: {{ color }};
|
color: {{ color }};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.order-button {
|
||||||
|
padding-top: 5px
|
||||||
|
}
|
||||||
|
.order-button a.button {
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
.order-info {
|
||||||
|
padding-bottom: 5px
|
||||||
|
}
|
||||||
|
|
||||||
|
.order {
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cart-table > tr > td:first-child {
|
||||||
|
width: 40px;
|
||||||
|
}
|
||||||
|
.order-details > tr > td:first-child {
|
||||||
|
width: 20%;
|
||||||
|
}
|
||||||
|
.order-details td {
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
{% if rtl %}
|
{% if rtl %}
|
||||||
body {
|
body {
|
||||||
direction: rtl;
|
direction: rtl;
|
||||||
|
|||||||
158
src/pretix/base/templates/pretixbase/email/order_details.html
Normal file
158
src/pretix/base/templates/pretixbase/email/order_details.html
Normal file
@@ -0,0 +1,158 @@
|
|||||||
|
{% load eventurl %}
|
||||||
|
{% load i18n %}
|
||||||
|
|
||||||
|
{% if position %}
|
||||||
|
<div class="order-info">
|
||||||
|
{% trans "You are receiving this email because someone signed you up for the following event:" %}
|
||||||
|
</div>
|
||||||
|
<table class="order-details">
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<strong>{% trans "Event:" %}</strong>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{{ event.name }}
|
||||||
|
<br>
|
||||||
|
{% if event.has_subevents and ev.name|upper != event.name|upper %}{{ ev.name }}<br>{% endif %}
|
||||||
|
{{ ev.get_date_range_display }}
|
||||||
|
{% if event.settings.show_times %}
|
||||||
|
{{ ev.date_from|date:"TIME_FORMAT" }}
|
||||||
|
{% endif %}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<strong>{% trans "Order code:" %}</strong>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{{ order.code }} ({{ order.datetime|date:"SHORT_DATE_FORMAT" }})<br>
|
||||||
|
{% if order.email %}
|
||||||
|
{% trans "created by" %} {{ order.email }}
|
||||||
|
{% endif %}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<strong>{% trans "Order status:" %}</strong>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{% include "pretixpresale/event/fragment_order_status.html" with order=order %}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<strong>{% trans "Organizer:" %}</strong>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{{ event.organizer }}
|
||||||
|
{% if event.settings.contact_mail %}
|
||||||
|
<br>
|
||||||
|
<a href="mailto:{{ event.settings.contact_mail }}">
|
||||||
|
{{ event.settings.contact_mail }}
|
||||||
|
</a>
|
||||||
|
{% endif %}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
<div class="order-button">
|
||||||
|
<a href="{% abseventurl event "presale:event.order.position" order=order.code secret=position.web_secret position=position.positionid %}" class="button">
|
||||||
|
{% trans "View registration details" %}
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
{% else %}
|
||||||
|
<div class="order-info">
|
||||||
|
{% trans "You are receiving this email because you placed an order for the following event:" %}
|
||||||
|
</div>
|
||||||
|
<table class="order-details">
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<strong>{% trans "Event:" %}</strong>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{{ event.name }}
|
||||||
|
{% if not event.has_subevents and event.settings.show_dates_on_frontpage %}
|
||||||
|
<br>
|
||||||
|
{{ event.get_date_range_display }}
|
||||||
|
{% if event.settings.show_times %}
|
||||||
|
{{ event.date_from|date:"TIME_FORMAT" }}
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<strong>{% trans "Order code:" %}</strong>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{{ order.code }} ({{ order.datetime|date:"SHORT_DATE_FORMAT" }})
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<strong>{% trans "Order status:" %}</strong>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{% include "pretixpresale/event/fragment_order_status.html" with order=order %}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{% if cart %}
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<strong>{% trans "Details:" %}</strong>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<table class="cart-table">
|
||||||
|
{% for groupkey, positions in cart %}
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
{% if not groupkey.4 %} {# is addon #}
|
||||||
|
{{ positions|length }}x
|
||||||
|
{% endif %}
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{% if groupkey.4 %} {# is addon #}
|
||||||
|
+
|
||||||
|
{% endif %}
|
||||||
|
{{ groupkey.0.name }}{% if groupkey.1 %} – {{ groupkey.1.value }}{% endif %}
|
||||||
|
{% if groupkey.2 %} {# subevent #}
|
||||||
|
<br>
|
||||||
|
{% if groupkey.2.name|upper != event.name|upper %}
|
||||||
|
{{ groupkey.2.name }} ·
|
||||||
|
{% endif %}
|
||||||
|
{{ groupkey.2.get_date_range_display }}
|
||||||
|
{% if event.settings.show_times %}
|
||||||
|
{{ groupkey.2.date_from|date:"TIME_FORMAT" }}
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
{% if groupkey.3 %} {# attendee name #}
|
||||||
|
<br>
|
||||||
|
{{ groupkey.3.name }}
|
||||||
|
{% endif %}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</table>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{% endif %}
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<strong>{% trans "Organizer:" %}</strong>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{{ event.organizer }}
|
||||||
|
{% if event.settings.contact_mail %}
|
||||||
|
<br>
|
||||||
|
<a href="mailto:{{ event.settings.contact_mail }}">
|
||||||
|
{{ event.settings.contact_mail }}
|
||||||
|
</a>
|
||||||
|
{% endif %}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
<div class="order-button">
|
||||||
|
<a href="{% abseventurl event "presale:event.order.open" hash=order.email_confirm_hash order=order.code secret=order.secret %}" class="button">
|
||||||
|
{% trans "View order details" %}
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
@@ -23,23 +23,7 @@
|
|||||||
<table cellpadding="20"><tr><td>
|
<table cellpadding="20"><tr><td>
|
||||||
<![endif]-->
|
<![endif]-->
|
||||||
<div class="content">
|
<div class="content">
|
||||||
{% if position %}
|
{% include "pretixbase/email/order_details.html" %}
|
||||||
{% trans "You are receiving this email because someone signed you up for the following event:" %}<br>
|
|
||||||
<strong>{% trans "Event:" %}</strong> {{ event.name }}<br>
|
|
||||||
<strong>{% trans "Order code:" %}</strong> {{ order.code }}<br>
|
|
||||||
<strong>{% trans "Order date:" %}</strong> {{ order.datetime|date:"SHORT_DATE_FORMAT" }}<br>
|
|
||||||
<a href="{% abseventurl event "presale:event.order.position" order=order.code secret=position.web_secret position=position.positionid %}">
|
|
||||||
{% trans "View registration details" %}
|
|
||||||
</a>
|
|
||||||
{% else %}
|
|
||||||
{% trans "You are receiving this email because you placed an order for the following event:" %}<br>
|
|
||||||
<strong>{% trans "Event:" %}</strong> {{ event.name }}<br>
|
|
||||||
<strong>{% trans "Order code:" %}</strong> {{ order.code }}<br>
|
|
||||||
<strong>{% trans "Order date:" %}</strong> {{ order.datetime|date:"SHORT_DATE_FORMAT" }}<br>
|
|
||||||
<a href="{% abseventurl event "presale:event.order.open" hash=order.email_confirm_hash order=order.code secret=order.secret %}">
|
|
||||||
{% trans "View order details" %}
|
|
||||||
</a>
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
</div>
|
||||||
<!--[if gte mso 9]>
|
<!--[if gte mso 9]>
|
||||||
</td></tr></table>
|
</td></tr></table>
|
||||||
|
|||||||
@@ -147,6 +147,31 @@
|
|||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
color: {{ color }};
|
color: {{ color }};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.order-button {
|
||||||
|
padding-top: 5px
|
||||||
|
}
|
||||||
|
.order-button a.button {
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
.order-info {
|
||||||
|
padding-bottom: 5px
|
||||||
|
}
|
||||||
|
|
||||||
|
.order {
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cart-table > tr > td:first-child {
|
||||||
|
width: 40px;
|
||||||
|
}
|
||||||
|
.order-details > tr > td:first-child {
|
||||||
|
width: 20%;
|
||||||
|
}
|
||||||
|
.order-details td {
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
{% if rtl %}
|
{% if rtl %}
|
||||||
body {
|
body {
|
||||||
direction: rtl;
|
direction: rtl;
|
||||||
@@ -226,23 +251,7 @@
|
|||||||
<table cellpadding="20"><tr><td>
|
<table cellpadding="20"><tr><td>
|
||||||
<![endif]-->
|
<![endif]-->
|
||||||
<div class="content">
|
<div class="content">
|
||||||
{% if position %}
|
{% include "pretixbase/email/order_details.html" %}
|
||||||
{% trans "You are receiving this email because someone signed you up for the following event:" %}<br>
|
|
||||||
<strong>{% trans "Event:" %}</strong> {{ event.name }}<br>
|
|
||||||
<strong>{% trans "Order code:" %}</strong> {{ order.code }}<br>
|
|
||||||
<strong>{% trans "Order date:" %}</strong> {{ order.datetime|date:"SHORT_DATE_FORMAT" }}<br>
|
|
||||||
<a href="{% abseventurl event "presale:event.order.position" order=order.code secret=position.web_secret position=position.positionid %}">
|
|
||||||
{% trans "View registration details" %}
|
|
||||||
</a>
|
|
||||||
{% else %}
|
|
||||||
{% trans "You are receiving this email because you placed an order for the following event:" %}<br>
|
|
||||||
<strong>{% trans "Event:" %}</strong> {{ event.name }}<br>
|
|
||||||
<strong>{% trans "Order code:" %}</strong> {{ order.code }}<br>
|
|
||||||
<strong>{% trans "Order date:" %}</strong> {{ order.datetime|date:"SHORT_DATE_FORMAT" }}<br>
|
|
||||||
<a href="{% abseventurl event "presale:event.order.open" hash=order.email_confirm_hash order=order.code secret=order.secret %}">
|
|
||||||
{% trans "View order details" %}
|
|
||||||
</a>
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
</div>
|
||||||
<!--[if gte mso 9]>
|
<!--[if gte mso 9]>
|
||||||
</td></tr></table>
|
</td></tr></table>
|
||||||
|
|||||||
@@ -691,14 +691,14 @@ class MailSettingsRendererPreview(MailSettingsPreview):
|
|||||||
expires=now(), code="PREVIEW", total=119)
|
expires=now(), code="PREVIEW", total=119)
|
||||||
item = request.event.items.create(name=gettext("Sample product"), default_price=42.23,
|
item = request.event.items.create(name=gettext("Sample product"), default_price=42.23,
|
||||||
description=gettext("Sample product description"))
|
description=gettext("Sample product description"))
|
||||||
p = order.positions.create(item=item, attendee_name_parts={'_legacy': gettext("John Doe")},
|
order.positions.create(item=item, attendee_name_parts={'_legacy': gettext("John Doe")},
|
||||||
price=item.default_price)
|
price=item.default_price, subevent=request.event.subevents.last())
|
||||||
v = renderers[request.GET.get('renderer')].render(
|
v = renderers[request.GET.get('renderer')].render(
|
||||||
v,
|
v,
|
||||||
str(request.event.settings.mail_text_signature),
|
str(request.event.settings.mail_text_signature),
|
||||||
gettext('Your order: %(code)s') % {'code': order.code},
|
gettext('Your order: %(code)s') % {'code': order.code},
|
||||||
order,
|
order,
|
||||||
position=p
|
position=None
|
||||||
)
|
)
|
||||||
r = HttpResponse(v, content_type='text/html')
|
r = HttpResponse(v, content_type='text/html')
|
||||||
r._csp_ignore = True
|
r._csp_ignore = True
|
||||||
|
|||||||
Reference in New Issue
Block a user