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