settings UI integration

This commit is contained in:
Matthias 2021-09-17 22:47:49 +02:00
parent 682ee87267
commit 771c453c40
No known key found for this signature in database
GPG Key ID: F50EF5741D33E076
4 changed files with 72 additions and 0 deletions

View File

@ -0,0 +1,22 @@
# -*- coding: utf-8 -*-
""" This module provides template tags for handeling plugins
"""
from django.utils.translation import ugettext_lazy as _
from django.conf import settings as djangosettings
from django import template
register = template.Library()
@register.simple_tag()
def plugin_list(*args, **kwargs):
""" Return a list of all installed integration plugins """
return djangosettings.INTEGRATION_PLUGIN_LIST
@register.simple_tag()
def plugin_settings(plugin, *args, **kwargs):
""" Return a list of all settings for a plugin """
return djangosettings.INTEGRATION_PLUGIN_SETTING.get(plugin)

View File

@ -1,4 +1,5 @@
{% load i18n %} {% load i18n %}
{% load plugin_extras %}
<ul class='list-group'> <ul class='list-group'>
@ -116,6 +117,22 @@
</a> </a>
</li> </li>
<li class='list-group-item'>
<strong>{% trans "Plugin Settings" %}</strong>
</li>
{% plugin_list as pl_list %}
{% for plugin_key, plugin in pl_list.items %}
{% if plugin.has_settings %}
<li class='list-group-item' title='{{ plugin.plugin_name }}'>
<a href='#' class='nav-toggle' id='select-plugin-{{plugin_key}}'>
{{ plugin.plugin_name}}
</a>
</li>
{% endif %}
{% endfor %}
{% endif %} {% endif %}
</ul> </ul>

View File

@ -0,0 +1,25 @@
{% extends "panel.html" %}
{% load i18n %}
{% load inventree_extras %}
{% load plugin_extras %}
{% block label %}plugin-{{plugin_key}}{% endblock %}
{% block heading %}
{% blocktrans with name=plugin.plugin_name %}Plugin Settings for {{name}}{% endblocktrans %}
{% endblock %}
{% block content %}
{% plugin_settings plugin_key as plugin_settings %}
<table class='table table-striped table-condensed'>
{% include "InvenTree/settings/header.html" %}
<tbody>
{% for setting in plugin_settings %}
{% include "InvenTree/settings/setting.html" with key=setting%}
{% endfor %}
</tbody>
</table>
{% endblock %}

View File

@ -3,6 +3,7 @@
{% load i18n %} {% load i18n %}
{% load static %} {% load static %}
{% load inventree_extras %} {% load inventree_extras %}
{% load plugin_extras %}
{% block page_title %} {% block page_title %}
{% inventree_title %} | {% trans "Settings" %} {% inventree_title %} | {% trans "Settings" %}
@ -34,6 +35,13 @@
{% include "InvenTree/settings/po.html" %} {% include "InvenTree/settings/po.html" %}
{% include "InvenTree/settings/so.html" %} {% include "InvenTree/settings/so.html" %}
{% plugin_list as pl_list %}
{% for plugin_key, plugin in pl_list.items %}
{% if plugin.has_settings %}
{% include "InvenTree/settings/plugin_settings.html" %}
{% endif %}
{% endfor %}
{% endif %} {% endif %}
{% endblock %} {% endblock %}