mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Logic fix
This commit is contained in:
parent
7faa0d199d
commit
4d7407ee51
@ -61,30 +61,30 @@ class BarcodeScanView(APIView):
|
|||||||
|
|
||||||
if barcode_data is None:
|
if barcode_data is None:
|
||||||
response['error'] = _('No barcode data provided')
|
response['error'] = _('No barcode data provided')
|
||||||
|
else:
|
||||||
|
# Look for a barcode plugin that knows how to handle the data
|
||||||
|
for plugin_class in barcode_plugins:
|
||||||
|
|
||||||
# Look for a barcode plugin that knows how to handle the data
|
# Instantiate the plugin with the provided plugin data
|
||||||
for plugin_class in barcode_plugins:
|
plugin = plugin_class(barcode_data)
|
||||||
|
|
||||||
# Instantiate the plugin with the provided plugin data
|
if plugin.validate():
|
||||||
plugin = plugin_class(barcode_data)
|
|
||||||
|
|
||||||
if plugin.validate():
|
# Plugin should return a dict response
|
||||||
|
response = plugin.decode()
|
||||||
|
|
||||||
# Plugin should return a dict response
|
if type(response) is dict:
|
||||||
response = plugin.decode()
|
if 'success' not in response.keys() and 'error' not in response.keys():
|
||||||
|
response['success'] = _('Barcode successfully decoded')
|
||||||
|
else:
|
||||||
|
response = {
|
||||||
|
'error': _('Barcode plugin returned incorrect response')
|
||||||
|
}
|
||||||
|
|
||||||
if type(response) is dict:
|
response['plugin'] = plugin.get_name()
|
||||||
if 'success' not in response.keys() and 'error' not in response.keys():
|
response['hash'] = plugin.hash()
|
||||||
response['success'] = _('Barcode successfully decoded')
|
|
||||||
else:
|
|
||||||
response = {
|
|
||||||
'error': _('Barcode plugin returned incorrect response')
|
|
||||||
}
|
|
||||||
|
|
||||||
response['plugin'] = plugin.get_name()
|
break
|
||||||
response['hash'] = plugin.hash()
|
|
||||||
|
|
||||||
break
|
|
||||||
|
|
||||||
if 'error' not in response and 'success' not in response:
|
if 'error' not in response and 'success' not in response:
|
||||||
response = {
|
response = {
|
||||||
|
Loading…
Reference in New Issue
Block a user