Fixes 16536 - Fix filtering of device component by device role #16553
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes: #16536
Fix the filtering of device components by device role by aligning the name of the fields from the DeviceComponentFilterForm and the DeviceComponentFilterSet.
I saw two solutions to implement the fix:
device_role_id
anddevice_role
(that's the one I've implemented)role_id
but create an exception for InventoryItemFilterSet and InventoryItemFilterForm, which already have a field namedrole
for the InventoryItemRoleI've chosen solution 1 because:
device_role
makes more sense asrole
could be confused with the role of the component.role
field override the role field from DeviceComponentFilterSet, and would have needed adevice_role
field or equivalent to preserve the feature. The role filter of DeviceComponent would have a different meaning between an Interface or a InventoryItem, which would have been more confusing.However, solution 1 also changes the API to filter the device components by roles. This was an undocumented change in 4.0, so maybe that's acceptable.
Please let me know if you agree with that approach or if you prefer another solution.