Coverage for src/backend/InvenTree/plugin/templatetags/plugin_extras.py: 64%
25 statements
« prev ^ index » next coverage.py v7.15.2, created at 2026-10-07 17:47 +0000
« prev ^ index » next coverage.py v7.15.2, created at 2026-10-07 17:47 +0000
1"""This module provides template tags for handling plugins."""
3from django import template
4from django.urls import reverse
6from plugin.registry import registry
8register = template.Library()
11@register.simple_tag()
12def plugin_list(*args, **kwargs):
13 """List of all installed plugins."""
14 return registry.plugins
17@register.simple_tag()
18def inactive_plugin_list(*args, **kwargs):
19 """List of all inactive plugins."""
20 return registry.plugins_inactive
23@register.simple_tag()
24def plugin_settings(plugin, *args, **kwargs):
25 """List of all settings for the plugin."""
26 return registry.mixins_settings.get(plugin)
29@register.simple_tag()
30def mixin_enabled(plugin, key, *args, **kwargs):
31 """Is the mixin registered and configured in the plugin?"""
32 return plugin.mixin_enabled(key)
35@register.simple_tag()
36def mixin_available(mixin: str, *args, **kwargs) -> bool:
37 """Returns True if there is at least one active plugin which supports the provided mixin."""
38 return len(registry.with_mixin(mixin)) > 0
41@register.simple_tag()
42def safe_url(view_name, *args, **kwargs):
43 """Safe lookup fnc for URLs.
45 Returns None if not found
46 """
47 try:
48 return reverse(view_name, args=args, kwargs=kwargs)
49 except Exception:
50 return None