1
0
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:
Jeremy Stretch
2017-03-13 11:31:28 -04:00
parent cd97b2fb96
commit f3fd82a24a

View File

@ -1618,20 +1618,23 @@ class DeviceBayCreateForm(DeviceComponentForm):
class PopulateDeviceBayForm(BootstrapMixin, forms.Form): class PopulateDeviceBayForm(BootstrapMixin, forms.Form):
installed_device = forms.ModelChoiceField(queryset=Device.objects.all(), label='Child Device', installed_device = forms.ModelChoiceField(
help_text="Child devices must first be created within the rack occupied " queryset=Device.objects.all(),
"by the parent device. Then they can be assigned to a bay.") 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): def __init__(self, device_bay, *args, **kwargs):
super(PopulateDeviceBayForm, self).__init__(*args, **kwargs) super(PopulateDeviceBayForm, self).__init__(*args, **kwargs)
children_queryset = Device.objects.filter(rack=device_bay.device.rack, self.fields['installed_device'].queryset = Device.objects.filter(
site=device_bay.device.site,
rack=device_bay.device.rack,
parent_bay__isnull=True, parent_bay__isnull=True,
device_type__u_height=0, device_type__u_height=0,
device_type__subdevice_role=SUBDEVICE_ROLE_CHILD)\ device_type__subdevice_role=SUBDEVICE_ROLE_CHILD
.exclude(pk=device_bay.device.pk) ).exclude(pk=device_bay.device.pk)
self.fields['installed_device'].queryset = children_queryset
# #