|
|
@@ -705,18 +705,19 @@ class ModuleForm(NetBoxModelForm):
|
|
|
# Get the templates for the module type.
|
|
|
for template in getattr(module_type, templates).all():
|
|
|
# Installing modules with placeholders require that the bay has a position value
|
|
|
- if '{module}' in template.name and not module_bay.position:
|
|
|
+ if MODULE_TOKEN in template.name and not module_bay.position:
|
|
|
raise forms.ValidationError(
|
|
|
"Cannot install module with placeholder values in a module bay with no position defined"
|
|
|
)
|
|
|
|
|
|
- resolved_name = template.name.replace('{module}', module_bay.position)
|
|
|
+ resolved_name = template.name.replace(MODULE_TOKEN, module_bay.position)
|
|
|
existing_item = installed_components.get(resolved_name)
|
|
|
|
|
|
# It is not possible to adopt components already belonging to a module
|
|
|
if adopt_components and existing_item and existing_item.module:
|
|
|
raise forms.ValidationError(
|
|
|
- f"Cannot adopt {template.component_model.__name__} '{resolved_name}' as it already belongs to a module"
|
|
|
+ f"Cannot adopt {template.component_model.__name__} '{resolved_name}' as it already belongs "
|
|
|
+ f"to a module"
|
|
|
)
|
|
|
|
|
|
# If we are not adopting components we error if the component exists
|