diff --git a/InvenTree/plugins/integration/integration.py b/InvenTree/plugins/integration/integration.py index 651abeb928..5690dfe2be 100644 --- a/InvenTree/plugins/integration/integration.py +++ b/InvenTree/plugins/integration/integration.py @@ -73,6 +73,27 @@ class UrlsMixin: does this plugin use custom urls """ return bool(self.urls) + + +class NavigationMixin: + """Mixin that enables adding navigation links with the plugin""" + def __init__(self): + super().__init__() + self.add_mixin('navigation', 'has_naviation') + self.navigation = self.setup_navigation() + + def setup_navigation(self): + """ + setup navigation links for this plugin + """ + return getattr(self, 'NAVIGATION', None) + + @property + def has_naviation(self): + """ + does this plugin define navigation elements + """ + return bool(self.navigation) # endregion diff --git a/InvenTree/plugins/integration/sample.py b/InvenTree/plugins/integration/sample.py index 86e0cf0eea..9096482648 100644 --- a/InvenTree/plugins/integration/sample.py +++ b/InvenTree/plugins/integration/sample.py @@ -4,7 +4,7 @@ from django.http import HttpResponse from django.utils.translation import ugettext_lazy as _ -class SampleIntegrationPlugin(SettingsMixin, UrlsMixin, IntegrationPlugin): +class SampleIntegrationPlugin(SettingsMixin, UrlsMixin, NavigationMixin, IntegrationPlugin): """ An full integration plugin """ @@ -34,6 +34,10 @@ class SampleIntegrationPlugin(SettingsMixin, UrlsMixin, IntegrationPlugin): }, } + NAVIGATION= [ + {'name': 'SampleIntegration', 'link': 'SampleIntegrationPlugin:hi'}, + ] + class OtherIntegrationPlugin(UrlsMixin, IntegrationPlugin): """ diff --git a/InvenTree/templates/navbar.html b/InvenTree/templates/navbar.html index b109bd9daf..369218b524 100644 --- a/InvenTree/templates/navbar.html +++ b/InvenTree/templates/navbar.html @@ -1,5 +1,6 @@ {% load static %} {% load inventree_extras %} +{% load plugin_extras %} {% load i18n %} {% settings_value 'BARCODE_ENABLE' as barcodes %} @@ -57,6 +58,23 @@ {% endif %} + + {% plugin_list as pl_list %} + {% for plugin_key, plugin in pl_list.items %} + {% mixin_enabled plugin 'navigation' as navigation %} + {% if navigation %} + +