From 84c58e4b000621e4af058181c3879bce3cdeafc6 Mon Sep 17 00:00:00 2001
From: Tom Teichler <tom.teichler@teckids.org>
Date: Sun, 13 Mar 2022 17:03:54 +0100
Subject: [PATCH] Fix email template, add link to send mails

---
 .../templates/templated_email/invoice.email   | 29 ++++++++-----------
 .../tezor/templates/tezor/invoice/full.html   |  4 +++
 2 files changed, 16 insertions(+), 17 deletions(-)

diff --git a/aleksis/apps/tezor/templates/templated_email/invoice.email b/aleksis/apps/tezor/templates/templated_email/invoice.email
index d6496f3..8fe6d05 100644
--- a/aleksis/apps/tezor/templates/templated_email/invoice.email
+++ b/aleksis/apps/tezor/templates/templated_email/invoice.email
@@ -1,26 +1,21 @@
 {% extends "templated_email/base.email" %}
-
 {% load i18n %}
 
-{% block subject %}{% trans "Invoice" %} {{ invoice }}{% endblock %}
+{% block subject_content %}{% trans "Invoice" %} {{ invoice.number }}{% endblock %}
 
-{% block plain %}
-    {% blocktrans with invoice=invoice %}
-    Please find attached invoice number {{ invoice.transaction_id }} for {{
-    invoice.description }} please carefully read the PDF file concerning all
-    payment details.
+{% block html_content %}
+<p>
+    {% blocktrans with number=invoice.number description=invoice.description %}
+    Please find attached invoice number {{ number }} for {{ description }}.
+    Please carefully read the PDF file concerning all payment details.
     {% endblocktrans %}
-
-{% endblock %}
-
-{% block html %}
-
+</p>
+{% if invoice.status == "waiting" %}
 <p>
-    {% blocktrans with invoice=invoice %}
-    Please find attached invoice number {{ invoice.transaction_id }} for {{
-    invoice.description }} please carefully read the PDF file concerning all
-    payment details.
+    {% blocktrans %}
+    Please visit the following link to view and make the payment:
     {% endblocktrans %}
 </p>
-
+<a href="{{ BASE_URL }}{{ invoice.get_absolute_url }}">{{ BASE_URL }}{{ invoice.get_absolute_url}}</a>
+{% endif %}
 {% endblock %}
diff --git a/aleksis/apps/tezor/templates/tezor/invoice/full.html b/aleksis/apps/tezor/templates/tezor/invoice/full.html
index 345aed9..01576f3 100644
--- a/aleksis/apps/tezor/templates/tezor/invoice/full.html
+++ b/aleksis/apps/tezor/templates/tezor/invoice/full.html
@@ -12,6 +12,7 @@
     {% has_perm 'tezor.display_purchased_items_rule' user object as can_view_purchased_items %}
     {% has_perm 'tezor.display_billing_rule' user object as can_view_billing_information %}
     {% has_perm 'tezor.print_invoice_rule' user object as can_print_invoice %}
+    {% has_perm 'tezor.send_invoice_email_rule' user object as can_send_invoice_email %}
 
     <h1>{% trans "Invoice" %} {{ object.number }} — {{ object.created.date }}</h1>
 
@@ -21,6 +22,9 @@
     {% if can_print_invoice %}
       <a class="btn colour-primary waves-effect waves-light" href="{% url 'print_invoice' object.token %}">{% trans "Print" %}</a>
     {% endif %}
+    {% if can_send_invoice_email %}
+      <a class="btn colour-primary waves-effect waves-light" href="{% url 'send_invoice_by_token' object.token %}">{% trans "Send Email" %}</a>
+    {% endif %}
 
     <div class="row">
     {% if can_view_billing_information %}
-- 
GitLab