From 3b2cb43ece01de30c4c1e070b46440946a3c1695 Mon Sep 17 00:00:00 2001 From: Matthias Date: Sat, 18 Sep 2021 04:46:50 +0200 Subject: [PATCH] mixin_enabled check for templates --- InvenTree/part/templatetags/plugin_extras.py | 6 ++++++ InvenTree/templates/InvenTree/settings/plugin.html | 7 +++++-- .../templates/InvenTree/settings/plugin_settings.html | 10 ++++++++-- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/InvenTree/part/templatetags/plugin_extras.py b/InvenTree/part/templatetags/plugin_extras.py index f400ab94ad..6f214340f7 100644 --- a/InvenTree/part/templatetags/plugin_extras.py +++ b/InvenTree/part/templatetags/plugin_extras.py @@ -19,3 +19,9 @@ def plugin_list(*args, **kwargs): def plugin_settings(plugin, *args, **kwargs): """ Return a list of all settings for a plugin """ return djangosettings.INTEGRATION_PLUGIN_SETTING.get(plugin) + + +@register.simple_tag() +def mixin_enabled(plugin, key, *args, **kwargs): + """ Return if the mixin is existant and configured in the plugin """ + return plugin.mixin_enabled(key) diff --git a/InvenTree/templates/InvenTree/settings/plugin.html b/InvenTree/templates/InvenTree/settings/plugin.html index 688cb19c45..44b486abae 100644 --- a/InvenTree/templates/InvenTree/settings/plugin.html +++ b/InvenTree/templates/InvenTree/settings/plugin.html @@ -25,12 +25,15 @@ {% plugin_list as pl_list %} {% for plugin_key, plugin in pl_list.items %} + {% mixin_enabled plugin 'urls' as urls %} + {% mixin_enabled plugin 'settings' as settings %} + {{plugin_key}} - {{ plugin.plugin_name}} - {% if plugin.has_urls %} + {% if urls %} {% trans 'Has urls' %} {% endif %} - {% if plugin.has_settings %} + {% if settings %} {% trans 'Has settings' %} {% endif %} diff --git a/InvenTree/templates/InvenTree/settings/plugin_settings.html b/InvenTree/templates/InvenTree/settings/plugin_settings.html index 7d9ff83de6..4f0d6d7f35 100644 --- a/InvenTree/templates/InvenTree/settings/plugin_settings.html +++ b/InvenTree/templates/InvenTree/settings/plugin_settings.html @@ -7,10 +7,14 @@ {% block heading %} -{% blocktrans with name=plugin.plugin_name %}Plugin Settings for {{name}}{% endblocktrans %} +{% blocktrans with name=plugin.plugin_name %}Plugin details for {{name}}{% endblocktrans %} {% endblock %} {% block content %} + +{% mixin_enabled plugin 'settings' as settings %} +{% if settings %} +

{% trans "Settings" %}

{% plugin_settings plugin_key as plugin_settings %} @@ -21,8 +25,10 @@ {% endfor %}
+{% endif %} -{% if plugin.has_urls %} +{% mixin_enabled plugin 'urls' as urls %} +{% if urls %}

{% trans "URLs" %}

{% define plugin.base_url as base %}

{% blocktrans %}The Base-URL for this plugin is {{ base }}.{% endblocktrans %}