1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Fixes #3018: Components connected via a cable must have an equal number of positions

This commit is contained in:
Jeremy Stretch
2019-07-31 10:12:07 -04:00
parent ea32853ab3
commit a32d185ff0
2 changed files with 11 additions and 0 deletions

View File

@@ -2772,6 +2772,16 @@ class Cable(ChangeLoggedModel):
self.termination_a_type, self.termination_b_type
))
# A component with multiple positions must be connected to a component with an equal number of positions
term_a_positions = getattr(self.termination_a, 'positions', 1)
term_b_positions = getattr(self.termination_b, 'positions', 1)
if term_a_positions != term_b_positions:
raise ValidationError(
"{} has {} positions and {} has {}. Both terminations must have the same number of positions.".format(
self.termination_a, term_a_positions, self.termination_b, term_b_positions
)
)
# A termination point cannot be connected to itself
if self.termination_a == self.termination_b:
raise ValidationError("Cannot connect {} to itself".format(self.termination_a_type))