Replace is_path_endpoint with simple isinstance check

It was only used in a single location anyway…
This commit is contained in:
Sander Steffann 2020-06-26 17:25:07 +02:00
parent 715ddc6b02
commit 3fdc8e7d3d
3 changed files with 2 additions and 13 deletions

View File

@ -300,9 +300,6 @@ class CircuitTermination(CableTermination):
blank=True
)
# Paths do not end on cable terminations, they continue at the other end of the circuit
is_path_endpoint = False
# But they are a possible connected endpoint
is_connected_endpoint = True

View File

@ -2129,6 +2129,7 @@ class Cable(ChangeLoggedModel):
return reverse('dcim:cable', args=[self.pk])
def clean(self):
from circuits.models import CircuitTermination
# Validate that termination A exists
if not hasattr(self, 'termination_a_type'):
@ -2198,7 +2199,7 @@ class Cable(ChangeLoggedModel):
(self.termination_b, self.termination_a)
]:
if isinstance(term_a, RearPort) and term_a.positions > 1:
if term_b.is_path_endpoint:
if not isinstance(term_b, (FrontPort, RearPort, CircuitTermination)):
raise ValidationError(
"Rear ports with multiple positions may only be connected to other pass-through ports"
)

View File

@ -86,9 +86,6 @@ class CableTermination(models.Model):
object_id_field='termination_b_id'
)
# Whether this class is always an endpoint for cable traces
is_path_endpoint = True
# Whether this class can be a connected endpoint
is_connected_endpoint = True
@ -900,9 +897,6 @@ class FrontPort(CableTermination, ComponentModel):
csv_headers = ['device', 'name', 'type', 'rear_port', 'rear_port_position', 'description']
# Whether this class is always an endpoint for cable traces
is_path_endpoint = False
# Whether this class can be a connected endpoint
is_connected_endpoint = False
@ -973,9 +967,6 @@ class RearPort(CableTermination, ComponentModel):
csv_headers = ['device', 'name', 'type', 'positions', 'description']
# Whether this class is always an endpoint for cable traces
is_path_endpoint = False
# Whether this class can be a connected endpoint
is_connected_endpoint = False