mixin_enabled check for templates

This commit is contained in:
Matthias 2021-09-18 04:46:50 +02:00
parent 1c781d9bf0
commit 3b2cb43ece
No known key found for this signature in database
GPG Key ID: F50EF5741D33E076
3 changed files with 19 additions and 4 deletions

View File

@ -19,3 +19,9 @@ def plugin_list(*args, **kwargs):
def plugin_settings(plugin, *args, **kwargs): def plugin_settings(plugin, *args, **kwargs):
""" Return a list of all settings for a plugin """ """ Return a list of all settings for a plugin """
return djangosettings.INTEGRATION_PLUGIN_SETTING.get(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)

View File

@ -25,12 +25,15 @@
<tbody> <tbody>
{% plugin_list as pl_list %} {% plugin_list as pl_list %}
{% for plugin_key, plugin in pl_list.items %} {% for plugin_key, plugin in pl_list.items %}
{% mixin_enabled plugin 'urls' as urls %}
{% mixin_enabled plugin 'settings' as settings %}
<tr> <tr>
<td>{{plugin_key}} - {{ plugin.plugin_name}} <td>{{plugin_key}} - {{ plugin.plugin_name}}
{% if plugin.has_urls %} {% if urls %}
<span class='badge'><a class='nav-toggle text-success' id='select-plugin-{{plugin_key}}'>{% trans 'Has urls' %}</a></span> <span class='badge'><a class='nav-toggle text-success' id='select-plugin-{{plugin_key}}'>{% trans 'Has urls' %}</a></span>
{% endif %} {% endif %}
{% if plugin.has_settings %} {% if settings %}
<span class='badge'><a class='nav-toggle text-success' id='select-plugin-{{plugin_key}}'>{% trans 'Has settings' %}</a></span> <span class='badge'><a class='nav-toggle text-success' id='select-plugin-{{plugin_key}}'>{% trans 'Has settings' %}</a></span>
{% endif %} {% endif %}
</td> </td>

View File

@ -7,10 +7,14 @@
{% block heading %} {% 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 %} {% endblock %}
{% block content %} {% block content %}
{% mixin_enabled plugin 'settings' as settings %}
{% if settings %}
<h4>{% trans "Settings" %}</h4>
{% plugin_settings plugin_key as plugin_settings %} {% plugin_settings plugin_key as plugin_settings %}
<table class='table table-striped table-condensed'> <table class='table table-striped table-condensed'>
@ -21,8 +25,10 @@
{% endfor %} {% endfor %}
</tbody> </tbody>
</table> </table>
{% endif %}
{% if plugin.has_urls %} {% mixin_enabled plugin 'urls' as urls %}
{% if urls %}
<h4>{% trans "URLs" %}</h4> <h4>{% trans "URLs" %}</h4>
{% define plugin.base_url as base %} {% define plugin.base_url as base %}
<p>{% blocktrans %}The Base-URL for this plugin is <a href="/{{ base }}" target="_blank"><strong>{{ base }}</strong></a>.{% endblocktrans %}</p> <p>{% blocktrans %}The Base-URL for this plugin is <a href="/{{ base }}" target="_blank"><strong>{{ base }}</strong></a>.{% endblocktrans %}</p>