Example #1
0
    def revert_to_published(self, location, user_id):
        """
        Reverts an item to its last published version (recursively traversing all of its descendants).
        If no published version exists, a VersionConflictError is thrown.

        If a published version exists but there is no draft version of this item or any of its descendants, this
        method is a no-op.

        :raises InvalidVersionError: if no published version exists for the location specified
        """
        if location.category in DIRECT_ONLY_CATEGORIES:
            return

        if not self.has_item(location, revision=ModuleStoreEnum.RevisionOption.published_only):
            raise InvalidVersionError(location)

        SplitMongoModuleStore.copy(
            self,
            user_id,
            # Directly using the replace function rather than the for_branch function
            # because for_branch obliterates the version_guid and will lead to missed version conflicts.
            # TODO Instead, the for_branch implementation should be fixed in the Opaque Keys library.
            location.course_key.replace(branch=ModuleStoreEnum.BranchName.published),
            location.course_key.for_branch(ModuleStoreEnum.BranchName.draft),
            [location]
        )
Example #2
0
 def publish(self, location, user_id, **kwargs):
     """
     Save a current draft to the underlying modulestore.
     Returns the newly published item.
     """
     SplitMongoModuleStore.copy(
         self,
         user_id,
         location.course_key.for_branch(ModuleStoreEnum.BranchName.draft),
         location.course_key.for_branch(ModuleStoreEnum.BranchName.published),
         [location],
     )
Example #3
0
 def publish(self, location, user_id, **kwargs):
     """
     Save a current draft to the underlying modulestore.
     Returns the newly published item.
     """
     SplitMongoModuleStore.copy(
         self,
         user_id,
         location.course_key.for_branch(ModuleStoreEnum.BranchName.draft),
         location.course_key.for_branch(
             ModuleStoreEnum.BranchName.published),
         [location],
     )
Example #4
0
 def publish(self, location, user_id, blacklist=None, **kwargs):
     """
     Publishes the subtree under location from the draft branch to the published branch
     Returns the newly published item.
     """
     SplitMongoModuleStore.copy(
         self,
         user_id,
         # Directly using the replace function rather than the for_branch function
         # because for_branch obliterates the version_guid and will lead to missed version conflicts.
         location.course_key.replace(branch=ModuleStoreEnum.BranchName.draft),
         location.course_key.for_branch(ModuleStoreEnum.BranchName.published),
         [location],
         blacklist=blacklist
     )
     return self.get_item(location.for_branch(ModuleStoreEnum.BranchName.published), **kwargs)
Example #5
0
 def publish(self, location, user_id, blacklist=None, **kwargs):
     """
     Publishes the subtree under location from the draft branch to the published branch
     Returns the newly published item.
     """
     SplitMongoModuleStore.copy(
         self,
         user_id,
         # Directly using the replace function rather than the for_branch function
         # because for_branch obliterates the version_guid and will lead to missed version conflicts.
         # TODO Instead, the for_branch implementation should be fixed in the Opaque Keys library.
         location.course_key.replace(branch=ModuleStoreEnum.BranchName.draft),
         # We clear out the version_guid here because the location here is from the draft branch, and that
         # won't have the same version guid
         location.course_key.replace(branch=ModuleStoreEnum.BranchName.published, version_guid=None),
         [location],
         blacklist=blacklist
     )
     return self.get_item(location.for_branch(ModuleStoreEnum.BranchName.published), **kwargs)
Example #6
0
 def publish(self, location, user_id, blacklist=None, **kwargs):
     """
     Publishes the subtree under location from the draft branch to the published branch
     Returns the newly published item.
     """
     SplitMongoModuleStore.copy(
         self,
         user_id,
         # Directly using the replace function rather than the for_branch function
         # because for_branch obliterates the version_guid and will lead to missed version conflicts.
         location.course_key.replace(branch=ModuleStoreEnum.BranchName.draft
                                     ),
         location.course_key.for_branch(
             ModuleStoreEnum.BranchName.published),
         [location],
         blacklist=blacklist)
     return self.get_item(
         location.for_branch(ModuleStoreEnum.BranchName.published),
         **kwargs)