mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
url integration
This commit is contained in:
parent
9f3862ab27
commit
d5f022f2cb
@ -48,6 +48,8 @@ from common.views import SettingEdit, UserSettingEdit
|
||||
from .api import InfoView, NotFoundView
|
||||
from .api import ActionPluginView
|
||||
|
||||
from plugins import plugins as inventree_plugins
|
||||
|
||||
from users.api import user_urls
|
||||
|
||||
admin.site.site_header = "InvenTree Admin"
|
||||
@ -125,6 +127,15 @@ translated_javascript_urls = [
|
||||
url(r'^table_filters.js', DynamicJsView.as_view(template_name='js/translated/table_filters.js'), name='table_filters.js'),
|
||||
]
|
||||
|
||||
# Integration plugin urls
|
||||
integration_plugins = inventree_plugins.load_integration_plugins()
|
||||
interation_urls = []
|
||||
for plugin in integration_plugins:
|
||||
# initialize
|
||||
plugin = plugin()
|
||||
if plugin.has_urls:
|
||||
interation_urls.append(plugin.urlpatterns)
|
||||
|
||||
urlpatterns = [
|
||||
url(r'^part/', include(part_urls)),
|
||||
url(r'^manufacturer-part/', include(manufacturer_part_urls)),
|
||||
@ -167,6 +178,9 @@ urlpatterns = [
|
||||
url(r'^api/', include(apipatterns)),
|
||||
url(r'^api-doc/', include_docs_urls(title='InvenTree API')),
|
||||
|
||||
# plugins
|
||||
url(r'^plugin/', include(interation_urls)),
|
||||
|
||||
url(r'^markdownx/', include('markdownx.urls')),
|
||||
]
|
||||
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
import logging
|
||||
|
||||
from django.conf.urls import url, include
|
||||
import plugins.plugin as plugin
|
||||
|
||||
|
||||
@ -28,6 +29,15 @@ class IntegrationPlugin(plugin.InvenTreePlugin):
|
||||
return self.urlpatterns
|
||||
return None
|
||||
|
||||
@property
|
||||
def urlpatterns(self):
|
||||
"""
|
||||
retruns the urlpatterns for this plugin
|
||||
"""
|
||||
if self.has_urls:
|
||||
return url(f'^{self.plugin_name()}/', include(self.urls), name=self.plugin_name())
|
||||
return None
|
||||
|
||||
@property
|
||||
def has_urls(self):
|
||||
"""
|
||||
|
@ -9,6 +9,9 @@ import logging
|
||||
import plugins.action as action
|
||||
from plugins.action.action import ActionPlugin
|
||||
|
||||
import plugins.integration as integration
|
||||
from plugins.integration.integration import IntegrationPlugin
|
||||
|
||||
|
||||
logger = logging.getLogger("inventree")
|
||||
|
||||
@ -78,3 +81,10 @@ def load_action_plugins():
|
||||
Return a list of all registered action plugins
|
||||
"""
|
||||
return load_plugins('action', action, ActionPlugin)
|
||||
|
||||
|
||||
def load_integration_plugins():
|
||||
"""
|
||||
Return a list of all registered integration plugins
|
||||
"""
|
||||
return load_plugins('integration', integration, IntegrationPlugin)
|
||||
|
Loading…
Reference in New Issue
Block a user