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
|
* [#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
|
* [#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
|
* [#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
|
### REST API Changes
|
||||||
|
|
||||||
|
@ -126,7 +126,7 @@ class ObjectListView(BaseMultiObjectView, ActionsMixin, TableMixin):
|
|||||||
content_type = ContentType.objects.get_for_model(model)
|
content_type = ContentType.objects.get_for_model(model)
|
||||||
|
|
||||||
if self.filterset:
|
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
|
# Determine the available actions
|
||||||
actions = self.get_permitted_actions(request.user)
|
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 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:
|
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:
|
else:
|
||||||
pk_list = request.POST.getlist('pk')
|
pk_list = request.POST.getlist('pk')
|
||||||
|
|
||||||
@ -741,7 +741,7 @@ class BulkDeleteView(GetReturnURLMixin, BaseMultiObjectView):
|
|||||||
if request.POST.get('_all'):
|
if request.POST.get('_all'):
|
||||||
qs = model.objects.all()
|
qs = model.objects.all()
|
||||||
if self.filterset is not None:
|
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)
|
pk_list = qs.only('pk').values_list('pk', flat=True)
|
||||||
else:
|
else:
|
||||||
pk_list = [int(pk) for pk in request.POST.getlist('pk')]
|
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?
|
# Are we editing *all* objects in the queryset or just a selected subset?
|
||||||
if request.POST.get('_all') and self.filterset is not None:
|
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:
|
else:
|
||||||
pk_list = [int(pk) for pk in request.POST.getlist('pk')]
|
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)
|
child_objects = self.get_children(request, instance)
|
||||||
|
|
||||||
if self.filterset:
|
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
|
# Determine the available actions
|
||||||
actions = self.get_permitted_actions(request.user, model=self.child_model)
|
actions = self.get_permitted_actions(request.user, model=self.child_model)
|
||||||
|
Reference in New Issue
Block a user