Skip to content

Commit 8bbcbd5

Browse files
Sak1012norbusanmariobehling
authored
fix(email): add missing templates and static files (#1121)
* fix(email): add missing templates and static files * Convert tab to spaces for consistency (from @copilot) * Apply suggestion from @Copilot * Fixes --------- Co-authored-by: Norbert Preining <[email protected]> Co-authored-by: Mario Behling <[email protected]>
1 parent 47ec185 commit 8bbcbd5

File tree

8 files changed

+343
-8
lines changed

8 files changed

+343
-8
lines changed

app/eventyay/config/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ def instance_name(request):
298298
BASE_DIR / 'jinja-templates',
299299
],
300300
'OPTIONS': {
301-
'environment': 'eventyay.jinja.environment',
301+
'environment': 'eventyay.helpers.jinja.environment',
302302
'extensions': (
303303
'jinja2.ext.i18n',
304304
'jinja2.ext.do',

app/eventyay/helpers/jinja.py

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
from django.urls import reverse
2-
from jinja2 import pass_context
2+
from django.utils.translation import gettext as django_gettext, ngettext
3+
from django.utils.formats import date_format
4+
from jinja2 import Environment, pass_context
35
from jinja2.runtime import Context
6+
from eventyay.helpers.templatetags.thumb import thumb
47

58

6-
# Ref: https://github.com/niwinz/django-jinja/blob/master/django_jinja/builtins/extensions.py#L173
79
@pass_context
810
def url_for(context: Context, name: str, *args, query_string=None, **kwargs):
911
try:
@@ -16,4 +18,41 @@ def url_for(context: Context, name: str, *args, query_string=None, **kwargs):
1618
except AttributeError:
1719
current_app = None
1820
base_url = reverse(name, args=args, kwargs=kwargs, current_app=current_app)
19-
return '{}?{}'.format(base_url, query_string) if query_string else base_url
21+
return f"{base_url}?{query_string}" if query_string else base_url
22+
23+
24+
def jinja_gettext(message, **kwargs):
25+
text = django_gettext(message)
26+
if kwargs:
27+
try:
28+
text = text % kwargs
29+
except Exception:
30+
pass
31+
return text
32+
33+
34+
def format_date(value, format_str="SHORT_DATE_FORMAT"):
35+
if not value:
36+
return ""
37+
try:
38+
return date_format(value, format_str)
39+
except Exception:
40+
return str(value)
41+
42+
43+
def environment(**options):
44+
env = Environment(**options, autoescape=True)
45+
46+
env.globals.update({
47+
'url_for': url_for,
48+
'_': jinja_gettext,
49+
'gettext': jinja_gettext,
50+
'ngettext': ngettext,
51+
})
52+
53+
env.filters.update({
54+
'thumb': thumb,
55+
'format_date': format_date,
56+
})
57+
58+
return env
Lines changed: 248 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,248 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset='utf-8'>
5+
<meta name='viewport' content='width=device-width, user-scalable=false'>
6+
<style type='text/css'>
7+
body {
8+
background-color: #eee;
9+
background-position: top;
10+
background-repeat: repeat-x;
11+
font-family: "Open Sans", "OpenSans", "Helvetica Neue", Helvetica, Arial, sans-serif;
12+
font-size: 14px;
13+
line-height: 20px;
14+
color: #333;
15+
margin: 0;
16+
padding-top: 20px;
17+
}
18+
19+
table.layout > tr > td {
20+
background-color: white;
21+
padding: 0;
22+
}
23+
24+
table.layout > tr > td.header {
25+
padding: 0 20px;
26+
text-align: center;
27+
}
28+
29+
.header h2 {
30+
margin-top: 5px;
31+
margin-bottom: 10px;
32+
font-size: 22px;
33+
line-height: 26px;
34+
}
35+
36+
.header h1 {
37+
margin-top: 0;
38+
margin-bottom: 5px;
39+
font-size: 26px;
40+
}
41+
42+
.header h2 a, .header h1 a, .content h2 a, .content h3 a {
43+
text-decoration: none;
44+
}
45+
46+
.content h2, .content h3 {
47+
margin-bottom: 20px;
48+
margin-top: 10px;
49+
}
50+
51+
a {
52+
color: {{ color }};
53+
font-weight: bold;
54+
}
55+
56+
a:hover, a:focus {
57+
color: {{ color }};
58+
text-decoration: underline;
59+
}
60+
61+
a:hover, a:active {
62+
outline: 0;
63+
}
64+
65+
p {
66+
margin: 0 0 10px;
67+
68+
/* These are technically the same, but use both */
69+
overflow-wrap: break-word;
70+
word-wrap: break-word;
71+
word-break: break-word;
72+
73+
-ms-word-break: break-all;
74+
75+
/* Adds a hyphen where the word breaks, if supported (No Blink) */
76+
-ms-hyphens: auto;
77+
-moz-hyphens: auto;
78+
-webkit-hyphens: auto;
79+
hyphens: auto;
80+
}
81+
p:last-child {
82+
margin-bottom: 0;
83+
}
84+
85+
.footer {
86+
padding: 10px;
87+
text-align: center;
88+
font-size: 12px;
89+
}
90+
91+
.content {
92+
padding: 0 18px;
93+
}
94+
95+
::selection {
96+
background: {{ color }};
97+
color: #FFF;
98+
}
99+
100+
table.layout {
101+
width: 100%;
102+
max-width: 600px;
103+
border-spacing: 0px;
104+
border-collapse: separate;
105+
margin: auto;
106+
}
107+
108+
img.wide {
109+
width: 100%;
110+
height: auto;
111+
}
112+
113+
.content table {
114+
width: 100%;
115+
}
116+
117+
.content table td {
118+
vertical-align: top;
119+
text-align: left;
120+
padding: 0;
121+
}
122+
123+
a.button {
124+
display: inline-block;
125+
padding: 10px 16px;
126+
font-size: 14px;
127+
line-height: 1.33333;
128+
border: 1px solid #cccccc;
129+
border-radius: 6px;
130+
-webkit-border-radius: 6px;
131+
-moz-border-radius: 6px;
132+
margin: 5px;
133+
text-decoration: none;
134+
color: {{ color }};
135+
}
136+
137+
.order-button {
138+
padding-top: 5px
139+
}
140+
.order-button a.button {
141+
font-size: 12px;
142+
}
143+
.order-info {
144+
padding-bottom: 5px
145+
}
146+
147+
.order {
148+
font-size: 12px;
149+
}
150+
151+
.cart-table > tr > td:first-child {
152+
width: 40px;
153+
}
154+
.order-details > tr > td:first-child {
155+
width: 20%;
156+
}
157+
.order-details td {
158+
font-size: 12px;
159+
}
160+
161+
{% if rtl %}
162+
body {
163+
direction: rtl;
164+
}
165+
.content table td {
166+
text-align: right;
167+
}
168+
{% endif %}
169+
170+
{% block addcss %}{% endblock %}
171+
</style>
172+
<!--[if mso]>
173+
<style type="text/css">
174+
body, table, td {
175+
font-family: "Open Sans", "OpenSans", "Helvetica Neue", Helvetica, Arial, sans-serif !important;
176+
}
177+
</style>
178+
<![endif]-->
179+
</head>
180+
<body align='center'>
181+
<!--[if gte mso 9]>
182+
<table width="100%"><tr><td align="center">
183+
<table width="600"><tr><td align="center"
184+
<![endif]-->
185+
<table class='layout' width='600' border='0' cellspacing='0'>
186+
<!--[if !mso]><!-- -->
187+
<tr>
188+
<td style='line-height: 0'>
189+
<img class='wide' src='data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAlgAAAA8CAAAAACf95tlAAAAAXNCSVQI5gpbmQAAAAlwSFlzAAAOxAAADsQBlSsOGwAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAG/SURBVHja7dvRboMwDIXhvf/DLiQQAwkku9+qDgq2hPyfN6j1qTlx06/uMunbLMnnhL98fuzRDtYILEeZ7GBNwAIWsIB1LdkOVgaWo4gdLAGWo6x2sFZgOUq1g1WB5SjNDlYDlqcEK1dDB5anmK3eE7C4FnIpBNbVFLo7sB7d3huwKFlULGA9pWQJsJxls4G1ActbooWr2IHlLbMFrBlY7rJbwNqBxb2QZ8nAuiUGO9ICLOo71R1YN0X9td8KLJ8ZeDEDrAd+Za3A4mLIz4TAujGqv+tUYPmN4v8LcweW3zS1t++hActzCrtRYD3pMJQOLOeJ7NyBpZFdoWaFDVjuJ6BRswpTBZbCAn5hpsDq/fbHpDMTBZbC1TAzT2ApyMIVsDROQ2GWwFJo8PR2YP3eOtywzwrsGYD1J9vlHXzcmSKw7q/wU2OEwHpdtALHILA00jJfV8DSaVofvYOPlckB658sp/8VNrBkANahqnXqfhhXJgasgymHD8REZwfWmezzga+tQdhcAet0qry1FYV3osD6dP1QJL3YbYUkhfUCsK6einWRPI0pxjROWZbK+QcsAiwCLEKARYBFgEXIu/wAYbjtwujw8KwAAAAASUVORK5CYII=' style='max-height: 60px;'>
190+
</td>
191+
</tr>
192+
<!--<![endif]-->
193+
<tr>
194+
<td class='header' align='center'>
195+
<!--[if gte mso 9]>
196+
<table cellpadding='20'><tr><td align='center'>
197+
<![endif]-->
198+
{% set logo = event.settings.event_logo_image or event.settings.logo_image %}
199+
{% if logo %}
200+
<div align="center" style="margin-top: 5px;">
201+
{% if logo|thumb('5000x120')|first == '/' %}
202+
<img src="{{ site_url }}{{ logo|thumb('5000x120') }}"
203+
alt="{{ event.name }}"
204+
style="height: auto; max-width: 180px;" />
205+
{% else %}
206+
<img src="{{ logo|thumb('5000x120') }}"
207+
alt="{{ event.name }}"
208+
style="height: auto; max-width: 180px;" />
209+
{% endif %}
210+
</div>
211+
{% endif %}
212+
213+
{% if event %}
214+
<h2><a href="{{ url_for('presale:event.index', organizer=event.organizer.slug, event=event.slug) }}" target='_blank'>{{ event.name }}</a></h2>
215+
{% else %}
216+
<h2><a href='{{ site_url }}' target='_blank'>{{ site }}</a></h2>
217+
{% endif %}
218+
{% block header %}
219+
<h1>{{ subject }}</h1>
220+
{% endblock %}
221+
<!--[if gte mso 9]>
222+
</td></tr></table>
223+
<![endif]-->
224+
</td>
225+
</tr>
226+
{% include 'eventyay/email/separator.jinja' %}
227+
{% block content %}
228+
{% endblock %}
229+
<!--[if !mso]><!-- -->
230+
<tr>
231+
<td style='line-height: 0'>
232+
<br>
233+
<img class='wide' src='data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAlgAAAA8CAYAAAC6nMS5AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAOxAAADsQBlSsOGwAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAPnSURBVHic7d3dbuJIEAbQsg2Ecd7/TQeDf3svVuFmdjJLxsGm+xwJKXcpqS76U3VTVCmlFAAArKbeugAAgNwIWAAAKxOwAABWJmABAKxMwAIAWNlh6wIAIiKWZYllWWKe5/vfEREppfsnIqKqqvsnIqKu66jrOpqmuf8NsDUBC3i6lFJM0xTjOMY0TbEsS6y1MaaqqqjrOg6HQxyPxzgcDvcwBvAslT1YwDN8BKpxHGOe56f+76Zp4ng83gMXwHcTsIBvsyxLDMMQfd/fr/y2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td>
235+
</tr>
236+
<!--<![endif]-->
237+
</table>
238+
<div class='footer'>
239+
{% include 'eventyay/email/email_footer.jinja' %}
240+
</div>
241+
<br/>
242+
<br/>
243+
<!--[if gte mso 9]>
244+
</td></tr></table>
245+
</td></tr></table>
246+
<![endif]-->
247+
</body>
248+
</html>

app/eventyay/jinja-templates/eventyay/email/order_details.jinja

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
{{ event.name }}
1212
<br>
1313
{% if event.has_subevents and ev.name|upper != event.name|upper %}{{ ev.name }}<br>{% endif %}
14-
{{ ev.get_date_range_display }}
14+
{{ ev.get_date_range_display() }}
1515
{% if event.settings.show_times %}
1616
{{ ev.date_from|format_date('TIME_FORMAT') }}
1717
{% endif %}
@@ -61,7 +61,7 @@
6161
{{ event.name }}
6262
{% if not event.has_subevents and event.settings.show_dates_on_frontpage %}
6363
<br>
64-
{{ event.get_date_range_display }}
64+
{{ event.get_date_range_display() }}
6565
{% if event.settings.show_times %}
6666
{{ event.date_from|format_date('TIME_FORMAT') }}
6767
{% endif %}
@@ -107,7 +107,7 @@
107107
{% endif %}
108108
{% if groupkey[3] %} {# attendee name #}
109109
<br>
110-
{{ groupkey[3].name }}
110+
{{ groupkey[3].name|default(groupkey[3]) }}
111111
{% endif %}
112112
</td>
113113
</tr>
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
{% extends "eventyay/email/base_logo.jinja" %}
2+
{% block content %}
3+
<tr>
4+
<td class="containertd">
5+
<!--[if gte mso 9]>
6+
<table cellpadding="20"><tr><td>
7+
<![endif]-->
8+
<div class="content">
9+
{{ body | safe }}
10+
</div>
11+
<!--[if gte mso 9]>
12+
</td></tr></table>
13+
<![endif]-->
14+
</td>
15+
</tr>
16+
{% if order %}
17+
{% include "eventyay/email/separator.jinja" %}
18+
<tr>
19+
<td class="order containertd">
20+
<!--[if gte mso 9]>
21+
<table cellpadding="20"><tr><td>
22+
<![endif]-->
23+
<div class="content">
24+
{% include "eventyay/email/order_details.jinja" %}
25+
</div>
26+
<!--[if gte mso 9]>
27+
</td></tr></table>
28+
<![endif]-->
29+
</td>
30+
</tr>
31+
{% endif %}
32+
{% if signature %}
33+
{% include "eventyay/email/separator.jinja" %}
34+
<tr>
35+
<td class="order containertd">
36+
<!--[if gte mso 9]>
37+
<table cellpadding="20"><tr><td>
38+
<![endif]-->
39+
<div class="content">
40+
{{ signature | safe }}
41+
</div>
42+
<!--[if gte mso 9]>
43+
</td></tr></table>
44+
<![endif]-->
45+
</td>
46+
</tr>
47+
{% endif %}
48+
{% endblock %}

app/eventyay/plugins/sendmail/templates/pretixplugins/sendmail/send_form.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ <h1>{% trans "Compose emails" %}</h1>
2424
{% endif %}
2525
{% bootstrap_field form.created_from layout='horizontal' %}
2626
{% bootstrap_field form.created_to layout='horizontal' %}
27-
{% bootstrap_field form.items layout='horizontal' %}
27+
{% bootstrap_field form.products layout='horizontal' %}
2828
<div class="row">
2929
<div class="col-md-9 col-md-offset-3">
3030
<div class="panel-group">
26.9 KB
Loading
27.9 KB
Loading

0 commit comments

Comments
 (0)