Commit 934d4e8a by Nimisha Asthagiri

Make Split Course work with new Publishing UI.

parent f10bcc1e
...@@ -152,6 +152,8 @@ class CachingDescriptorSystem(MakoDescriptorSystem): ...@@ -152,6 +152,8 @@ class CachingDescriptorSystem(MakoDescriptorSystem):
edit_info = json_data.get('edit_info', {}) edit_info = json_data.get('edit_info', {})
module.edited_by = edit_info.get('edited_by') module.edited_by = edit_info.get('edited_by')
module.edited_on = edit_info.get('edited_on') module.edited_on = edit_info.get('edited_on')
module.subtree_edited_by = None # TODO - addressed with LMS-11183
module.subtree_edited_on = None # TODO - addressed with LMS-11183
module.published_by = None # TODO - addressed with LMS-11184 module.published_by = None # TODO - addressed with LMS-11184
module.published_date = None # TODO - addressed with LMS-11184 module.published_date = None # TODO - addressed with LMS-11184
module.previous_version = edit_info.get('previous_version') module.previous_version = edit_info.get('previous_version')
......
...@@ -217,7 +217,7 @@ class DraftVersioningModuleStore(ModuleStoreDraftAndPublished, SplitMongoModuleS ...@@ -217,7 +217,7 @@ class DraftVersioningModuleStore(ModuleStoreDraftAndPublished, SplitMongoModuleS
return True return True
# check if the draft has changed since the published was created # check if the draft has changed since the published was created
return draft_block['edit_info']['update_version'] != published_block['edit_info']['source_version'] return self._get_version(draft_block) != self._get_version(published_block)
def publish(self, location, user_id, blacklist=None, **kwargs): def publish(self, location, user_id, blacklist=None, **kwargs):
...@@ -266,24 +266,13 @@ class DraftVersioningModuleStore(ModuleStoreDraftAndPublished, SplitMongoModuleS ...@@ -266,24 +266,13 @@ class DraftVersioningModuleStore(ModuleStoreDraftAndPublished, SplitMongoModuleS
PublishState.public - published exists and is the same as draft PublishState.public - published exists and is the same as draft
PublishState.private - no published version exists PublishState.private - no published version exists
""" """
def get_head(branch): draft_head = self._get_head(xblock, ModuleStoreEnum.BranchName.draft)
course_structure = self._lookup_course(xblock.location.course_key.for_branch(branch))['structure'] published_head = self._get_head(xblock, ModuleStoreEnum.BranchName.published)
return self._get_block_from_structure(course_structure, xblock.location.block_id)
def get_version(block):
"""
Return the version of the given database representation of a block.
"""
#TODO: make this method a more generic helper
return block['edit_info'].get('source_version', block['edit_info']['update_version'])
draft_head = get_head(ModuleStoreEnum.BranchName.draft)
published_head = get_head(ModuleStoreEnum.BranchName.published)
if not published_head: if not published_head:
# published version does not exist # published version does not exist
return PublishState.private return PublishState.private
elif get_version(draft_head) == get_version(published_head): elif self._get_version(draft_head) == self._get_version(published_head):
# published and draft versions are equal # published and draft versions are equal
return PublishState.public return PublishState.public
else: else:
...@@ -298,3 +287,14 @@ class DraftVersioningModuleStore(ModuleStoreDraftAndPublished, SplitMongoModuleS ...@@ -298,3 +287,14 @@ class DraftVersioningModuleStore(ModuleStoreDraftAndPublished, SplitMongoModuleS
""" """
# This is a no-op in Split since a draft version of the data always remains # This is a no-op in Split since a draft version of the data always remains
pass pass
def _get_head(self, xblock, branch):
course_structure = self._lookup_course(xblock.location.course_key.for_branch(branch))['structure']
return self._get_block_from_structure(course_structure, xblock.location.block_id)
def _get_version(self, block):
"""
Return the version of the given database representation of a block.
"""
return block['edit_info'].get('source_version', block['edit_info']['update_version'])
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment