[PR #15203] [MERGED] Closes #15042: Move model registration logic to AppConfigs #14546

Closed
opened 2025-12-29 23:25:07 +01:00 by adam · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/netbox-community/netbox/pull/15203
Author: @jeremystretch
Created: 2/20/2024
Status: Merged
Merged: 2/21/2024
Merged by: @jeremystretch

Base: featureHead: 15042-model-registration


📝 Commits (2)

  • 62a0b52 Closes #15042: Move model registration logic to AppConfigs
  • 3b10cf1 Refactor register_model() to accept multiple models

📊 Changes

14 files changed (+100 additions, -70 deletions)

View changed files

📝 netbox/circuits/apps.py (+4 -0)
📝 netbox/core/apps.py (+5 -1)
📝 netbox/dcim/apps.py (+5 -1)
📝 netbox/extras/apps.py (+4 -0)
📝 netbox/extras/utils.py (+0 -20)
📝 netbox/ipam/apps.py (+4 -0)
📝 netbox/netbox/models/features.py (+48 -36)
📝 netbox/netbox/plugins/__init__.py (+5 -0)
📝 netbox/netbox/tests/test_plugins.py (+4 -0)
📝 netbox/tenancy/apps.py (+4 -0)
📝 netbox/users/apps.py (+4 -11)
📝 netbox/virtualization/apps.py (+5 -1)
📝 netbox/vpn/apps.py (+4 -0)
📝 netbox/wireless/apps.py (+4 -0)

📄 Description

Fixes: #15042

  • Move code from extras.utils.register_features() into netbox.models.features._register_features()
  • Rename netbox.models.features._register_features() to register_model()
  • Decouple model registration from the class_prepared signal
  • Call register_model() for each model under AppConfig.ready() for each app
  • Extend PluginConfig.ready() to also call register_model() for each model
  • Add a plugin test for model registration

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/netbox-community/netbox/pull/15203 **Author:** [@jeremystretch](https://github.com/jeremystretch) **Created:** 2/20/2024 **Status:** ✅ Merged **Merged:** 2/21/2024 **Merged by:** [@jeremystretch](https://github.com/jeremystretch) **Base:** `feature` ← **Head:** `15042-model-registration` --- ### 📝 Commits (2) - [`62a0b52`](https://github.com/netbox-community/netbox/commit/62a0b52237d72bd6cf10f450e9582f6fd2c00625) Closes #15042: Move model registration logic to AppConfigs - [`3b10cf1`](https://github.com/netbox-community/netbox/commit/3b10cf153cbb4048efed430411333e2b2ce1e7e0) Refactor register_model() to accept multiple models ### 📊 Changes **14 files changed** (+100 additions, -70 deletions) <details> <summary>View changed files</summary> 📝 `netbox/circuits/apps.py` (+4 -0) 📝 `netbox/core/apps.py` (+5 -1) 📝 `netbox/dcim/apps.py` (+5 -1) 📝 `netbox/extras/apps.py` (+4 -0) 📝 `netbox/extras/utils.py` (+0 -20) 📝 `netbox/ipam/apps.py` (+4 -0) 📝 `netbox/netbox/models/features.py` (+48 -36) 📝 `netbox/netbox/plugins/__init__.py` (+5 -0) 📝 `netbox/netbox/tests/test_plugins.py` (+4 -0) 📝 `netbox/tenancy/apps.py` (+4 -0) 📝 `netbox/users/apps.py` (+4 -11) 📝 `netbox/virtualization/apps.py` (+5 -1) 📝 `netbox/vpn/apps.py` (+4 -0) 📝 `netbox/wireless/apps.py` (+4 -0) </details> ### 📄 Description ### Fixes: #15042 - Move code from `extras.utils.register_features()` into `netbox.models.features._register_features()` - Rename `netbox.models.features._register_features()` to `register_model()` - Decouple model registration from the `class_prepared` signal - Call `register_model()` for each model under `AppConfig.ready()` for each app - Extend `PluginConfig.ready()` to also call `register_model()` for each model - Add a plugin test for model registration --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
adam added the pull-request label 2025-12-29 23:25:07 +01:00
adam closed this issue 2025-12-29 23:25:07 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#14546