1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Closes #3563: Enable editing of individual DeviceType components

This commit is contained in:
Jeremy Stretch
2019-10-07 17:08:51 -04:00
parent a9d3d38a41
commit c668b990e1
5 changed files with 138 additions and 8 deletions

View File

@ -1023,6 +1023,16 @@ class PowerOutletTemplateForm(BootstrapMixin, forms.ModelForm):
'device_type': forms.HiddenInput(),
}
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
# Limit power_port choices to current DeviceType
if hasattr(self.instance, 'device_type'):
self.fields['power_port'].queryset = PowerPortTemplate.objects.filter(
device_type=self.instance.device_type
)
class PowerOutletTemplateCreateForm(ComponentForm):
name_pattern = ExpandableNameField(
@ -1107,6 +1117,16 @@ class FrontPortTemplateForm(BootstrapMixin, forms.ModelForm):
'rear_port': StaticSelect2(),
}
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
# Limit rear_port choices to current DeviceType
if hasattr(self.instance, 'device_type'):
self.fields['rear_port'].queryset = RearPortTemplate.objects.filter(
device_type=self.instance.device_type
)
class FrontPortTemplateCreateForm(ComponentForm):
name_pattern = ExpandableNameField(