Fixes #4477 - Host[group] form only show authorized resources
Previously, most dropdowns in the host and hostgroup edit forms displayed all of the existing resources, including some that a user may not have been authorized to view. This commit makes sure only authorized resources are displayed, with the exception of the current resource - so that editing a host will not cause changes to its current associations in case the user is not allowed to see them. This also includes a refactoring of the code to reduce duplication. I have also included a change to `with_taxonomy_scope_override` that allows its use for relations. This was not previously possible due to the `.unscoped` which was used to remove the default scope and has been replaced with `.unscope(:where => :taxonomy)` that only removes any previous taxonomy scopes.
Related issues
Feature #4477: Improve permissions on resources in host creation/editing form
Fixes #4477 - Host[group] form only show authorized resources
Previously, most dropdowns in the host and hostgroup edit forms
displayed all of the existing resources, including some that a user may
not have been authorized to view.
This commit makes sure only authorized resources are displayed, with the
exception of the current resource - so that editing a host will not
cause changes to its current associations in case the user is not
allowed to see them. This also includes a refactoring of the code to
reduce duplication.
I have also included a change to `with_taxonomy_scope_override` that
allows its use for relations. This was not previously possible due to
the `.unscoped` which was used to remove the default scope and has been
replaced with `.unscope(:where => :taxonomy)` that only removes any
previous taxonomy scopes.