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

Add device and module type columns #161

Merged
merged 2 commits into from
Jul 16, 2024
Merged

Conversation

alehaa
Copy link
Contributor

@alehaa alehaa commented Apr 28, 2024

A linked count column added to the device and module type list tables allows for quick access to the associated assets, while providing an overview of the total assets managed as opposed to instances in use. This also allows both columns to be exported as CSV.

A linked count column added to the device and module type list tables
allows for quick access to the associated assets, while providing an
overview of the total assets managed as opposed to instances in use.
This also allows both columns to be exported as CSV.
@matejv
Copy link
Member

matejv commented May 6, 2024

Does this code work for you? I get zeros for all device types even those that have assets.

I think the issue is that we don't setup a reverse relation from Asset to DeviceType (...), see here.

I know this was done intentionally, however I can't remember why. It's possible I encountered some issues but it's also possible I didn't want to risk any namespace collisions. Eg. if netbox or other plugins tried to setup reverse relation with the same name. Django complains and fails in such case.

@alehaa
Copy link
Contributor Author

alehaa commented May 28, 2024

Hmm. Indeed, I had a reverse relationship requested for testing, but not committed. However, adding this could introduce new problems in the future as I'm working on a feature in NetBox to automatically display related objects. Assets of DeviceType and ModuleType objects would then be displayed twice in the related detail views.

I'll see if I can change the columns to use a dedicated lookup instead of relations.

@alehaa
Copy link
Contributor Author

alehaa commented May 29, 2024

I've added the reverse relation, which allows the columns to work now.

However, adding this could introduce new problems in the future as I'm working on a feature in NetBox to automatically display related objects.

This doesn't seem to be a problem. The detailed view of Assets with different kind is on the manufacturer's view. However, these relations would be shown on the views for DeviceType and ModuleType.

@matejv matejv merged commit d687fad into ArnesSI:master Jul 16, 2024
matejv added a commit that referenced this pull request Jul 16, 2024
altering name of reverse FK relations needs a
migration
@alehaa alehaa deleted the feature/columns branch February 9, 2025 09:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants