mirror of
https://github.com/nottinghamtec/PyRIGS.git
synced 2026-01-17 13:32:15 +00:00
Refactor activity feed template logic
Yay for removing arbitrary if/else chains!
This commit is contained in:
@@ -176,18 +176,14 @@ class Asset(models.Model, RevisionMixin):
|
||||
errdict["csa"] = ["The CSA of a cable must be more than 0"]
|
||||
if not self.cable_type:
|
||||
errdict["cable_type"] = ["A cable must have a type"]
|
||||
# if not self.circuits or self.circuits <= 0:
|
||||
# errdict["circuits"] = ["There must be at least one circuit in a cable"]
|
||||
# if not self.cores or self.cores <= 0:
|
||||
# errdict["cores"] = ["There must be at least one core in a cable"]
|
||||
# if self.socket is None:
|
||||
# errdict["socket"] = ["A cable must have a socket"]
|
||||
# if self.plug is None:
|
||||
# errdict["plug"] = ["A cable must have a plug"]
|
||||
|
||||
if errdict != {}: # If there was an error when validation
|
||||
raise ValidationError(errdict)
|
||||
|
||||
@property
|
||||
def activity_feed_string(self):
|
||||
return str(self)
|
||||
|
||||
|
||||
@receiver(pre_save, sender=Asset)
|
||||
def pre_save_asset(sender, instance, **kwargs):
|
||||
|
||||
Reference in New Issue
Block a user