-
Notifications
You must be signed in to change notification settings - Fork 4.2k
feat: entity link view and api #36190
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
Merged
ChrisChV
merged 8 commits into
openedx:master
from
open-craft:navin/fal-4006/course-libraries-page
Feb 18, 2025
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
d64f2e8
feat: entity link view
navinkarkera 58a60f5
refactor: entity link view
navinkarkera 3c36e72
chore: reorder imports
navinkarkera 8e43b2d
test: entity link view
navinkarkera 41d2b3a
docs: update method docs
navinkarkera 8e3a70d
Merge branch 'master' into navin/fal-4006/course-libraries-page
ChrisChV 1e74ac3
feat: add course libraries link in course content menu
navinkarkera eb313d2
Merge branch 'master' into navin/fal-4006/course-libraries-page
ChrisChV File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
cms/djangoapps/contentstore/rest_api/v2/serializers/__init__.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| """Module for v2 serializers.""" | ||
|
|
||
| from cms.djangoapps.contentstore.rest_api.v2.serializers.downstreams import PublishableEntityLinksSerializer | ||
| from cms.djangoapps.contentstore.rest_api.v2.serializers.home import CourseHomeTabSerializerV2 |
28 changes: 28 additions & 0 deletions
28
cms/djangoapps/contentstore/rest_api/v2/serializers/downstreams.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| """ | ||
| Serializers for upstream -> downstream entity links. | ||
| """ | ||
|
|
||
| from rest_framework import serializers | ||
|
|
||
| from cms.djangoapps.contentstore.models import PublishableEntityLink | ||
|
|
||
|
|
||
| class PublishableEntityLinksSerializer(serializers.ModelSerializer): | ||
| """ | ||
| Serializer for publishable entity links. | ||
| """ | ||
| upstream_context_title = serializers.CharField(read_only=True) | ||
| upstream_version = serializers.IntegerField(read_only=True) | ||
| ready_to_sync = serializers.SerializerMethodField() | ||
|
|
||
| def get_ready_to_sync(self, obj): | ||
| """Calculate ready_to_sync field""" | ||
| return bool( | ||
| obj.upstream_version and | ||
| obj.upstream_version > (obj.version_synced or 0) and | ||
| obj.upstream_version > (obj.version_declined or 0) | ||
| ) | ||
|
|
||
| class Meta: | ||
| model = PublishableEntityLink | ||
| exclude = ['upstream_block', 'uuid'] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@navinkarkera @ChrisChV @pomegranited The name of this is UpstreamListView, but in reality is a list of Downstreams. Consider the case where one upstream library block is linked to two downstream course blocks. How many times would it be represented in this API's response? Twice--one for each downstream.
That is why there is a commented-out class above this class called DownstreamListView... it was meant to be un-commented for this very API endpoint :) That's also why the docstring mentions some
NOT YET IMPLEMENTEDroutes around /downstreams/, and why downstreams/ is aPotential Future Pathin the urls.py.Could you please make a follow-up PR to fix this, and follow the API schema that the comments had recommended? (Otherwise, in terms of actual functionality, the API looks great :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kdmccormick Makes sense, I'll update it soon.