diff --git a/InvenTree/InvenTree/api.py b/InvenTree/InvenTree/api.py index d5c9e6b38e..bcec1f4a5d 100644 --- a/InvenTree/InvenTree/api.py +++ b/InvenTree/InvenTree/api.py @@ -138,7 +138,7 @@ class LocatePluginView(APIView): # Which plugin to we wish to use? plugin = request.data.get('plugin', None) - + if not plugin: raise ParseError("'plugin' field must be supplied") @@ -146,10 +146,10 @@ class LocatePluginView(APIView): plugins = registry.with_mixin('locate') if plugin not in [p.slug for p in plugins]: - raise ParseError(f"Plugin '{plugin}' is not installed, or does not support the location mixin") + raise ParseError(f"Plugin '{plugin}' is not installed, or does not support the location mixin") # StockItem to identify - item_pk= request.data.get('item', None) + item_pk = request.data.get('item', None) # StockLocation to identify location_pk = request.data.get('location', None) @@ -165,7 +165,7 @@ class LocatePluginView(APIView): # StockItem takes priority if item_pk: try: - item = StockItem.objects.get(pk=item_pk) + StockItem.objects.get(pk=item_pk) offload_task('plugin.registry.call_function', plugin, 'locate_stock_item', item_pk) @@ -175,10 +175,10 @@ class LocatePluginView(APIView): except StockItem.DoesNotExist: raise NotFound("StockItem matching PK '{item}' not found") - + elif location_pk: try: - location = StockLocation.objects.get(pk=location_pk) + StockLocation.objects.get(pk=location_pk) offload_task('plugin.registry.call_function', plugin, 'locate_stock_location', location_pk) diff --git a/InvenTree/plugin/api.py b/InvenTree/plugin/api.py index 29e8e4c603..22df8f2ac3 100644 --- a/InvenTree/plugin/api.py +++ b/InvenTree/plugin/api.py @@ -47,7 +47,7 @@ class PluginList(generics.ListAPIView): for result in queryset: if mixin in result.mixins().keys(): matches.append(result.pk) - + queryset = queryset.filter(pk__in=matches) return queryset diff --git a/InvenTree/plugin/builtin/integration/mixins.py b/InvenTree/plugin/builtin/integration/mixins.py index fc8bcce296..3bde6f217d 100644 --- a/InvenTree/plugin/builtin/integration/mixins.py +++ b/InvenTree/plugin/builtin/integration/mixins.py @@ -453,11 +453,11 @@ class LocateMixin: class MixinMeta: MIXIN_NAME = "Locate" - + def __init__(self): super().__init__() self.add_mixin('locate', True, __class__) - + def locate_stock_item(self, item_pk): """ Attempt to locate a particular StockItem @@ -490,10 +490,10 @@ class LocateMixin: def locate_stock_location(self, location_pk): """ Attempt to location a particular StockLocation - + Arguments: location_pk: The PK (primary key) of the StockLocation to be located - + Note: The default implementation here does nothing! """ ... diff --git a/InvenTree/plugin/templatetags/plugin_extras.py b/InvenTree/plugin/templatetags/plugin_extras.py index fbd6c483ae..d183ae5483 100644 --- a/InvenTree/plugin/templatetags/plugin_extras.py +++ b/InvenTree/plugin/templatetags/plugin_extras.py @@ -44,6 +44,7 @@ def mixin_enabled(plugin, key, *args, **kwargs): """ return plugin.mixin_enabled(key) + @register.simple_tag() def mixin_available(mixin, *args, **kwargs): """ @@ -51,6 +52,7 @@ def mixin_available(mixin, *args, **kwargs): """ return len(registry.with_mixin(mixin)) > 0 + @register.simple_tag() def navigation_enabled(*args, **kwargs): """