mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Closes #10816: Pass the current request when instantiating a FilterSet within UI views
This commit is contained in:
@ -56,6 +56,7 @@ A new `PluginMenu` class has been introduced, which enables a plugin to inject a
|
||||
* [#9046](https://github.com/netbox-community/netbox/issues/9046) - Remove legacy contact fields from provider model
|
||||
* [#10358](https://github.com/netbox-community/netbox/issues/10358) - Raise minimum required PostgreSQL version from 10 to 11
|
||||
* [#10699](https://github.com/netbox-community/netbox/issues/10699) - Remove custom `import_object()` function
|
||||
* [#10816](https://github.com/netbox-community/netbox/issues/10816) - Pass the current request when instantiating a FilterSet within UI views
|
||||
|
||||
### REST API Changes
|
||||
|
||||
|
@ -126,7 +126,7 @@ class ObjectListView(BaseMultiObjectView, ActionsMixin, TableMixin):
|
||||
content_type = ContentType.objects.get_for_model(model)
|
||||
|
||||
if self.filterset:
|
||||
self.queryset = self.filterset(request.GET, self.queryset).qs
|
||||
self.queryset = self.filterset(request.GET, self.queryset, request=request).qs
|
||||
|
||||
# Determine the available actions
|
||||
actions = self.get_permitted_actions(request.user)
|
||||
@ -544,7 +544,7 @@ class BulkEditView(GetReturnURLMixin, BaseMultiObjectView):
|
||||
|
||||
# If we are editing *all* objects in the queryset, replace the PK list with all matched objects.
|
||||
if request.POST.get('_all') and self.filterset is not None:
|
||||
pk_list = self.filterset(request.GET, self.queryset.values_list('pk', flat=True)).qs
|
||||
pk_list = self.filterset(request.GET, self.queryset.values_list('pk', flat=True), request=request).qs
|
||||
else:
|
||||
pk_list = request.POST.getlist('pk')
|
||||
|
||||
@ -741,7 +741,7 @@ class BulkDeleteView(GetReturnURLMixin, BaseMultiObjectView):
|
||||
if request.POST.get('_all'):
|
||||
qs = model.objects.all()
|
||||
if self.filterset is not None:
|
||||
qs = self.filterset(request.GET, qs).qs
|
||||
qs = self.filterset(request.GET, qs, request=request).qs
|
||||
pk_list = qs.only('pk').values_list('pk', flat=True)
|
||||
else:
|
||||
pk_list = [int(pk) for pk in request.POST.getlist('pk')]
|
||||
@ -828,7 +828,8 @@ class BulkComponentCreateView(GetReturnURLMixin, BaseMultiObjectView):
|
||||
|
||||
# Are we editing *all* objects in the queryset or just a selected subset?
|
||||
if request.POST.get('_all') and self.filterset is not None:
|
||||
pk_list = [obj.pk for obj in self.filterset(request.GET, self.parent_model.objects.only('pk')).qs]
|
||||
queryset = self.filterset(request.GET, self.parent_model.objects.only('pk'), request=request).qs
|
||||
pk_list = [obj.pk for obj in queryset]
|
||||
else:
|
||||
pk_list = [int(pk) for pk in request.POST.getlist('pk')]
|
||||
|
||||
|
@ -126,7 +126,7 @@ class ObjectChildrenView(ObjectView, ActionsMixin, TableMixin):
|
||||
child_objects = self.get_children(request, instance)
|
||||
|
||||
if self.filterset:
|
||||
child_objects = self.filterset(request.GET, child_objects).qs
|
||||
child_objects = self.filterset(request.GET, child_objects, request=request).qs
|
||||
|
||||
# Determine the available actions
|
||||
actions = self.get_permitted_actions(request.user, model=self.child_model)
|
||||
|
Reference in New Issue
Block a user