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

This commit is contained in:
Jeremy Stretch 2018-11-08 10:40:17 -05:00
parent 0dee55885b
commit 4b5181d640
3 changed files with 6 additions and 1 deletions

View File

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

View File

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

View File

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