'Turn the published version into a draft, removing the published version.
NOTE: unlike publish, this gives an error if called above the draftable level as it\'s intended
to remove things from the published version'

def unpublish(self, location, user_id, **kwargs):

    if (location.category in DIRECT_ONLY_CATEGORIES):
        raise InvalidVersionError(location)
    self._verify_branch_setting(ModuleStoreEnum.Branch.draft_preferred)
    self._convert_to_draft(location, user_id, delete_published=True)
    course_key = location.course_key
    self._flag_publish_event(course_key)
