PEP style fixes

This commit is contained in:
Oliver Walters 2022-05-09 23:52:19 +10:00
parent 35fbb910e8
commit 6c0661a6f2
4 changed files with 13 additions and 11 deletions

View File

@ -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)

View File

@ -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

View File

@ -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!
"""
...

View File

@ -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):
"""