InvenTree/InvenTree/plugin/samples/integration/sample.py

49 lines
1.4 KiB
Python
Raw Normal View History

2021-09-24 23:22:48 +00:00
"""sample implementations for IntegrationPlugin"""
2021-11-15 23:40:49 +00:00
from plugin.integration import IntegrationPluginBase
from plugin.builtin.integration.mixins import AppMixin, GlobalSettingsMixin, UrlsMixin, NavigationMixin
2021-09-19 12:46:32 +00:00
from django.http import HttpResponse
from django.utils.translation import ugettext_lazy as _
2021-09-19 21:38:27 +00:00
from django.conf.urls import url, include
2021-09-19 12:46:32 +00:00
2021-11-13 23:24:32 +00:00
class SampleIntegrationPlugin(AppMixin, GlobalSettingsMixin, UrlsMixin, NavigationMixin, IntegrationPluginBase):
2021-09-19 12:46:32 +00:00
"""
2021-09-19 12:54:55 +00:00
An full integration plugin
2021-09-19 12:46:32 +00:00
"""
2021-09-19 12:54:55 +00:00
PLUGIN_NAME = "SampleIntegrationPlugin"
2021-10-04 10:06:27 +00:00
PLUGIN_SLUG = "sample"
2021-10-04 10:31:31 +00:00
PLUGIN_TITLE = "Sample Plugin"
2021-09-19 12:46:32 +00:00
2021-10-04 17:25:42 +00:00
NAVIGATION_TAB_NAME = "Sample Nav"
2021-10-04 17:40:55 +00:00
NAVIGATION_TAB_ICON = 'fas fa-plus'
2021-10-04 17:25:42 +00:00
2021-09-19 12:46:32 +00:00
def view_test(self, request):
2021-09-24 23:22:48 +00:00
"""very basic view"""
2021-09-19 12:46:32 +00:00
return HttpResponse(f'Hi there {request.user.username} this works')
def setup_urls(self):
2021-09-24 23:30:05 +00:00
he_urls = [
2021-09-19 12:46:32 +00:00
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'),
2021-09-24 23:30:05 +00:00
url(r'^ho/', include(he_urls), name='ho'),
2021-09-19 12:46:32 +00:00
]
SETTINGS = {
'PO_FUNCTION_ENABLE': {
'name': _('Enable PO'),
'description': _('Enable PO functionality in InvenTree interface'),
'default': True,
'validator': bool,
},
}
2021-09-19 21:38:27 +00:00
NAVIGATION = [
2021-10-04 05:59:07 +00:00
{'name': 'SampleIntegration', 'link': 'plugin:sample:hi'},
2021-09-19 14:27:43 +00:00
]