Added form validation

* Asset IDs must be unique
* Asset IDs that are legacy and unchange have no validation applied
* Asset IDs must be alphanumeric
* Values must be >=0
* Lengths, CSAs, Circuits and Cores of cables must all be >0
This commit is contained in:
Matthew Smith
2019-10-08 22:33:41 +01:00
parent 1d6208414f
commit b7e14b7dc3
5 changed files with 89 additions and 7 deletions

View File

@@ -40,7 +40,7 @@ class Supplier(models.Model):
class Asset(PolymorphicModel):
parent = models.ForeignKey(to='self', related_name='asset_parent', blank=True, null=True, on_delete=models.SET_NULL)
asset_id = models.CharField(max_length=10)
asset_id = models.CharField(max_length=10, unique=True)
description = models.CharField(max_length=120)
category = models.ForeignKey(to=AssetCategory, on_delete=models.CASCADE)
status = models.ForeignKey(to=AssetStatus, on_delete=models.CASCADE)