11
11
from api .base .parsers import JSONAPIMultipleRelationshipsParser , JSONAPIMultipleRelationshipsParserForRegularJSON
12
12
13
13
from api .base .views import JSONAPIBaseView
14
- from api .base .views import BaseLinkedList
15
14
from api .base .views import LinkedNodesRelationship
16
15
from api .nodes .utils import NodeOptimizationMixin
17
16
@@ -507,7 +506,7 @@ def get_resource(self, check_object_permissions=True):
507
506
return self .get_collection_submission (check_object_permissions )
508
507
509
508
510
- class LinkedNodesList (BaseLinkedList , CollectionMixin , NodeOptimizationMixin ):
509
+ class LinkedNodesList (JSONAPIBaseView , generics . ListAPIView , CollectionMixin , NodeOptimizationMixin ):
511
510
"""List of nodes linked to this node. *Read-only*.
512
511
513
512
Linked nodes are the project/component nodes pointed to by node links. This view will probably replace node_links in the near future.
@@ -560,6 +559,10 @@ class LinkedNodesList(BaseLinkedList, CollectionMixin, NodeOptimizationMixin):
560
559
CollectionWriteOrPublic ,
561
560
base_permissions .TokenHasScope ,
562
561
)
562
+
563
+ required_read_scopes = [CoreScopes .COLLECTED_META_READ ]
564
+ required_write_scopes = [CoreScopes .COLLECTED_META_WRITE ]
565
+
563
566
serializer_class = NodeSerializer
564
567
view_category = 'collections'
565
568
view_name = 'linked-nodes'
@@ -582,7 +585,7 @@ def get_parser_context(self, http_request):
582
585
return res
583
586
584
587
585
- class LinkedRegistrationsList (BaseLinkedList , CollectionMixin ):
588
+ class LinkedRegistrationsList (JSONAPIBaseView , generics . ListAPIView , CollectionMixin ):
586
589
"""List of registrations linked to this node. *Read-only*.
587
590
588
591
Linked registrations are the registration nodes pointed to by node links.
@@ -656,11 +659,22 @@ class LinkedRegistrationsList(BaseLinkedList, CollectionMixin):
656
659
view_category = 'collections'
657
660
view_name = 'linked-registrations'
658
661
662
+ required_read_scopes = [CoreScopes .COLLECTED_META_READ ]
663
+ required_write_scopes = [CoreScopes .COLLECTED_META_WRITE ]
664
+
659
665
ordering = ('-modified' ,)
660
666
661
667
def get_queryset (self ):
662
668
auth = get_user_auth (self .request )
663
- return Registration .objects .filter (guids__in = self .get_collection ().active_guids .all (), is_deleted = False ).can_view (user = auth .user , private_link = auth .private_link ).order_by ('-modified' )
669
+ return Registration .objects .filter (
670
+ guids__in = self .get_collection ().active_guids .all (),
671
+ is_deleted = False ,
672
+ ).can_view (
673
+ user = auth .user ,
674
+ private_link = auth .private_link ,
675
+ ).order_by (
676
+ '-modified' ,
677
+ )
664
678
665
679
# overrides APIView
666
680
def get_parser_context (self , http_request ):
@@ -672,7 +686,7 @@ def get_parser_context(self, http_request):
672
686
return res
673
687
674
688
675
- class LinkedPreprintsList (BaseLinkedList , CollectionMixin ):
689
+ class LinkedPreprintsList (JSONAPIBaseView , generics . ListAPIView , CollectionMixin ):
676
690
"""List of preprints linked to this collection. *Read-only*.
677
691
"""
678
692
permission_classes = (
@@ -684,6 +698,9 @@ class LinkedPreprintsList(BaseLinkedList, CollectionMixin):
684
698
view_category = 'collections'
685
699
view_name = 'linked-preprints'
686
700
701
+ required_read_scopes = [CoreScopes .COLLECTED_META_READ ]
702
+ required_write_scopes = [CoreScopes .COLLECTED_META_WRITE ]
703
+
687
704
ordering = ('-modified' ,)
688
705
689
706
def get_queryset (self ):
0 commit comments