Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make the "Related Objects" pane in the detail view for "Tenant" extensible #13794

Closed
peteeckel opened this issue Sep 18, 2023 · 3 comments
Closed
Assignees
Labels
status: accepted This issue has been accepted for implementation type: feature Introduction of new functionality to the application
Milestone

Comments

@peteeckel
Copy link
Contributor

peteeckel commented Sep 18, 2023

NetBox version

v3.6.1

Feature type

Change to existing functionality

Proposed functionality

On the right side of the detail view for a "Tenant" object there is a list of NetBox core models and object counts the tenant is assigned to. Currently the list of models in this view is hardcoded in tenancy.TenantView.get_extra_content().

It would be helpful for plugins supporting tenancy if that list could be extended, e.g. by providing a decorator that could be applied to models using tenancy similar to the mechanism used for the global search index.

Use case

In many cases it makes sense for plugins to use tenancy to indicate the ownership of or responsibility for objects, making it easier to filter for objects related, for instance, to a specific customer or department.

While tenancy itself is easy to implement, this does not reflect in the list of related objects for a tenant. The detail view for a tenant only shows NetBox core objects that are assigned to the tenant, not objects of plugin models.

This is especially annoying when a user wants to delete a tenant object, which is usually related to the target object using the referential integrity option models.PROTECT. So even if there are no related objects shown in the tenant view, the tenant still can't be deleted because there are unlisted objects still owned by it in the plugin's models.

Database changes

Unknown, probably none - depending on how this can be implemented.

External dependencies

None.

@peteeckel peteeckel added the type: feature Introduction of new functionality to the application label Sep 18, 2023
@abhi1693
Copy link
Member

this does not reflect in the list of related objects for a tenant.

You can use the template content or tab view to inject the additional views which will help with your use case.

@peteeckel
Copy link
Contributor Author

peteeckel commented Sep 18, 2023

Yes, adding a tab or an additional pane via template content (eventually it became the latter as that's less diverting from the original contents of the view) was actually what I had in mind as a workaround.

@jeremystretch
Copy link
Member

Rather than requiring other models to register explicitly, we should be able to infer many-to-one relationships from the Tenant model, and display the object count for each.

@jeremystretch jeremystretch added the status: accepted This issue has been accepted for implementation label Nov 6, 2023
@jeremystretch jeremystretch self-assigned this Nov 6, 2023
@jeremystretch jeremystretch added this to the v3.7 milestone Nov 6, 2023
jeremystretch added a commit that referenced this issue Nov 16, 2023
… view (#14196)

* Closes #13794: Dynamically populate related objects list under tenant view

* get_related_models() should sort models alphabetically by default

* Reference Meta.related_objects instead of calling get_fields()
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 15, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status: accepted This issue has been accepted for implementation type: feature Introduction of new functionality to the application
Projects
None yet
Development

No branches or pull requests

3 participants