Fixes #2566: Prevent both ends of a cable from connecting to the same termination point

This commit is contained in:
Jeremy Stretch
2018-11-08 10:40:17 -05:00
parent 0dee55885b
commit 4b5181d640
3 changed files with 6 additions and 1 deletions

View File

@@ -2516,6 +2516,11 @@ class Cable(ChangeLoggedModel):
self.termination_a_type, self.termination_b_type
))
# A termination point cannot be connected to itself
if self.termination_a == self.termination_b:
print("Validation failed: same interface")
raise ValidationError("Cannot connect {} to itself".format(self.termination_a_type))
# Check for an existing Cable connected to either termination object
if self.termination_a.cable not in (None, self):
raise ValidationError("{} already has a cable attached (#{})".format(