diff --git a/InvenTree/plugin/base/barcodes/api.py b/InvenTree/plugin/base/barcodes/api.py index 8f7fdafdaa..657da84137 100644 --- a/InvenTree/plugin/base/barcodes/api.py +++ b/InvenTree/plugin/base/barcodes/api.py @@ -11,8 +11,8 @@ from rest_framework.views import APIView from InvenTree.helpers import hash_barcode from plugin import registry -from plugin.builtin.barcodes.inventree_barcode import ( - InvenTreeExternalBarcodePlugin, InvenTreeInternalBarcodePlugin) +from plugin.builtin.barcodes.inventree_barcode import \ + InvenTreeInternalBarcodePlugin from users.models import RuleSet @@ -56,7 +56,6 @@ class BarcodeScan(APIView): # Ensure that the default barcode handlers are run first plugins = [ InvenTreeInternalBarcodePlugin(), - InvenTreeExternalBarcodePlugin(), ] + registry.with_mixin('barcode') barcode_hash = hash_barcode(barcode_data) @@ -115,7 +114,6 @@ class BarcodeAssign(APIView): # Here we only check against 'InvenTree' plugins plugins = [ InvenTreeInternalBarcodePlugin(), - InvenTreeExternalBarcodePlugin(), ] # First check if the provided barcode matches an existing database entry @@ -133,7 +131,7 @@ class BarcodeAssign(APIView): valid_labels = [] - for model in InvenTreeExternalBarcodePlugin.get_supported_barcode_models(): + for model in InvenTreeInternalBarcodePlugin.get_supported_barcode_models(): label = model.barcode_model_type() valid_labels.append(label) @@ -188,7 +186,7 @@ class BarcodeUnassign(APIView): """Respond to a barcode unassign POST request""" # The following database models support assignment of third-party barcodes - supported_models = InvenTreeExternalBarcodePlugin.get_supported_barcode_models() + supported_models = InvenTreeInternalBarcodePlugin.get_supported_barcode_models() supported_labels = [model.barcode_model_type() for model in supported_models] model_names = ', '.join(supported_labels) diff --git a/InvenTree/plugin/builtin/barcodes/inventree_barcode.py b/InvenTree/plugin/builtin/barcodes/inventree_barcode.py index 4fbe20ca27..90d1b68521 100644 --- a/InvenTree/plugin/builtin/barcodes/inventree_barcode.py +++ b/InvenTree/plugin/builtin/barcodes/inventree_barcode.py @@ -63,6 +63,7 @@ class InvenTreeInternalBarcodePlugin(InvenTreeBarcodePlugin): """Builtin BarcodePlugin for matching and generating internal barcodes.""" NAME = "InvenTreeInternalBarcode" + TITLE = "Inventree Barcodes" def scan(self, barcode_data): """Scan a barcode against this plugin. @@ -83,6 +84,8 @@ class InvenTreeInternalBarcodePlugin(InvenTreeBarcodePlugin): if type(barcode_data) is not dict: return None + barcode_hash = hash_barcode(barcode_data) + # Look for various matches. First good match will be returned for model in self.get_supported_barcode_models(): label = model.barcode_model_type() @@ -93,22 +96,9 @@ class InvenTreeInternalBarcodePlugin(InvenTreeBarcodePlugin): except (ValueError, model.DoesNotExist): pass - -class InvenTreeExternalBarcodePlugin(InvenTreeBarcodePlugin): - """Builtin BarcodePlugin for matching arbitrary external barcodes.""" - - NAME = "InvenTreeExternalBarcode" - - def scan(self, barcode_data): - """Scan a barcode against this plugin. - - Here we are looking for a dict object which contains a reference to a particular InvenTree databse object - """ - + # If no "direct" hits are found, look for assigned third-party barcodes for model in self.get_supported_barcode_models(): - label = model.barcode_model_type() - - barcode_hash = hash_barcode(barcode_data) + label = model.get_barcode_model_type() instance = model.lookup_barcode(barcode_hash) diff --git a/InvenTree/plugin/plugin.py b/InvenTree/plugin/plugin.py index 17a98719e4..cefe59980a 100644 --- a/InvenTree/plugin/plugin.py +++ b/InvenTree/plugin/plugin.py @@ -108,7 +108,7 @@ class MetaBase: """Return True if this plugin is currently active.""" # Builtin plugins are always considered "active" - if self.is_builtin(): + if self.is_builtin: return True cfg = self.plugin_config() diff --git a/InvenTree/templates/InvenTree/settings/plugin.html b/InvenTree/templates/InvenTree/settings/plugin.html index 5f4d3af055..0eae518e26 100644 --- a/InvenTree/templates/InvenTree/settings/plugin.html +++ b/InvenTree/templates/InvenTree/settings/plugin.html @@ -58,14 +58,16 @@ {% plugin_list as pl_list %} + {% if pl_list %} +
{% trans 'Active plugins' %}
{% for plugin_key, plugin in pl_list.items %} {% include "InvenTree/settings/plugin_details.html" with plugin=plugin plugin_key=plugin_key %} {% endfor %} + {% endif %} {% inactive_plugin_list as in_pl_list %} {% if in_pl_list %} - -
{% trans 'Inactive plugins' %}
+
{% trans 'Inactive plugins' %}
{% for plugin_key, plugin in in_pl_list.items %} {% include "InvenTree/settings/plugin_details.html" with plugin=plugin plugin_key=plugin_key %} {% endfor %} diff --git a/InvenTree/templates/InvenTree/settings/plugin_details.html b/InvenTree/templates/InvenTree/settings/plugin_details.html index 9f25b7d8e5..109c1b6d5a 100644 --- a/InvenTree/templates/InvenTree/settings/plugin_details.html +++ b/InvenTree/templates/InvenTree/settings/plugin_details.html @@ -3,6 +3,12 @@ + {% if plugin.is_active %} + + {% else %} + + {% endif %} + {% if plugin.human_name %} {{ plugin.human_name }} {% elif plugin.name %} diff --git a/InvenTree/templates/InvenTree/settings/settings.html b/InvenTree/templates/InvenTree/settings/settings.html index f6d1e990ab..79862291ae 100644 --- a/InvenTree/templates/InvenTree/settings/settings.html +++ b/InvenTree/templates/InvenTree/settings/settings.html @@ -42,8 +42,6 @@ {% include "InvenTree/settings/po.html" %} {% include "InvenTree/settings/so.html" %} -{% plugins_enabled as plug %} -{% if plug %} {% include "InvenTree/settings/plugin.html" %} {% plugin_list as pl_list %} {% for plugin_key, plugin in pl_list.items %} @@ -51,7 +49,6 @@ {% include "InvenTree/settings/plugin_settings.html" %} {% endif %} {% endfor %} -{% endif %} {% endif %} diff --git a/InvenTree/templates/InvenTree/settings/sidebar.html b/InvenTree/templates/InvenTree/settings/sidebar.html index 620c589359..03e691e63d 100644 --- a/InvenTree/templates/InvenTree/settings/sidebar.html +++ b/InvenTree/templates/InvenTree/settings/sidebar.html @@ -51,8 +51,6 @@ {% trans "Sales Orders" as text %} {% include "sidebar_item.html" with label='sales-order' text=text icon="fa-truck" %} -{% plugins_enabled as plug %} -{% if plug %} {% include "sidebar_header.html" with text="Plugin Settings" %} {% include "sidebar_item.html" with label='plugin' text="Plugins" icon="fa-plug" %} @@ -62,6 +60,5 @@ {% include "sidebar_item.html" with label='plugin-'|add:plugin_key text=plugin.human_name %} {% endif %} {% endfor %} -{% endif %} {% endif %}