mirror of
https://github.com/inventree/InvenTree.git
synced 2025-05-16 03:53:07 +00:00
[FR] Add plugin keys, state and version to version info (#3496)
* [FR] Add plugin keys, state and version to version info Fixes #3477 * Add info to general API endpoint
This commit is contained in:
parent
a77f21b17e
commit
6c55874dd1
@ -12,6 +12,7 @@ from rest_framework.serializers import ValidationError
|
|||||||
|
|
||||||
from InvenTree.mixins import ListCreateAPI
|
from InvenTree.mixins import ListCreateAPI
|
||||||
from InvenTree.permissions import RolePermission
|
from InvenTree.permissions import RolePermission
|
||||||
|
from part.templatetags.inventree_extras import plugins_info
|
||||||
|
|
||||||
from .status import is_worker_running
|
from .status import is_worker_running
|
||||||
from .version import (inventreeApiVersion, inventreeInstanceName,
|
from .version import (inventreeApiVersion, inventreeInstanceName,
|
||||||
@ -36,6 +37,7 @@ class InfoView(AjaxView):
|
|||||||
'apiVersion': inventreeApiVersion(),
|
'apiVersion': inventreeApiVersion(),
|
||||||
'worker_running': is_worker_running(),
|
'worker_running': is_worker_running(),
|
||||||
'plugins_enabled': settings.PLUGINS_ENABLED,
|
'plugins_enabled': settings.PLUGINS_ENABLED,
|
||||||
|
'active_plugins': plugins_info(),
|
||||||
}
|
}
|
||||||
|
|
||||||
return JsonResponse(data)
|
return JsonResponse(data)
|
||||||
|
@ -17,6 +17,7 @@ import InvenTree.helpers
|
|||||||
from common.models import ColorTheme, InvenTreeSetting, InvenTreeUserSetting
|
from common.models import ColorTheme, InvenTreeSetting, InvenTreeUserSetting
|
||||||
from common.settings import currency_code_default
|
from common.settings import currency_code_default
|
||||||
from InvenTree import settings, version
|
from InvenTree import settings, version
|
||||||
|
from plugin import registry
|
||||||
from plugin.models import NotificationUserSetting, PluginSetting
|
from plugin.models import NotificationUserSetting, PluginSetting
|
||||||
|
|
||||||
register = template.Library()
|
register = template.Library()
|
||||||
@ -149,6 +150,25 @@ def plugins_enabled(*args, **kwargs):
|
|||||||
return djangosettings.PLUGINS_ENABLED
|
return djangosettings.PLUGINS_ENABLED
|
||||||
|
|
||||||
|
|
||||||
|
@register.simple_tag()
|
||||||
|
def plugins_info(*args, **kwargs):
|
||||||
|
"""Return information about activated plugins."""
|
||||||
|
# Check if plugins are even enabled
|
||||||
|
if not djangosettings.PLUGINS_ENABLED:
|
||||||
|
return False
|
||||||
|
|
||||||
|
# Fetch plugins
|
||||||
|
plug_list = [plg for plg in registry.plugins.values() if plg.plugin_config().active]
|
||||||
|
# Format list
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
'name': plg.name,
|
||||||
|
'slug': plg.slug,
|
||||||
|
'version': plg.version
|
||||||
|
} for plg in plug_list
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
@register.simple_tag()
|
@register.simple_tag()
|
||||||
def inventree_db_engine(*args, **kwargs):
|
def inventree_db_engine(*args, **kwargs):
|
||||||
"""Return the InvenTree database backend e.g. 'postgresql'."""
|
"""Return the InvenTree database backend e.g. 'postgresql'."""
|
||||||
|
@ -6,3 +6,4 @@ Django Version: {% django_version %}
|
|||||||
Database: {% inventree_db_engine %}
|
Database: {% inventree_db_engine %}
|
||||||
Debug-Mode: {% inventree_in_debug_mode %}
|
Debug-Mode: {% inventree_in_debug_mode %}
|
||||||
Deployed using Docker: {% inventree_docker_mode %}
|
Deployed using Docker: {% inventree_docker_mode %}
|
||||||
|
Active plugins: {% plugins_info %}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user