Merge pull request #2231 from SchrodingersGat/outgoing-email

Refactor email body out into a template
This commit is contained in:
Oliver 2021-11-02 15:07:23 +11:00 committed by GitHub
commit 96a89558b4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 66 additions and 29 deletions

View File

@ -0,0 +1,43 @@
{% load i18n %}
{% load static %}
{% load inventree_extras %}
<table style='border-collapse: collapse; width: 85%; margin-left: 10%; font-size: 1rem; border: 1px solid #68686a; border-radius: 2px;'>
{% block header %}
<tr style='background: #eef3f7; height: 4rem; text-align: center;'>
<th colspan="100%" style="padding-bottom: 1rem; color: #68686a;">
{% block header_row %}
<p style='font-size: 1.25rem;'>{% block title %}<!-- email title goes here -->{% endblock %}</p>
{% block subtitle %}
<!-- email subtitle goes here -->
{% endblock %}
{% endblock %}
</th>
</tr>
{% endblock %}
{% block body %}
<tr style="height: 3rem; border-bottom: 1px solid #68686a;">
{% block body_row %}
<!-- email body goes here -->
{% endblock %}
</tr>
{% endblock %}
{% block footer %}
<tr style='background: #eef3f7; height: 2rem;'>
<td colspan="100%" style="padding-top:1rem; text-align: center">
{% block footer_prefix %}
<!-- Custom footer information goes here -->
{% endblock %}
<p><em><small>{% trans "InvenTree version" %}: {% inventree_version %} - <a href='https://inventree.readthedocs.io'>inventree.readthedocs.io</a></small></em></p>
{% block footer_suffix %}
<!-- Custom footer information goes here -->
{% endblock %}
</td>
</tr>
{% endblock %}
</table>

View File

@ -1,35 +1,29 @@
{% extends "email/email.html" %}
{% load i18n %} {% load i18n %}
{% load inventree_extras %} {% load inventree_extras %}
<table style="border-collapse:collapse; width: 80%;margin-left: 10%; font-size: 1rem"> {% block title %}
{% blocktrans with part=part.name %} The available stock for {{ part }} has fallen below the configured minimum level{% endblocktrans %}
{% if link %}
<p>{% trans "Click on the following link to view this part" %}: <a href="{{ link }}">{{ link }}</a></p>
{% endif %}
{% endblock %}
<tr style="background: aliceblue; height: 4rem;"> {% block subtitle %}
<th colspan="3" style="padding-bottom: 1rem; font-size: 1.25rem; color:rgb(210, 20, 20)"> <p><em>{% blocktrans with part=part.name %}You are receiving this email because you are subscribed to notifications for this part {% endblocktrans %}.</em></p>
<p>{% blocktrans with part=part.name %} The available stock for {{ part }} has fallen below the configured minimum level{% endblocktrans %}</p> {% endblock %}
{% if link %}
<p>{% trans "Click on the following link to view this part" %}: <a href="{{ link }}">{{ link }}</a></p>
{% endif %}
</th>
</tr>
<tr style="height: 3rem; border-bottom: 1px solid"> {% block body %}
<th>{% trans "Part Name" %}</th> <tr style="height: 3rem; border-bottom: 1px solid">
<th>{% trans "Available Quantity" %}</th> <th>{% trans "Part Name" %}</th>
<th>{% trans "Minimum Quantity" %}</th> <th>{% trans "Available Quantity" %}</th>
</tr> <th>{% trans "Minimum Quantity" %}</th>
</tr>
<tr style="height: 3rem">
<td style="text-align: center;">{{ part.full_name }}</td>
<td style="text-align: center;">{{ part.total_stock }}</td>
<td style="text-align: center;">{{ part.minimum_stock }}</td>
</tr>
<tr style="background-color: aliceblue;height: 4rem;">
<td colspan="3" style="padding-top:1rem; text-align: center">
<p><em>{% blocktrans with part=part.name %}You are receiving this email because you are subscribed to notifications for this part {% endblocktrans %}.</em></p>
<p><em><small>{% trans "InvenTree version" %}: {% inventree_version %}</small></em></p>
</td>
</tr>
</table>
<tr style="height: 3rem">
<td style="text-align: center;">{{ part.full_name }}</td>
<td style="text-align: center;">{{ part.total_stock }}</td>
<td style="text-align: center;">{{ part.minimum_stock }}</td>
</tr>
{% endblock %}