Refactor function naming

This commit is contained in:
Oliver Walters 2020-05-16 12:03:18 +10:00
parent 4cb97b1340
commit 3d0bea15ae
6 changed files with 20 additions and 20 deletions

View File

@ -282,7 +282,7 @@ class BuildComplete(AjaxUpdateView):
existing = []
for serial in serials:
if not StockItem.check_serial_number(build.part, serial):
if build.part.checkIfSerialNumberExists(serial):
existing.append(serial)
if len(existing) > 0:

View File

@ -266,7 +266,7 @@ class Part(MPTTModel):
def __str__(self):
return "{n} - {d}".format(n=self.full_name, d=self.description)
def check_if_serial_number_exists(self, sn):
def checkIfSerialNumberExists(self, sn):
"""
Check if a serial number exists for this Part.
@ -279,7 +279,7 @@ class Part(MPTTModel):
return stock.exists()
def get_highest_serial_number(self):
def getHighestSerialNumber(self):
"""
Return the highest serial number for this Part.
@ -296,12 +296,12 @@ class Part(MPTTModel):
# No serial numbers found
return None
def get_next_serial_number(self):
def getNextSerialNumber(self):
"""
Return the next-available serial number for this Part.
"""
n = self.get_highest_serial_number()
n = self.getHighestSerialNumber()
if n is None:
return 1

View File

@ -113,7 +113,7 @@ class SerializeStockForm(HelperForm):
if item:
# Pre-calculate what the serial numbers should be!
sn = item.part.get_next_serial_number()
sn = item.part.getNextSerialNumber()
if item.quantity >= 2:
sn = "{n}-{m}".format(n=sn, m=int(sn+item.quantity-1))

View File

@ -606,7 +606,7 @@ class StockItem(MPTTModel):
existing = []
for serial in serials:
if self.part.check_if_serial_number_exists(serial):
if self.part.checkIfSerialNumberExists(serial):
existing.append(serial)
if len(existing) > 0:

View File

@ -361,26 +361,26 @@ class VariantTest(StockTest):
chair = Part.objects.get(pk=10000)
# Operations on the top-level object
self.assertTrue(chair.check_if_serial_number_exists(1))
self.assertTrue(chair.check_if_serial_number_exists(2))
self.assertTrue(chair.check_if_serial_number_exists(3))
self.assertTrue(chair.check_if_serial_number_exists(4))
self.assertTrue(chair.check_if_serial_number_exists(5))
self.assertTrue(chair.checkIfSerialNumberExists(1))
self.assertTrue(chair.checkIfSerialNumberExists(2))
self.assertTrue(chair.checkIfSerialNumberExists(3))
self.assertTrue(chair.checkIfSerialNumberExists(4))
self.assertTrue(chair.checkIfSerialNumberExists(5))
self.assertTrue(chair.check_if_serial_number_exists(20))
self.assertTrue(chair.check_if_serial_number_exists(21))
self.assertTrue(chair.check_if_serial_number_exists(22))
self.assertTrue(chair.checkIfSerialNumberExists(20))
self.assertTrue(chair.checkIfSerialNumberExists(21))
self.assertTrue(chair.checkIfSerialNumberExists(22))
self.assertFalse(chair.check_if_serial_number_exists(30))
self.assertFalse(chair.checkIfSerialNumberExists(30))
self.assertEqual(chair.get_next_serial_number(), 23)
self.assertEqual(chair.getNextSerialNumber(), 23)
# Same operations on a sub-item
variant = Part.objects.get(pk=10003)
self.assertEqual(variant.get_next_serial_number(), 23)
self.assertEqual(variant.getNextSerialNumber(), 23)
# Create a new serial number
n = variant.get_highest_serial_number()
n = variant.getHighestSerialNumber()
item = StockItem(
part=variant,

View File

@ -775,7 +775,7 @@ class StockItemSerialize(AjaxUpdateView):
item = self.get_object()
# Pre-calculate what the serial numbers should be!
sn = item.part.get_next_serial_number()
sn = item.part.getNextSerialNumber()
if item.quantity >= 2:
sn = "{n}-{m}".format(n=sn, m=int(sn+item.quantity-1))