Merge pull request #1903 from MITx/fix/cdodge/dangling-verticals-on-delete

Fix/cdodge/dangling verticals on delete
This commit is contained in:
Christina Roberts
2013-04-29 11:58:22 -07:00
4 changed files with 25 additions and 24 deletions

View File

@@ -13,6 +13,12 @@ def as_draft(location):
"""
return Location(location)._replace(revision=DRAFT)
def as_published(location):
"""
Returns the Location that is the published version for `location`
"""
return Location(location)._replace(revision=None)
def wrap_draft(item):
"""
@@ -159,13 +165,17 @@ class DraftModuleStore(ModuleStoreBase):
return super(DraftModuleStore, self).update_metadata(draft_loc, metadata)
def delete_item(self, location):
def delete_item(self, location, delete_all_versions=False):
"""
Delete an item from this modulestore
location: Something that can be passed to Location
"""
return super(DraftModuleStore, self).delete_item(as_draft(location))
super(DraftModuleStore, self).delete_item(as_draft(location))
if delete_all_versions:
super(DraftModuleStore, self).delete_item(as_published(location))
return
def get_parent_locations(self, location, course_id):
'''Find all locations that are the parents of this location. Needed

View File

@@ -694,11 +694,12 @@ class MongoModuleStore(ModuleStoreBase):
self.refresh_cached_metadata_inheritance_tree(loc)
self.fire_updated_modulestore_signal(get_course_id_no_run(Location(location)), Location(location))
def delete_item(self, location):
def delete_item(self, location, delete_all_versions=False):
"""
Delete an item from this modulestore
location: Something that can be passed to Location
delete_all_versions: is here because the DraftMongoModuleStore needs it and we need to keep the interface the same. It is unused.
"""
# VS[compat] cdodge: This is a hack because static_tabs also have references from the course module, so
# if we add one then we need to also add it to the policy information (i.e. metadata)