diff --git a/docs/release-notes/version-2.9.md b/docs/release-notes/version-2.9.md index 7defe5317..101788aff 100644 --- a/docs/release-notes/version-2.9.md +++ b/docs/release-notes/version-2.9.md @@ -20,6 +20,7 @@ * [#5133](https://github.com/netbox-community/netbox/issues/5133) - Fix disassociation of an IP address from a VM interface * [#5136](https://github.com/netbox-community/netbox/issues/5136) - Fix exception when bulk editing interface 802.1Q mode * [#5156](https://github.com/netbox-community/netbox/issues/5156) - Add missing "add" button to rack reservations list +* [#5167](https://github.com/netbox-community/netbox/issues/5167) - Support filtering ObjectChanges by multiple users --- diff --git a/netbox/extras/filters.py b/netbox/extras/filters.py index 1af98e885..865c693e7 100644 --- a/netbox/extras/filters.py +++ b/netbox/extras/filters.py @@ -1,4 +1,5 @@ import django_filters +from django.contrib.auth.models import User from django.contrib.contenttypes.models import ContentType from django.db.models import Q @@ -259,12 +260,21 @@ class ObjectChangeFilterSet(BaseFilterSet): label='Search', ) time = django_filters.DateTimeFromToRangeFilter() + user_id = django_filters.ModelMultipleChoiceFilter( + queryset=User.objects.all(), + label='User (ID)', + ) + user = django_filters.ModelMultipleChoiceFilter( + field_name='user__username', + queryset=User.objects.all(), + to_field_name='username', + label='User name', + ) class Meta: model = ObjectChange fields = [ - 'id', 'user', 'user_name', 'request_id', 'action', 'changed_object_type', 'changed_object_id', - 'object_repr', + 'id', 'user_name', 'request_id', 'action', 'changed_object_type', 'changed_object_id', 'object_repr', ] def search(self, queryset, name, value): diff --git a/netbox/extras/forms.py b/netbox/extras/forms.py index 90ec828c7..c88e66262 100644 --- a/netbox/extras/forms.py +++ b/netbox/extras/forms.py @@ -397,10 +397,11 @@ class ObjectChangeFilterForm(BootstrapMixin, forms.Form): required=False, widget=StaticSelect2() ) - user = DynamicModelMultipleChoiceField( + user_id = DynamicModelMultipleChoiceField( queryset=User.objects.all(), required=False, display_field='username', + label='User', widget=APISelectMultiple( api_url='/api/users/users/', )