Skip to content

Make the "Related Objects" pane of all models dynamic #15794

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

Closed
alehaa opened this issue Apr 20, 2024 · 2 comments · Fixed by #15876
Closed

Make the "Related Objects" pane of all models dynamic #15794

alehaa opened this issue Apr 20, 2024 · 2 comments · Fixed by #15876
Assignees
Labels
complexity: medium Requires a substantial but not unusual amount of effort to implement status: accepted This issue has been accepted for implementation type: feature Introduction of new functionality to the application

Comments

@alehaa
Copy link
Contributor

alehaa commented Apr 20, 2024

NetBox version

v3.7.5

Feature type

Change to existing functionality

Proposed functionality

In #13794, extending the "Related Objects" by other showing other models was requested and implemented by dynamically listing counts for all ManyToMany reverse relationships. Now, I'd like to copy this functionality to all other uses of the "Related Objects" pane,

Use case

As described in #13794, it might be useful for plugins to link their data to existing NetBox core models. However, this is not only useful for tenancy, but any object relationship could benefit from this.

A real life example is covered by the NetBox inventory plugin: Hardware assets are related to dcim.Device, dcim.Manufacturer, dcim.Site and dcim.Location. They would benefit from quick access to a list of related assets for these models. Right now an extra pane needs to be implemented, so there are actually two "Related Objects" panes per details page.

Also, this would make this feature work consistently across all views in NetBox, so the maintenance overhead should theoretically be reduced.

Database changes

None

External dependencies

None

@alehaa alehaa added status: needs triage This issue is awaiting triage by a maintainer type: feature Introduction of new functionality to the application labels Apr 20, 2024
@alehaa
Copy link
Contributor Author

alehaa commented Apr 20, 2024

I've already tested using the code from TenantView in other views and can provide a PR for the changes requested.

@arthanson arthanson added status: under review Further discussion is needed to determine this issue's scope and/or implementation and removed status: needs triage This issue is awaiting triage by a maintainer labels Apr 22, 2024
@arthanson arthanson removed their assignment Apr 22, 2024
@arthanson
Copy link
Collaborator

@alehaa sounds good, I'll assign to you - Note: you should capture the existing logic into a reusable function (vs. copying and pasting the current get_extra_context() for TenantView)

@arthanson arthanson added status: accepted This issue has been accepted for implementation and removed status: under review Further discussion is needed to determine this issue's scope and/or implementation labels Apr 22, 2024
alehaa added a commit to alehaa/netbox that referenced this issue Apr 28, 2024
Instead of hardcoding relationships between models for the detail view,
they are now dynamically generated.
@jeremystretch jeremystretch added the complexity: medium Requires a substantial but not unusual amount of effort to implement label May 21, 2024
jeremystretch added a commit that referenced this issue Jun 12, 2024
* Closes #15794: Make "related objects" dynamic

Instead of hardcoding relationships between models for the detail view,
they are now dynamically generated.

* Fix related models call

* Remove extra related models hook

Instead of providing a rarely used hook method, additional related
models can now be passed directly to the lookup method.

* Fix relations view for ASNs

ASNs have ManyToMany relationships and therefore can't used automatic
resolving. Explicit relations have been restored as before.

* Add method call keywords for clarification

* Cleanup related models

---------

Co-authored-by: Jeremy Stretch <[email protected]>
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 11, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
complexity: medium Requires a substantial but not unusual amount of effort to implement status: accepted This issue has been accepted for implementation type: feature Introduction of new functionality to the application
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants