|
@@ -1002,6 +1002,7 @@ class InventoryItemTemplateForm(ComponentTemplateForm):
|
|
|
queryset=Manufacturer.objects.all(),
|
|
queryset=Manufacturer.objects.all(),
|
|
|
required=False
|
|
required=False
|
|
|
)
|
|
)
|
|
|
|
|
+
|
|
|
# Assigned component selectors
|
|
# Assigned component selectors
|
|
|
consoleporttemplate = DynamicModelChoiceField(
|
|
consoleporttemplate = DynamicModelChoiceField(
|
|
|
queryset=ConsolePortTemplate.objects.all(),
|
|
queryset=ConsolePortTemplate.objects.all(),
|
|
@@ -1063,8 +1064,19 @@ class InventoryItemTemplateForm(ComponentTemplateForm):
|
|
|
fieldsets = (
|
|
fieldsets = (
|
|
|
FieldSet(
|
|
FieldSet(
|
|
|
'device_type', 'parent', 'name', 'label', 'role', 'manufacturer', 'part_id', 'description',
|
|
'device_type', 'parent', 'name', 'label', 'role', 'manufacturer', 'part_id', 'description',
|
|
|
- 'component_type', 'component_id',
|
|
|
|
|
),
|
|
),
|
|
|
|
|
+ FieldSet(
|
|
|
|
|
+ TabbedGroups(
|
|
|
|
|
+ FieldSet('interfacetemplate', name=_('Interface')),
|
|
|
|
|
+ FieldSet('consoleporttemplate', name=_('Console Port')),
|
|
|
|
|
+ FieldSet('consoleserverporttemplate', name=_('Console Server Port')),
|
|
|
|
|
+ FieldSet('frontporttemplate', name=_('Front Port')),
|
|
|
|
|
+ FieldSet('rearporttemplate', name=_('Rear Port')),
|
|
|
|
|
+ FieldSet('powerporttemplate', name=_('Power Port')),
|
|
|
|
|
+ FieldSet('poweroutlettemplate', name=_('Power Outlet')),
|
|
|
|
|
+ ),
|
|
|
|
|
+ name=_('Component Assignment')
|
|
|
|
|
+ )
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
class Meta:
|
|
class Meta:
|
|
@@ -1079,22 +1091,17 @@ class InventoryItemTemplateForm(ComponentTemplateForm):
|
|
|
component_type = initial.get('component_type')
|
|
component_type = initial.get('component_type')
|
|
|
component_id = initial.get('component_id')
|
|
component_id = initial.get('component_id')
|
|
|
|
|
|
|
|
- # Used for picking the default active tab for component selection
|
|
|
|
|
- self.no_component = True
|
|
|
|
|
-
|
|
|
|
|
if instance:
|
|
if instance:
|
|
|
# When editing set the initial value for component selection
|
|
# When editing set the initial value for component selection
|
|
|
for component_model in ContentType.objects.filter(MODULAR_COMPONENT_TEMPLATE_MODELS):
|
|
for component_model in ContentType.objects.filter(MODULAR_COMPONENT_TEMPLATE_MODELS):
|
|
|
if type(instance.component) is component_model.model_class():
|
|
if type(instance.component) is component_model.model_class():
|
|
|
initial[component_model.model] = instance.component
|
|
initial[component_model.model] = instance.component
|
|
|
- self.no_component = False
|
|
|
|
|
break
|
|
break
|
|
|
elif component_type and component_id:
|
|
elif component_type and component_id:
|
|
|
# When adding the InventoryItem from a component page
|
|
# When adding the InventoryItem from a component page
|
|
|
if content_type := ContentType.objects.filter(MODULAR_COMPONENT_TEMPLATE_MODELS).filter(pk=component_type).first():
|
|
if content_type := ContentType.objects.filter(MODULAR_COMPONENT_TEMPLATE_MODELS).filter(pk=component_type).first():
|
|
|
if component := content_type.model_class().objects.filter(pk=component_id).first():
|
|
if component := content_type.model_class().objects.filter(pk=component_id).first():
|
|
|
initial[content_type.model] = component
|
|
initial[content_type.model] = component
|
|
|
- self.no_component = False
|
|
|
|
|
|
|
|
|
|
kwargs['initial'] = initial
|
|
kwargs['initial'] = initial
|
|
|
|
|
|