2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-17 20:45:44 +00:00

refactor of file structure

This commit is contained in:
Matthias
2021-09-26 14:47:45 +02:00
parent 7393834a79
commit 7a551bf9d1
8 changed files with 6 additions and 7 deletions

View File

@ -0,0 +1,25 @@
# -*- coding: utf-8 -*-
"""sample implementation for ActionPlugin"""
from plugins.action.action import ActionPlugin
class SimpleActionPlugin(ActionPlugin):
"""
An EXTREMELY simple action plugin which demonstrates
the capability of the ActionPlugin class
"""
PLUGIN_NAME = "SimpleActionPlugin"
ACTION_NAME = "simple"
def perform_action(self):
print("Action plugin in action!")
def get_info(self):
return {
"user": self.user.username,
"hello": "world",
}
def get_result(self):
return True

View File

@ -0,0 +1,18 @@
"""sample implementation for IntegrationPlugin"""
from plugins.integration import IntegrationPlugin, UrlsMixin
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,42 @@
"""sample implementations for IntegrationPlugin"""
from plugins.integration import SettingsMixin, UrlsMixin, NavigationMixin, IntegrationPlugin
from django.http import HttpResponse
from django.utils.translation import ugettext_lazy as _
from django.conf.urls import url, include
class SampleIntegrationPlugin(SettingsMixin, UrlsMixin, NavigationMixin, IntegrationPlugin):
"""
An full integration plugin
"""
PLUGIN_NAME = "SampleIntegrationPlugin"
def view_test(self, request):
"""very basic view"""
return HttpResponse(f'Hi there {request.user.username} this works')
def setup_urls(self):
he_urls = [
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_urls), name='ho'),
]
SETTINGS = {
'PO_FUNCTION_ENABLE': {
'name': _('Enable PO'),
'description': _('Enable PO functionality in InvenTree interface'),
'default': True,
'validator': bool,
},
}
NAVIGATION = [
{'name': 'SampleIntegration', 'link': 'plugin:SampleIntegrationPlugin:hi'},
]