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

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

Jeremy Stretch 7 лет назад
Родитель
Сommit
4b5181d640
3 измененных файлов с 6 добавлено и 1 удалено
  1. 1 0
      CHANGELOG.md
  2. 5 0
      netbox/dcim/models.py
  3. 0 1
      netbox/project-static/js/livesearch.js

+ 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)
 
 * [#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
 
 ## API Changes

+ 5 - 0
netbox/dcim/models.py

@@ -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(

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

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