-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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: basic get/post endpoint for v2 xblocks. TNL-10873 #32600
Conversation
2ea4170
to
e00cda1
Compare
5b4b53f
to
350a379
Compare
47b1c70
to
3e03662
Compare
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.
Thanks, looks good! I haven't tested this manually but I'm happy with the code.
} | ||
}, format='json') | ||
block_saved = xblock_api.load_block(block_key, self.staff_user) | ||
assert block_saved.data == '\n<p>test</p>\n' |
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.
Will it be an issue for the editors if some newlines go inserted here? This test set the data to '<p>test</p>'
but we get the data back as '\n<p>test</p>\n'
. I'm assuming that's fine but just want to confirm.
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.
no, in fact I don't think editors can have content without the newlines; it's just an artifact of what I wrote in the test.
@@ -133,7 +133,9 @@ def save_block(self, block): | |||
if not learning_context.can_edit_block(self.user, block.scope_ids.usage_id): | |||
log.warning("User %s does not have permission to edit %s", self.user.username, block.scope_ids.usage_id) | |||
raise RuntimeError("You do not have permission to edit this XBlock") | |||
olx_str, static_files = serialize_xblock(block) | |||
serialized = serialize_modulestore_block_for_blockstore(block) |
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.
I guess we should rename this function to just serialize_block_for_blockstore
since we're already passing in a blockstore block here.
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.
it is called in a bunch of other places.
3e03662
to
255d58b
Compare
7d58c41
to
99f7cdc
Compare
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.
Just some comments on comments for clarity. Code looks ok.
View to get/edit the field values of an XBlock as JSON (in the v2 runtime) | ||
|
||
This class mimics the functionality of xblock_handler in block.py (for v1 xblocks), but for v2 xblocks. | ||
However, it only implements the exact subset of functionality needed to support the v2 editors (from | ||
the frontend-lib-content-components project). As such, it only supports GET and POST, and only the | ||
POSTing of data/metadata fields. | ||
""" |
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.
View to get/edit the field values of an XBlock as JSON (in the v2 runtime) | |
This class mimics the functionality of xblock_handler in block.py (for v1 xblocks), but for v2 xblocks. | |
However, it only implements the exact subset of functionality needed to support the v2 editors (from | |
the frontend-lib-content-components project). As such, it only supports GET and POST, and only the | |
POSTing of data/metadata fields. | |
""" | |
View for the field values of an XBlock, returned as JSON. | |
This class mimics the functionality of the v1 xblock_handler in block.py. | |
However, it only implements the exact subset of functionality needed to support xblock editing, for a single xblock which has no children blocks. As such, it only supports GET and POST. | |
""" |
99f7cdc
to
d6f824d
Compare
2U Release Notice: This PR has been deployed to the edX staging environment in preparation for a release to production. |
2U Release Notice: This PR has been deployed to the edX production environment. |
feat: basic get/post endpoint for v2 xblocks. TNL-10873