Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add extra fields options to relationships #65

Merged
merged 1 commit into from
Jul 7, 2023

Conversation

johanseto
Copy link
Collaborator

@johanseto johanseto commented Jul 7, 2023

Description

This change is applied to course-experience api.
The relations file inherit from json api relation but add the possibility to add some extra fields using a function. The function has to be passed through the new relation using get_extra_fields kwarg. There you can calculate a dict that would be added to corresponding relationhips field. The base json api only add id and type, with this change you cad add extra model attributes.
https://github.com/django-json-api/django-rest-framework-json-api/blob/main/rest_framework_json_api/relations.py#L255

Testing instructions

Clone the repo and check anything is broken and the feedback API work with it same functionality.

After

image

Additional information

jira story:
https://edunext.atlassian.net/jira/software/c/projects/FUTUREX/boards/36?modal=detail&selectedIssue=FUTUREX-459

Checklist for Merge

  • Tested in a remote environment
  • Updated documentation
  • Rebased master/main
  • Squashed commits

@johanseto johanseto force-pushed the jlc/add-relations-extra-field branch from fc078eb to 9637e2d Compare July 7, 2023 22:46
This change is applied to course-experience api.
The relations file inherit from json api relation but add the
possibility to add some extra fields using a function.
The function has to be passed through the new relation using `get_extra_fields` kwarg.
There you can calculate a dict that would be added to corresponding relationhips field.
The base json api only add id and type, with this change you cad add extra model
attributes.
https://github.com/django-json-api/django-rest-framework-json-api/blob/main/rest_framework_json_api/relations.py#L255

chore: pr suggestions

Co-authored-by: Andrey Cañon <[email protected]>
@johanseto johanseto force-pushed the jlc/add-relations-extra-field branch from 9637e2d to a345957 Compare July 7, 2023 22:48
@johanseto johanseto merged commit 9d3b7ab into master Jul 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants