Skip to content

Commit

Permalink
[FR] Add plugin keys, state and version to version info (#3496)
Browse files Browse the repository at this point in the history
* [FR] Add plugin keys, state and version  to version info
Fixes #3477

* Add info to general API endpoint
  • Loading branch information
matmair authored Aug 7, 2022
1 parent a77f21b commit 6c55874
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
2 changes: 2 additions & 0 deletions InvenTree/InvenTree/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

from InvenTree.mixins import ListCreateAPI
from InvenTree.permissions import RolePermission
from part.templatetags.inventree_extras import plugins_info

from .status import is_worker_running
from .version import (inventreeApiVersion, inventreeInstanceName,
Expand All @@ -36,6 +37,7 @@ def get(self, request, *args, **kwargs):
'apiVersion': inventreeApiVersion(),
'worker_running': is_worker_running(),
'plugins_enabled': settings.PLUGINS_ENABLED,
'active_plugins': plugins_info(),
}

return JsonResponse(data)
Expand Down
20 changes: 20 additions & 0 deletions InvenTree/part/templatetags/inventree_extras.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from common.models import ColorTheme, InvenTreeSetting, InvenTreeUserSetting
from common.settings import currency_code_default
from InvenTree import settings, version
from plugin import registry
from plugin.models import NotificationUserSetting, PluginSetting

register = template.Library()
Expand Down Expand Up @@ -149,6 +150,25 @@ def plugins_enabled(*args, **kwargs):
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()
def inventree_db_engine(*args, **kwargs):
"""Return the InvenTree database backend e.g. 'postgresql'."""
Expand Down
1 change: 1 addition & 0 deletions InvenTree/templates/version.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
Database: {% inventree_db_engine %}
Debug-Mode: {% inventree_in_debug_mode %}
Deployed using Docker: {% inventree_docker_mode %}
Active plugins: {% plugins_info %}

0 comments on commit 6c55874

Please sign in to comment.