Skip to content

Commit

Permalink
Fix self url for PreprintsInstitutionsRelationshipSerializer
Browse files Browse the repository at this point in the history
In addition, removed the superfluous 'html' link that is not
part of JSON:API specs.
  • Loading branch information
cslzchen committed Sep 16, 2024
1 parent dadfbae commit d8139b8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 1 addition & 5 deletions api/preprints/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -610,14 +610,10 @@ class PreprintsInstitutionsRelationshipSerializer(BaseAPISerializer):

links = LinksField({
'self': 'get_self_url',
'html': 'get_related_url',
})

def get_self_url(self, obj):
return obj['self'].absolute_api_v2_url

def get_related_url(self, obj):
return f"{obj['self'].absolute_api_v2_url}institutions/"
return obj['self'].institutions_relationship_url

class Meta:
type_ = 'institutions'
Expand Down
4 changes: 4 additions & 0 deletions osf/models/preprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,10 @@ def display_absolute_url(self):
def linked_nodes_self_url(self):
return self.absolute_api_v2_url + 'relationships/node/'

@property
def institutions_relationship_url(self):
return self.absolute_api_v2_url + 'relationships/institutions/'

@property
def admin_contributor_or_group_member_ids(self):
# Overrides ContributorMixin
Expand Down

0 comments on commit d8139b8

Please sign in to comment.