diff --git a/InvenTree/plugin/templatetags/plugin_extras.py b/InvenTree/plugin/templatetags/plugin_extras.py index a30f7ec2e4..fbd6c483ae 100644 --- a/InvenTree/plugin/templatetags/plugin_extras.py +++ b/InvenTree/plugin/templatetags/plugin_extras.py @@ -44,6 +44,12 @@ def mixin_enabled(plugin, key, *args, **kwargs): """ return plugin.mixin_enabled(key) +@register.simple_tag() +def mixin_available(mixin, *args, **kwargs): + """ + Returns True if there is at least one active plugin which supports the provided mixin + """ + return len(registry.with_mixin(mixin)) > 0 @register.simple_tag() def navigation_enabled(*args, **kwargs): diff --git a/InvenTree/stock/templates/stock/item_base.html b/InvenTree/stock/templates/stock/item_base.html index 944e432026..2d7877acf4 100644 --- a/InvenTree/stock/templates/stock/item_base.html +++ b/InvenTree/stock/templates/stock/item_base.html @@ -1,5 +1,6 @@ {% extends "page_base.html" %} {% load static %} +{% load plugin_extras %} {% load inventree_extras %} {% load status_codes %} {% load i18n %} @@ -18,7 +19,6 @@ {% endblock breadcrumb_tree %} - {% block heading %} {% trans "Stock Item" %}: {{ item.part.full_name}} {% endblock heading %} @@ -29,6 +29,12 @@ {% url 'admin:stock_stockitem_change' item.pk as url %} {% include "admin_button.html" with url=url %} {% endif %} +{% mixin_available "locate" as locate_available %} +{% if plugins_enabled and locate_available %} + +{% endif %} {% if barcodes %}
diff --git a/InvenTree/stock/templates/stock/location.html b/InvenTree/stock/templates/stock/location.html index 61320a2676..1e4f144107 100644 --- a/InvenTree/stock/templates/stock/location.html +++ b/InvenTree/stock/templates/stock/location.html @@ -1,6 +1,7 @@ {% extends "stock/stock_app_base.html" %} {% load static %} {% load inventree_extras %} +{% load plugin_extras %} {% load i18n %} {% block sidebar %} @@ -27,6 +28,14 @@ {% include "admin_button.html" with url=url %} {% endif %} +{% mixin_available "locate" as locate_available %} +{% if plugins_enabled and locate_available %} + + +{% endif %} + {% if barcodes %} {% if location %} diff --git a/InvenTree/templates/base.html b/InvenTree/templates/base.html index 0d8272892a..795a5679aa 100644 --- a/InvenTree/templates/base.html +++ b/InvenTree/templates/base.html @@ -2,6 +2,7 @@ {% load i18n %} {% load inventree_extras %} +{% plugins_enabled as plugins_enabled %} {% settings_value 'BARCODE_ENABLE' as barcodes %} {% settings_value 'REPORT_ENABLE_TEST_REPORT' as test_report_enabled %} {% settings_value "REPORT_ENABLE" as report_enabled %}