mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Allow assigning child devices to rackless parents
This commit is contained in:
@ -1618,20 +1618,23 @@ class DeviceBayCreateForm(DeviceComponentForm):
|
||||
|
||||
|
||||
class PopulateDeviceBayForm(BootstrapMixin, forms.Form):
|
||||
installed_device = forms.ModelChoiceField(queryset=Device.objects.all(), label='Child Device',
|
||||
help_text="Child devices must first be created within the rack occupied "
|
||||
"by the parent device. Then they can be assigned to a bay.")
|
||||
installed_device = forms.ModelChoiceField(
|
||||
queryset=Device.objects.all(),
|
||||
label='Child Device',
|
||||
help_text="Child devices must first be created and assigned to the site/rack of the parent device."
|
||||
)
|
||||
|
||||
def __init__(self, device_bay, *args, **kwargs):
|
||||
|
||||
super(PopulateDeviceBayForm, self).__init__(*args, **kwargs)
|
||||
|
||||
children_queryset = Device.objects.filter(rack=device_bay.device.rack,
|
||||
parent_bay__isnull=True,
|
||||
device_type__u_height=0,
|
||||
device_type__subdevice_role=SUBDEVICE_ROLE_CHILD)\
|
||||
.exclude(pk=device_bay.device.pk)
|
||||
self.fields['installed_device'].queryset = children_queryset
|
||||
self.fields['installed_device'].queryset = Device.objects.filter(
|
||||
site=device_bay.device.site,
|
||||
rack=device_bay.device.rack,
|
||||
parent_bay__isnull=True,
|
||||
device_type__u_height=0,
|
||||
device_type__subdevice_role=SUBDEVICE_ROLE_CHILD
|
||||
).exclude(pk=device_bay.device.pk)
|
||||
|
||||
|
||||
#
|
||||
|
Reference in New Issue
Block a user