diff --git a/InvenTree/plugin/base/integration/mixins.py b/InvenTree/plugin/base/integration/mixins.py index 5bae993e61..32bdd00681 100644 --- a/InvenTree/plugin/base/integration/mixins.py +++ b/InvenTree/plugin/base/integration/mixins.py @@ -11,9 +11,8 @@ from django.db.utils import OperationalError, ProgrammingError import InvenTree.helpers -from plugin.helpers import MixinImplementationError, MixinNotImplementedError +from plugin.helpers import MixinImplementationError, MixinNotImplementedError, render_template from plugin.models import PluginConfig, PluginSetting -from plugin.template import render_template from plugin.urls import PLUGIN_BASE diff --git a/InvenTree/plugin/helpers.py b/InvenTree/plugin/helpers.py index f1753b1b45..011a8f84f0 100644 --- a/InvenTree/plugin/helpers.py +++ b/InvenTree/plugin/helpers.py @@ -8,12 +8,17 @@ import sysconfig import traceback import inspect import pkgutil +import logging +from django import template from django.conf import settings from django.core.exceptions import AppRegistryNotReady from django.db.utils import IntegrityError +logger = logging.getLogger('inventree') + + # region logging / errors class IntegrationPluginError(Exception): """ @@ -217,3 +222,26 @@ def get_plugins(pkg, baseclass): return plugins # endregion + +# region templates +def render_template(plugin, template_file, context=None): + """ + Locate and render a template file, available in the global template context. + """ + + try: + tmp = template.loader.get_template(template_file) + except template.TemplateDoesNotExist: + logger.error(f"Plugin {plugin.slug} could not locate template '{template_file}'") + + return f""" +