From 6c187e45eccb8095291c8f074d75b2ab9ab76416 Mon Sep 17 00:00:00 2001 From: Anton Krytskyi Date: Fri, 14 Nov 2025 14:57:45 +0200 Subject: [PATCH] enable filtering by id for linked_nodes and linked_registrations --- api/base/views.py | 13 +++++++------ api/collections/views.py | 9 +++++++-- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/api/base/views.py b/api/base/views.py index a2e59cf7b0e..e0a253cd65e 100644 --- a/api/base/views.py +++ b/api/base/views.py @@ -38,7 +38,7 @@ from api.nodes.permissions import ExcludeWithdrawals from api.users.serializers import UserSerializer from framework.auth.oauth_scopes import CoreScopes -from osf.models import Contributor, MaintenanceState, BaseFileNode +from osf.models import Contributor, MaintenanceState, BaseFileNode, AbstractNode from osf.utils.permissions import API_CONTRIBUTOR_PERMISSIONS, READ, WRITE, ADMIN from waffle.models import Flag, Switch, Sample from waffle import sample_is_active @@ -600,7 +600,7 @@ def get_queryset(self): ) -class BaseLinkedList(JSONAPIBaseView, generics.ListAPIView): +class BaseLinkedList(JSONAPIBaseView, generics.ListAPIView, ListFilterMixin): permission_classes = ( drf_permissions.IsAuthenticatedOrReadOnly, @@ -618,11 +618,9 @@ class BaseLinkedList(JSONAPIBaseView, generics.ListAPIView): view_name = None ordering = ('-modified',) + model_class = AbstractNode - # TODO: This class no longer exists - # model_class = Pointer - - def get_queryset(self): + def get_default_queryset(self): auth = get_user_auth(self.request) from api.resources import annotations as resource_annotations @@ -639,6 +637,9 @@ def get_queryset(self): .order_by('-modified') ) + def get_queryset(self): + return self.get_queryset_from_request() + class WaterButlerMixin: diff --git a/api/collections/views.py b/api/collections/views.py index fb8d808f888..907a6fee571 100644 --- a/api/collections/views.py +++ b/api/collections/views.py @@ -569,6 +569,7 @@ class LinkedNodesList(JSONAPIBaseView, generics.ListAPIView, CollectionMixin, No view_name = 'linked-nodes' ordering = ('-modified',) + model_class = Node def get_default_queryset(self): auth = get_user_auth(self.request) @@ -589,7 +590,7 @@ def get_parser_context(self, http_request): return res -class LinkedRegistrationsList(JSONAPIBaseView, generics.ListAPIView, CollectionMixin): +class LinkedRegistrationsList(JSONAPIBaseView, generics.ListAPIView, CollectionMixin, ListFilterMixin): """List of registrations linked to this node. *Read-only*. Linked registrations are the registration nodes pointed to by node links. @@ -667,8 +668,9 @@ class LinkedRegistrationsList(JSONAPIBaseView, generics.ListAPIView, CollectionM required_write_scopes = [CoreScopes.COLLECTED_META_WRITE] ordering = ('-modified',) + model_class = Registration - def get_queryset(self): + def get_default_queryset(self): auth = get_user_auth(self.request) return Registration.objects.filter( guids__in=self.get_collection().active_guids.all(), @@ -680,6 +682,9 @@ def get_queryset(self): '-modified', ) + def get_queryset(self): + return self.get_queryset_from_request() + # overrides APIView def get_parser_context(self, http_request): """