mirror of
https://github.com/inventree/InvenTree.git
synced 2025-04-29 20:16:44 +00:00
PEP style fixes
This commit is contained in:
parent
35fbb910e8
commit
6c0661a6f2
@ -138,7 +138,7 @@ class LocatePluginView(APIView):
|
|||||||
|
|
||||||
# Which plugin to we wish to use?
|
# Which plugin to we wish to use?
|
||||||
plugin = request.data.get('plugin', None)
|
plugin = request.data.get('plugin', None)
|
||||||
|
|
||||||
if not plugin:
|
if not plugin:
|
||||||
raise ParseError("'plugin' field must be supplied")
|
raise ParseError("'plugin' field must be supplied")
|
||||||
|
|
||||||
@ -146,10 +146,10 @@ class LocatePluginView(APIView):
|
|||||||
plugins = registry.with_mixin('locate')
|
plugins = registry.with_mixin('locate')
|
||||||
|
|
||||||
if plugin not in [p.slug for p in plugins]:
|
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
|
# StockItem to identify
|
||||||
item_pk= request.data.get('item', None)
|
item_pk = request.data.get('item', None)
|
||||||
|
|
||||||
# StockLocation to identify
|
# StockLocation to identify
|
||||||
location_pk = request.data.get('location', None)
|
location_pk = request.data.get('location', None)
|
||||||
@ -165,7 +165,7 @@ class LocatePluginView(APIView):
|
|||||||
# StockItem takes priority
|
# StockItem takes priority
|
||||||
if item_pk:
|
if item_pk:
|
||||||
try:
|
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)
|
offload_task('plugin.registry.call_function', plugin, 'locate_stock_item', item_pk)
|
||||||
|
|
||||||
@ -175,10 +175,10 @@ class LocatePluginView(APIView):
|
|||||||
|
|
||||||
except StockItem.DoesNotExist:
|
except StockItem.DoesNotExist:
|
||||||
raise NotFound("StockItem matching PK '{item}' not found")
|
raise NotFound("StockItem matching PK '{item}' not found")
|
||||||
|
|
||||||
elif location_pk:
|
elif location_pk:
|
||||||
try:
|
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)
|
offload_task('plugin.registry.call_function', plugin, 'locate_stock_location', location_pk)
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ class PluginList(generics.ListAPIView):
|
|||||||
for result in queryset:
|
for result in queryset:
|
||||||
if mixin in result.mixins().keys():
|
if mixin in result.mixins().keys():
|
||||||
matches.append(result.pk)
|
matches.append(result.pk)
|
||||||
|
|
||||||
queryset = queryset.filter(pk__in=matches)
|
queryset = queryset.filter(pk__in=matches)
|
||||||
|
|
||||||
return queryset
|
return queryset
|
||||||
|
@ -453,11 +453,11 @@ class LocateMixin:
|
|||||||
|
|
||||||
class MixinMeta:
|
class MixinMeta:
|
||||||
MIXIN_NAME = "Locate"
|
MIXIN_NAME = "Locate"
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self.add_mixin('locate', True, __class__)
|
self.add_mixin('locate', True, __class__)
|
||||||
|
|
||||||
def locate_stock_item(self, item_pk):
|
def locate_stock_item(self, item_pk):
|
||||||
"""
|
"""
|
||||||
Attempt to locate a particular StockItem
|
Attempt to locate a particular StockItem
|
||||||
@ -490,10 +490,10 @@ class LocateMixin:
|
|||||||
def locate_stock_location(self, location_pk):
|
def locate_stock_location(self, location_pk):
|
||||||
"""
|
"""
|
||||||
Attempt to location a particular StockLocation
|
Attempt to location a particular StockLocation
|
||||||
|
|
||||||
Arguments:
|
Arguments:
|
||||||
location_pk: The PK (primary key) of the StockLocation to be located
|
location_pk: The PK (primary key) of the StockLocation to be located
|
||||||
|
|
||||||
Note: The default implementation here does nothing!
|
Note: The default implementation here does nothing!
|
||||||
"""
|
"""
|
||||||
...
|
...
|
||||||
|
@ -44,6 +44,7 @@ def mixin_enabled(plugin, key, *args, **kwargs):
|
|||||||
"""
|
"""
|
||||||
return plugin.mixin_enabled(key)
|
return plugin.mixin_enabled(key)
|
||||||
|
|
||||||
|
|
||||||
@register.simple_tag()
|
@register.simple_tag()
|
||||||
def mixin_available(mixin, *args, **kwargs):
|
def mixin_available(mixin, *args, **kwargs):
|
||||||
"""
|
"""
|
||||||
@ -51,6 +52,7 @@ def mixin_available(mixin, *args, **kwargs):
|
|||||||
"""
|
"""
|
||||||
return len(registry.with_mixin(mixin)) > 0
|
return len(registry.with_mixin(mixin)) > 0
|
||||||
|
|
||||||
|
|
||||||
@register.simple_tag()
|
@register.simple_tag()
|
||||||
def navigation_enabled(*args, **kwargs):
|
def navigation_enabled(*args, **kwargs):
|
||||||
"""
|
"""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user