Skip to content

Commit

Permalink
fixup! Avoid HTML tags in plain text part of notification emails
Browse files Browse the repository at this point in the history
  • Loading branch information
FestplattenSchnitzel committed Feb 5, 2024
1 parent 0964afb commit 8d62480
Show file tree
Hide file tree
Showing 11 changed files with 39 additions and 41 deletions.
11 changes: 11 additions & 0 deletions pycroft/templates/mail/base.html.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{%- set links = [] -%}
{%- import "macros/link.html" as link with context -%}
{%- if mode == 'html' -%}
<pre>
{%- endif -%}
{% block body %}{% endblock %}

{{ link.render_link_list(mode) }}
{%- if mode == 'html' -%}
</pre>
{%- endif -%}
12 changes: 0 additions & 12 deletions pycroft/templates/mail/macros/link.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
{%- macro start_pre(mode) -%}
{%- if mode == 'html' -%}
<pre>
{%- endif -%}
{%- endmacro -%}

{%- macro render_link(text, url, mode) -%}
{%- if mode == 'html' -%}
<a href="{{ url }}">{{ text }}</a>
Expand All @@ -19,9 +13,3 @@
{% endfor -%}
{%- endif -%}{{ '' if links.clear() }}
{%- endmacro -%}

{%- macro end_pre(mode) -%}
{%- if mode == 'html' -%}
</pre>
{%- endif -%}
{%- endmacro -%}
5 changes: 3 additions & 2 deletions pycroft/templates/mail/member_negative_balance.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{{ link.start_pre(mode) }}
{% extends "base.html.j2" %}
{% block body %}
* English version below *

Hallo {{ user.name }},
Expand Down Expand Up @@ -97,4 +98,4 @@
[4] Office hours: https://agdsn.de/sipa/pages/support/contacts
[5] Finance constitution:
https://agdsn.de/sipa/documents/legal/beitragsordnung.pdf
{{ link.end_pre(mode) }}
{% endblock %}
5 changes: 3 additions & 2 deletions pycroft/templates/mail/member_request_denied.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{{ link.start_pre(mode) }}
{% extends "base.html.j2" %}
{% block body %}
English version below!

---
Expand Down Expand Up @@ -30,4 +31,4 @@

Best Regards
Your AG DSN
{{ link.end_pre(mode) }}
{% endblock %}
5 changes: 3 additions & 2 deletions pycroft/templates/mail/member_request_merged.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{{ link.start_pre(mode) }}
{% extends "base.html.j2" %}
{% block body %}
English version below!

---
Expand Down Expand Up @@ -41,4 +42,4 @@

Best Regards
Your AG DSN
{{ link.end_pre(mode) }}
{% endblock %}
5 changes: 3 additions & 2 deletions pycroft/templates/mail/member_request_pending.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{{ link.start_pre(mode) }}
{% extends "base.html.j2" %}
{% block body %}
English version below!

---
Expand Down Expand Up @@ -70,4 +71,4 @@

Best Regards
Your AG DSN
{{ link.end_pre(mode) }}
{% endblock %}
5 changes: 3 additions & 2 deletions pycroft/templates/mail/task_failed.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{{ link.start_pre(mode) }}
{% extends "base.html.j2" %}
{% block body %}
Hallo Supportteam,

die geplante Pycroft {{ task.type }} Aufgabe #{{ task.id }} von {{ task.creator.name }}
Expand All @@ -15,4 +16,4 @@

Viele Grüße
Pycroft
{{ link.end_pre(mode) }}
{% endblock %}
8 changes: 3 additions & 5 deletions pycroft/templates/mail/user_confirm_email.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{%- set links = [] -%}
{% extends "base.html.j2" %}
{%- import "macros/link.html" as link with context -%}
{{ link.start_pre(mode) }}
{% block body %}
English version below!

---
Expand Down Expand Up @@ -29,6 +29,4 @@

Best Regards
Your AG DSN

{{ link.render_link_list(mode) }}
{{ link.end_pre(mode) }}
{% endblock %}
9 changes: 3 additions & 6 deletions pycroft/templates/mail/user_created.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{%- set links = [] -%}
{% extends "base.html.j2" %}
{%- import "macros/link.html" as link with context -%}

{{ link.start_pre(mode) }}
{% block body %}
English version below!

---
Expand Down Expand Up @@ -83,6 +82,4 @@

Best Regards
Your AG DSN

{{ link.render_link_list(mode) }}
{{ link.end_pre(mode) }}
{% endblock %}
7 changes: 4 additions & 3 deletions pycroft/templates/mail/user_moved_in.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{{ link.start_pre(mode) }}
{% extends "base.html.j2" %}
{%- import "macros/link.html" as link with context -%}
{% block body %}
English version below!

---
Expand Down Expand Up @@ -38,5 +40,4 @@

Best Regards
Your AG DSN
{{ link.render_link_list(mode) }}
{{ link.end_pre(mode) }}
{% endblock %}
8 changes: 3 additions & 5 deletions pycroft/templates/mail/user_reset_password.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{%- set links = [] -%}
{% extends "base.html.j2" %}
{%- import "macros/link.html" as link with context -%}
{{ link.start_pre(mode) }}
{% block body %}
English version below!

---
Expand Down Expand Up @@ -36,6 +36,4 @@

Best Regards
Your AG DSN

{{ link.render_link_list(mode) }}
{{ link.end_pre(mode) }}
{% endblock %}

0 comments on commit 8d62480

Please sign in to comment.