mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
fix reused builtins
This commit is contained in:
parent
cbd84a23f9
commit
c44565f9e3
@ -109,14 +109,14 @@ class BarcodeScan(APIView):
|
||||
# No plugin is found!
|
||||
# However, the hash of the barcode may still be associated with a StockItem!
|
||||
else:
|
||||
hash = hash_barcode(barcode_data)
|
||||
result_hash = hash_barcode(barcode_data)
|
||||
|
||||
response['hash'] = hash
|
||||
response['hash'] = result_hash
|
||||
response['plugin'] = None
|
||||
|
||||
# Try to look for a matching StockItem
|
||||
try:
|
||||
item = StockItem.objects.get(uid=hash)
|
||||
item = StockItem.objects.get(uid=result_hash)
|
||||
serializer = StockItemSerializer(item, part_detail=True, location_detail=True, supplier_part_detail=True)
|
||||
response['stockitem'] = serializer.data
|
||||
response['url'] = reverse('stock-item-detail', kwargs={'pk': item.id})
|
||||
@ -182,8 +182,8 @@ class BarcodeAssign(APIView):
|
||||
# Matching plugin was found
|
||||
if plugin is not None:
|
||||
|
||||
hash = plugin.hash()
|
||||
response['hash'] = hash
|
||||
result_hash = plugin.hash()
|
||||
response['hash'] = result_hash
|
||||
response['plugin'] = plugin.name
|
||||
|
||||
# Ensure that the barcode does not already match a database entry
|
||||
@ -208,14 +208,14 @@ class BarcodeAssign(APIView):
|
||||
match_found = True
|
||||
|
||||
else:
|
||||
hash = hash_barcode(barcode_data)
|
||||
result_hash = hash_barcode(barcode_data)
|
||||
|
||||
response['hash'] = hash
|
||||
response['hash'] = result_hash
|
||||
response['plugin'] = None
|
||||
|
||||
# Lookup stock item by hash
|
||||
try:
|
||||
item = StockItem.objects.get(uid=hash)
|
||||
item = StockItem.objects.get(uid=result_hash)
|
||||
response['error'] = _('Barcode hash already matches Stock Item')
|
||||
match_found = True
|
||||
except StockItem.DoesNotExist:
|
||||
|
@ -124,12 +124,12 @@ class BarcodeAPITest(APITestCase):
|
||||
|
||||
self.assertIn('success', data)
|
||||
|
||||
hash = data['hash']
|
||||
result_hash = data['hash']
|
||||
|
||||
# Read the item out from the database again
|
||||
item = StockItem.objects.get(pk=522)
|
||||
|
||||
self.assertEqual(hash, item.uid)
|
||||
self.assertEqual(result_hash, item.uid)
|
||||
|
||||
# Ensure that the same UID cannot be assigned to a different stock item!
|
||||
response = self.client.post(
|
||||
|
@ -446,10 +446,10 @@ class PartSerialNumberDetail(generics.RetrieveAPIView):
|
||||
}
|
||||
|
||||
if latest is not None:
|
||||
next = increment(latest)
|
||||
next_serial = increment(latest)
|
||||
|
||||
if next != increment:
|
||||
data['next'] = next
|
||||
if next_serial != increment:
|
||||
data['next'] = next_serial
|
||||
|
||||
return Response(data)
|
||||
|
||||
|
@ -1530,15 +1530,15 @@ class Part(MPTTModel):
|
||||
returns a string representation of a hash object which can be compared with a stored value
|
||||
"""
|
||||
|
||||
hash = hashlib.md5(str(self.id).encode())
|
||||
result_hash = hashlib.md5(str(self.id).encode())
|
||||
|
||||
# List *all* BOM items (including inherited ones!)
|
||||
bom_items = self.get_bom_items().all().prefetch_related('sub_part')
|
||||
|
||||
for item in bom_items:
|
||||
hash.update(str(item.get_item_hash()).encode())
|
||||
result_hash.update(str(item.get_item_hash()).encode())
|
||||
|
||||
return str(hash.digest())
|
||||
return str(result_hash.digest())
|
||||
|
||||
def is_bom_valid(self):
|
||||
""" Check if the BOM is 'valid' - if the calculated checksum matches the stored value
|
||||
@ -2676,18 +2676,18 @@ class BomItem(models.Model):
|
||||
"""
|
||||
|
||||
# Seed the hash with the ID of this BOM item
|
||||
hash = hashlib.md5(str(self.id).encode())
|
||||
result_hash = hashlib.md5(str(self.id).encode())
|
||||
|
||||
# Update the hash based on line information
|
||||
hash.update(str(self.sub_part.id).encode())
|
||||
hash.update(str(self.sub_part.full_name).encode())
|
||||
hash.update(str(self.quantity).encode())
|
||||
hash.update(str(self.note).encode())
|
||||
hash.update(str(self.reference).encode())
|
||||
hash.update(str(self.optional).encode())
|
||||
hash.update(str(self.inherited).encode())
|
||||
result_hash.update(str(self.sub_part.id).encode())
|
||||
result_hash.update(str(self.sub_part.full_name).encode())
|
||||
result_hash.update(str(self.quantity).encode())
|
||||
result_hash.update(str(self.note).encode())
|
||||
result_hash.update(str(self.reference).encode())
|
||||
result_hash.update(str(self.optional).encode())
|
||||
result_hash.update(str(self.inherited).encode())
|
||||
|
||||
return str(hash.digest())
|
||||
return str(result_hash.digest())
|
||||
|
||||
def validate_hash(self, valid=True):
|
||||
""" Mark this item as 'valid' (store the checksum hash).
|
||||
|
@ -293,7 +293,7 @@ def progress_bar(val, max, *args, **kwargs):
|
||||
Render a progress bar element
|
||||
"""
|
||||
|
||||
id = kwargs.get('id', 'progress-bar')
|
||||
item_id = kwargs.get('id', 'progress-bar')
|
||||
|
||||
if val > max:
|
||||
style = 'progress-bar-over'
|
||||
@ -317,7 +317,7 @@ def progress_bar(val, max, *args, **kwargs):
|
||||
style_tags.append(f'max-width: {max_width};')
|
||||
|
||||
html = f"""
|
||||
<div id='{id}' class='progress' style='{" ".join(style_tags)}'>
|
||||
<div id='{item_id}' class='progress' style='{" ".join(style_tags)}'>
|
||||
<div class='progress-bar {style}' role='progressbar' aria-valuemin='0' aria-valuemax='100' style='width:{percent}%'></div>
|
||||
<div class='progress-value'>{val} / {max}</div>
|
||||
</div>
|
||||
|
@ -30,8 +30,8 @@ class TemplateTagTest(TestCase):
|
||||
self.assertEqual(type(inventree_extras.inventree_version()), str)
|
||||
|
||||
def test_hash(self):
|
||||
hash = inventree_extras.inventree_commit_hash()
|
||||
self.assertGreater(len(hash), 5)
|
||||
result_hash = inventree_extras.inventree_commit_hash()
|
||||
self.assertGreater(len(result_hash), 5)
|
||||
|
||||
def test_date(self):
|
||||
d = inventree_extras.inventree_commit_date()
|
||||
|
@ -173,8 +173,8 @@ class IntegrationPluginBase(MixinBase, plugin_base.InvenTreePluginBase):
|
||||
"""
|
||||
License of plugin
|
||||
"""
|
||||
license = getattr(self, 'LICENSE', None)
|
||||
return license
|
||||
lic = getattr(self, 'LICENSE', None)
|
||||
return lic
|
||||
# endregion
|
||||
|
||||
@property
|
||||
|
Loading…
Reference in New Issue
Block a user