Skip to content

[RFR] [OSF-8498] API: Add id and type to relationships#7702

Closed
TomBaxter wants to merge 1 commit into
CenterForOpenScience:developfrom
TomBaxter:feature/osf-8498
Closed

[RFR] [OSF-8498] API: Add id and type to relationships#7702
TomBaxter wants to merge 1 commit into
CenterForOpenScience:developfrom
TomBaxter:feature/osf-8498

Conversation

@TomBaxter

Copy link
Copy Markdown
Member

[#OSF-8498]

Purpose

Return relationship data for those relations of the form...
proto://host:port/v2//<namespace_id>/

Changes

Update api/base/serializers.py::RelationshipField::to_representation to add "data" to "relationships"

Side effects

This PR makes assumptions about the form of endpoint URLs and the naming standard of kwargs passed to views. I don't believe that failures to live up to my assumptions will result in returning bad data, it should result in no passed data, but bad data is a possibility.

Ticket

OSF-8498

Comment thread api/base/serializers.py Outdated
if related_url and (len(related_path.split('/')) & 1) == 1:
resolved_url = resolve(related_path)
related_class = resolved_url.func.view_class
if not hasattr(related_class, 'LIST_FIELDS'):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed, better to check if the view derives from mixins.mixins.RetrieveModelMixin or doesn't derive from mixins.ListModelMixin

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Complete. I'll add a test and set ticket to CR.

[#OSF-8498]
Return relationship data for those relations of the form...
proto://host:port/v2/<namespace>/<namespace_id>/
@TomBaxter TomBaxter changed the title [WIP] [OSF-8498] API: Add id and type to relationships [RFR] [OSF-8498] API: Add id and type to relationships Sep 20, 2017
@TomBaxter

Copy link
Copy Markdown
Member Author

Merged in #7807

@TomBaxter TomBaxter closed this Nov 14, 2017
@TomBaxter
TomBaxter deleted the feature/osf-8498 branch November 14, 2017 15:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants