2
0
Эх сурвалжийг харах

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

Jeremy Stretch 7 жил өмнө
parent
commit
4b5181d640

+ 1 - 0
CHANGELOG.md

@@ -40,6 +40,7 @@ NetBox now supports modeling physical cables for console, power, and interface c
 ## Bug Fixes (from v2.5-beta1)
 ## Bug Fixes (from v2.5-beta1)
 
 
 * [#2563](https://github.com/digitalocean/netbox/issues/2563) - Enable export templates for cables
 * [#2563](https://github.com/digitalocean/netbox/issues/2563) - Enable export templates for cables
+* [#2566](https://github.com/digitalocean/netbox/issues/2566) - Prevent both ends of a cable from connecting to the same termination point
 * [#2567](https://github.com/digitalocean/netbox/issues/2567) - Introduced proxy models to represent console/power/interface connections
 * [#2567](https://github.com/digitalocean/netbox/issues/2567) - Introduced proxy models to represent console/power/interface connections
 
 
 ## API Changes
 ## API Changes

+ 5 - 0
netbox/dcim/models.py

@@ -2516,6 +2516,11 @@ class Cable(ChangeLoggedModel):
                 self.termination_a_type, self.termination_b_type
                 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
         # Check for an existing Cable connected to either termination object
         if self.termination_a.cable not in (None, self):
         if self.termination_a.cable not in (None, self):
             raise ValidationError("{} already has a cable attached (#{})".format(
             raise ValidationError("{} already has a cable attached (#{})".format(

+ 0 - 1
netbox/project-static/js/livesearch.js

@@ -42,7 +42,6 @@ $(document).ready(function() {
             event.preventDefault();
             event.preventDefault();
             search_field.val(ui.item.label);
             search_field.val(ui.item.label);
             select_fields.val('');
             select_fields.val('');
-            select_fields.attr('disabled', 'disabled');
             real_field.empty();
             real_field.empty();
             real_field.append($("<option></option>").attr('value', ui.item.value).text(ui.item.label));
             real_field.append($("<option></option>").attr('value', ui.item.value).text(ui.item.label));
             real_field.change();
             real_field.change();