Просмотр исходного кода

Replace `is_path_endpoint` with simple `isinstance` check
It was only used in a single location anyway…

Sander Steffann 5 лет назад
Родитель
Сommit
3fdc8e7d3d
3 измененных файлов с 2 добавлено и 13 удалено
  1. 0 3
      netbox/circuits/models.py
  2. 2 1
      netbox/dcim/models/__init__.py
  3. 0 9
      netbox/dcim/models/device_components.py

+ 0 - 3
netbox/circuits/models.py

@@ -300,9 +300,6 @@ class CircuitTermination(CableTermination):
         blank=True
         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
     # But they are a possible connected endpoint
     is_connected_endpoint = True
     is_connected_endpoint = True
 
 

+ 2 - 1
netbox/dcim/models/__init__.py

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

+ 0 - 9
netbox/dcim/models/device_components.py

@@ -86,9 +86,6 @@ class CableTermination(models.Model):
         object_id_field='termination_b_id'
         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
     # Whether this class can be a connected endpoint
     is_connected_endpoint = True
     is_connected_endpoint = True
 
 
@@ -900,9 +897,6 @@ class FrontPort(CableTermination, ComponentModel):
 
 
     csv_headers = ['device', 'name', 'type', 'rear_port', 'rear_port_position', 'description']
     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
     # Whether this class can be a connected endpoint
     is_connected_endpoint = False
     is_connected_endpoint = False
 
 
@@ -973,9 +967,6 @@ class RearPort(CableTermination, ComponentModel):
 
 
     csv_headers = ['device', 'name', 'type', 'positions', 'description']
     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
     # Whether this class can be a connected endpoint
     is_connected_endpoint = False
     is_connected_endpoint = False