mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-22 20:12:00 -06:00
Fixes #1579: Devices already assigned to a cluster cannot be added to a different cluster
This commit is contained in:
parent
6f2f8697ae
commit
34f1a9ebfb
@ -59,6 +59,7 @@
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
var device_list = $('#id_devices');
|
||||
var disabled_indicator = device_list.attr('disabled-indicator');
|
||||
$('#id_search').autocomplete({
|
||||
source: function(request, response) {
|
||||
$.ajax({
|
||||
@ -70,7 +71,11 @@
|
||||
},
|
||||
success: function(data) {
|
||||
response($.map(data.results, function(item) {
|
||||
device_list.append('<option value="' + item['id'] + '">' + item['display_name'] + '</option>');
|
||||
var option = $("<option></option>").attr("value", item['id']).text(item['display_name']);
|
||||
if (disabled_indicator && item[disabled_indicator]) {
|
||||
option.attr("disabled", "disabled");
|
||||
}
|
||||
device_list.append(option);
|
||||
}));
|
||||
}
|
||||
});
|
||||
|
@ -210,7 +210,7 @@ class ClusterAddDevicesForm(BootstrapMixin, ChainedFieldsMixin, forms.Form):
|
||||
|
||||
# If the Cluster is assigned to a Site, all Devices must be assigned to that Site.
|
||||
if self.cluster.site is not None:
|
||||
for device in self.cleaned_data.get('devices'):
|
||||
for device in self.cleaned_data.get('devices', []):
|
||||
if device.site != self.cluster.site:
|
||||
raise ValidationError({
|
||||
'devices': "{} belongs to a different site ({}) than the cluster ({})".format(
|
||||
|
Loading…
Reference in New Issue
Block a user