netbox/docs
Mark Robert Coleman a06a300913
Implement {module} position inheritance for nested module bays (#21753)
* Implement {module} position inheritance for nested module bays (#19796)

Enables a single ModuleType to produce correctly named components at any
nesting depth by resolving {module} in module bay position fields during
tree traversal. The user controls the separator through the position
field template itself (e.g. {module}/1 vs {module}-1 vs {module}.1).

Model layer:
- Add _get_inherited_positions() to resolve {module} in positions as
  the module tree is walked from root to leaf
- Update _resolve_module_placeholder() with single-token logic: one
  {module} resolves to the leaf bay's inherited position; multi-token
  continues level-by-level replacement for backwards compatibility

Form layer:
- Update _get_module_bay_tree() to resolve {module} in positions during
  traversal, propagating parent positions through the tree
- Extract validation into _validate_module_tokens() private method

Tests:
- Position inheritance at depth 2 and 3
- Custom separator (dot notation)
- Multi-token backwards compatibility
- Documentation for position inheritance

Fixes: #19796

* Consolidate {module} placeholder logic into shared utilities and add API validation

Extract get_module_bay_positions() and resolve_module_placeholder() into
dcim/utils.py as shared routines used by the model, form, and API serializer.
This eliminates duplicated traversal and resolution logic across three layers.

Key changes:
- Add position inheritance: {module} tokens in bay position fields resolve
  using the parent bay's position during hierarchy traversal
- Single {module} token now resolves to the leaf bay's inherited position
- Mismatched token count vs tree depth now raises ValueError instead of
  silently producing partial strings
- API serializer validation uses shared utilities for parity with the form
- Fix error message wording ("levels deep" instead of "in tree")
2026-04-01 17:58:16 -07:00
..
_theme Closes #21635: Migrate from mkdocs to Zensical (#21742) 2026-03-25 16:48:29 +01:00
administration docs(guides): Update Ubuntu reference to 24.04 2026-01-26 15:43:59 -05:00
best-practices #20382: Additional GraphQL API tips (#20451) 2025-09-30 11:29:29 -04:00
configuration feat(core): Retain create & last update changelog records 2026-03-05 22:05:07 +01:00
customization Closes #19025: Add schema validation for JSON custom fields (#21746) 2026-03-31 12:41:49 -05:00
development feat(virtualization): Add Virtual Machine Type model 2026-03-31 09:10:02 -04:00
features feat(virtualization): Add Virtual Machine Type model 2026-03-31 09:10:02 -04:00
getting-started Update planning.md to cleanup grammar 2025-09-06 11:09:01 -04:00
installation docs(guides): Update Ubuntu reference to 24.04 2026-01-26 15:43:59 -05:00
integrations Merge branch 'main' into feature 2026-03-18 10:16:21 -04:00
media Fixes #19841: Add white background to upgrade paths image 2025-07-14 15:08:27 -04:00
models Implement {module} position inheritance for nested module bays (#21753) 2026-04-01 17:58:16 -07:00
plugins Merge branch 'main' into feature 2026-04-01 13:22:52 -04:00
reference #20175 Fix Grammatical Error Related To Capitalization 2025-08-25 14:28:35 -04:00
release-notes Release v4.5.6 2026-03-31 12:43:26 -04:00
extra.css Closes #21635: Migrate from mkdocs to Zensical (#21742) 2026-03-25 16:48:29 +01:00
index.md Closes #19611: Update index.md To Spell Acronym First Time It's Found (#19614) 2025-05-30 13:57:22 -05:00
introduction.md Closes #18820: Bump minimum PostgreSQL version to 14 (#18909) 2025-03-14 13:45:44 -05:00
netbox_logo_dark.svg Fixes: #17732 - Add a background-color to img elements in docs to ensure readability in dark mode (#17790) 2024-10-18 10:47:05 -04:00
netbox_logo_light.svg Fixes: #17732 - Add a background-color to img elements in docs to ensure readability in dark mode (#17790) 2024-10-18 10:47:05 -04:00