diff --git a/src/backend/InvenTree/plugin/helpers.py b/src/backend/InvenTree/plugin/helpers.py index 4c78ff14e7..d3f45c4a19 100644 --- a/src/backend/InvenTree/plugin/helpers.py +++ b/src/backend/InvenTree/plugin/helpers.py @@ -10,7 +10,6 @@ import traceback from importlib.metadata import entry_points from importlib.util import module_from_spec -from django import template from django.conf import settings from django.core.exceptions import AppRegistryNotReady from django.db.utils import IntegrityError @@ -244,35 +243,3 @@ def get_plugins(pkg, baseclass, path=None): # 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.exception( - "Plugin %s could not locate template '%s'", plugin.slug, template_file - ) - - return f""" -
- Template file {template_file} does not exist. -
- """ - - # Render with the provided context - html = tmp.render(context) - - return html - - -def render_text(text, context=None): - """Locate a raw string with provided context.""" - ctx = template.Context(context) - - return template.Template(text).render(ctx) - - -# endregion diff --git a/src/backend/InvenTree/plugin/test_helpers.py b/src/backend/InvenTree/plugin/test_helpers.py deleted file mode 100644 index 95cff3ea95..0000000000 --- a/src/backend/InvenTree/plugin/test_helpers.py +++ /dev/null @@ -1,26 +0,0 @@ -"""Unit tests for helpers.py.""" - -from django.test import TestCase - -from .helpers import render_template - - -class HelperTests(TestCase): - """Tests for helpers.""" - - def test_render_template(self): - """Check if render_template helper works.""" - - class ErrorSource: - slug = 'sampleplg' - - # working sample - response = render_template(ErrorSource(), 'sample/sample.html', {'abc': 123}) - self.assertEqual(response, '

123

\n') - - # Wrong sample - response = render_template( - ErrorSource(), 'sample/wrongsample.html', {'abc': 123} - ) - self.assertIn('lert alert-block alert-danger', response) - self.assertIn('Template file sample/wrongsample.html', response)