From c222b9c296f85ce5df3d96ad7c6d462a2e3531ba Mon Sep 17 00:00:00 2001 From: Matthias Date: Sun, 19 Sep 2021 14:46:32 +0200 Subject: [PATCH] Some sample code for internal testing --- InvenTree/plugins/integration/__init__.py | 0 .../plugins/integration/another_sample.py | 20 +++++++ InvenTree/plugins/integration/sample.py | 58 +++++++++++++++++++ 3 files changed, 78 insertions(+) create mode 100644 InvenTree/plugins/integration/__init__.py create mode 100644 InvenTree/plugins/integration/another_sample.py create mode 100644 InvenTree/plugins/integration/sample.py diff --git a/InvenTree/plugins/integration/__init__.py b/InvenTree/plugins/integration/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/InvenTree/plugins/integration/another_sample.py b/InvenTree/plugins/integration/another_sample.py new file mode 100644 index 0000000000..28d7cf5249 --- /dev/null +++ b/InvenTree/plugins/integration/another_sample.py @@ -0,0 +1,20 @@ +from plugins.integration.integration import * + +from django.http import HttpResponse +from django.utils.translation import ugettext_lazy as _ + + +class NoIntegrationPlugin(IntegrationPlugin): + """ + An basic integration plugin + """ + + PLUGIN_NAME = "NoIntegrationPlugin" + + +class WrongIntegrationPlugin(UrlsMixin, IntegrationPlugin): + """ + An basic integration plugin + """ + + PLUGIN_NAME = "WrongIntegrationPlugin" diff --git a/InvenTree/plugins/integration/sample.py b/InvenTree/plugins/integration/sample.py new file mode 100644 index 0000000000..8ade4373bb --- /dev/null +++ b/InvenTree/plugins/integration/sample.py @@ -0,0 +1,58 @@ +from plugins.integration.integration import * + +from django.http import HttpResponse +from django.utils.translation import ugettext_lazy as _ + + +class SimpleIntegrationPlugin(SettingsMixin, UrlsMixin, IntegrationPlugin): + """ + An basic integration plugin + """ + + PLUGIN_NAME = "SimpleIntegrationPlugin" + + def view_test(self, request): + return HttpResponse(f'Hi there {request.user.username} this works') + + def setup_urls(self): + he = [ + url(r'^he/', self.view_test, name='he'), + url(r'^ha/', self.view_test, name='ha'), + ] + + return [ + url(r'^hi/', self.view_test, name='hi'), + url(r'^ho/', include(he), name='ho'), + ] + + SETTINGS = { + 'PO_FUNCTION_ENABLE': { + 'name': _('Enable PO'), + 'description': _('Enable PO functionality in InvenTree interface'), + 'default': True, + 'validator': bool, + }, + } + + +class OtherIntegrationPlugin(UrlsMixin, IntegrationPlugin): + """ + An basic integration plugin + """ + + PLUGIN_NAME = "OtherIntegrationPlugin" + + # @cls_login_required() + def view_test(self, request): + return HttpResponse(f'Hi there {request.user.username} this works') + + def setup_urls(self): + he = [ + url(r'^he/', self.view_test, name='he'), + url(r'^ha/', self.view_test, name='ha'), + ] + + return [ + url(r'^hi/', self.view_test, name='hi'), + url(r'^ho/', include(he), name='ho'), + ]