Some sample code for internal testing

This commit is contained in:
Matthias 2021-09-19 14:46:32 +02:00
parent 896b676a66
commit c222b9c296
No known key found for this signature in database
GPG Key ID: F50EF5741D33E076
3 changed files with 78 additions and 0 deletions

View File

@ -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"

View File

@ -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'),
]