change templates to new way

This commit is contained in:
Matthias 2021-12-04 02:19:12 +01:00
parent febc51466a
commit 1ba7110cda
No known key found for this signature in database
GPG Key ID: F50EF5741D33E076
2 changed files with 6 additions and 3 deletions

View File

@ -16,13 +16,16 @@ logger = logging.getLogger("inventree")
def notify_low_stock(part: part.models.Part): def notify_low_stock(part: part.models.Part):
name = _("Low stock notification")
message = _(f'The available stock for {part.name} has fallen below the configured minimum level')
context = { context = {
# Pass the "Part" object through to the template context
'part': part, 'part': part,
'name': name,
'message': message,
'link': InvenTree.helpers.construct_absolute_url(part.get_absolute_url()), 'link': InvenTree.helpers.construct_absolute_url(part.get_absolute_url()),
'template': { 'template': {
'html': 'email/low_stock_notification.html', 'html': 'email/low_stock_notification.html',
'subject': "[InvenTree] " + _("Low stock notification"), 'subject': "[InvenTree] " + name,
}, },
} }

View File

@ -4,7 +4,7 @@
{% load inventree_extras %} {% load inventree_extras %}
{% block title %} {% block title %}
{% blocktrans with part=part.name %} The available stock for {{ part }} has fallen below the configured minimum level{% endblocktrans %} {{ message }}
{% if link %} {% if link %}
<p>{% trans "Click on the following link to view this part" %}: <a href="{{ link }}">{{ link }}</a></p> <p>{% trans "Click on the following link to view this part" %}: <a href="{{ link }}">{{ link }}</a></p>
{% endif %} {% endif %}