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

Add tests for device type component views

This commit is contained in:
Jeremy Stretch
2020-02-06 14:39:36 -05:00
parent f7ca97d51f
commit 5620fdc63e
2 changed files with 373 additions and 2 deletions

View File

@@ -1174,8 +1174,11 @@ class PowerOutletTemplateCreateForm(BootstrapMixin, forms.Form):
super().__init__(*args, **kwargs)
# Limit power_port choices to current DeviceType
device_type = DeviceType.objects.get(
pk=self.initial.get('device_type') or self.data.get('device_type')
)
self.fields['power_port'].queryset = PowerPortTemplate.objects.filter(
device_type=self.initial.get('device_type')
device_type=device_type
)
@@ -1278,7 +1281,9 @@ class FrontPortTemplateCreateForm(BootstrapMixin, forms.Form):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
device_type = DeviceType.objects.filter(pk=self.initial.get('device_type')).first()
device_type = DeviceType.objects.get(
pk=self.initial.get('device_type') or self.data.get('device_type')
)
# Determine which rear port positions are occupied. These will be excluded from the list of available mappings.
occupied_port_positions = [