def delete_skill(committer_id, skill_id, force_deletion=False): """Deletes the skill with the given skill_id. Args: committer_id: str. ID of the committer. skill_id: str. ID of the skill to be deleted. force_deletion: bool. If true, the skill and its history are fully deleted and are unrecoverable. Otherwise, the skill and all its history are marked as deleted, but the corresponding models are still retained in the datastore. This last option is the preferred one. """ skill_rights_model = skill_models.SkillRightsModel.get(skill_id) skill_rights_model.delete( committer_id, feconf.COMMIT_MESSAGE_SKILL_DELETED, force_deletion=force_deletion) skill_model = skill_models.SkillModel.get(skill_id) skill_model.delete( committer_id, feconf.COMMIT_MESSAGE_SKILL_DELETED, force_deletion=force_deletion) # This must come after the skill is retrieved. Otherwise the memcache # key will be reinstated. skill_memcache_key = _get_skill_memcache_key(skill_id) memcache_services.delete(skill_memcache_key) # Delete the summary of the skill (regardless of whether # force_deletion is True or not). delete_skill_summary(skill_id) opportunity_services.delete_skill_opportunity(skill_id)
def delete_skill(committer_id, skill_id, force_deletion=False): """Deletes the skill with the given skill_id. Args: committer_id: str. ID of the committer. skill_id: str. ID of the skill to be deleted. force_deletion: bool. If true, the skill and its history are fully deleted and are unrecoverable. Otherwise, the skill and all its history are marked as deleted, but the corresponding models are still retained in the datastore. This last option is the preferred one. """ skill_models.SkillModel.delete_multi( [skill_id], committer_id, '', force_deletion=force_deletion) # This must come after the skill is retrieved. Otherwise the memcache # key will be reinstated. caching_services.delete_multi( caching_services.CACHE_NAMESPACE_SKILL, None, [skill_id]) # Delete the summary of the skill (regardless of whether # force_deletion is True or not). delete_skill_summary(skill_id) opportunity_services.delete_skill_opportunity(skill_id) suggestion_services.auto_reject_question_suggestions_for_skill_id( skill_id)