From 8151b1030f64b25397658ab48722cf074299e761 Mon Sep 17 00:00:00 2001 From: Chris Dodge Date: Sat, 13 Oct 2012 10:42:49 -0400 Subject: [PATCH 1/4] remove wip on Import header button --- cms/templates/widgets/header.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cms/templates/widgets/header.html b/cms/templates/widgets/header.html index 08e998381a..d3fc132756 100644 --- a/cms/templates/widgets/header.html +++ b/cms/templates/widgets/header.html @@ -13,7 +13,7 @@
  • Pages
  • Assets
  • Users
  • -
  • Import
  • +
  • Import
  • % endif From f1517fefa62656ea1be1702a7ebe699cc5ad0ec5 Mon Sep 17 00:00:00 2001 From: Chris Dodge Date: Sat, 13 Oct 2012 10:45:52 -0400 Subject: [PATCH 2/4] hide search button on asset index page --- cms/templates/asset_index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cms/templates/asset_index.html b/cms/templates/asset_index.html index 5940767c86..ad58819b62 100644 --- a/cms/templates/asset_index.html +++ b/cms/templates/asset_index.html @@ -10,7 +10,7 @@

    Asset Library

    From 2e43d2ebcc6d14bf030d27d975c6fb69d860f3a3 Mon Sep 17 00:00:00 2001 From: Chris Dodge Date: Sat, 13 Oct 2012 15:43:50 -0400 Subject: [PATCH 3/4] don't display a broken thumbnail image if a thumbnail is not available --- cms/djangoapps/contentstore/views.py | 6 +++--- cms/templates/asset_index.html | 6 +++++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/cms/djangoapps/contentstore/views.py b/cms/djangoapps/contentstore/views.py index 78cda2e00c..15edd68aa1 100644 --- a/cms/djangoapps/contentstore/views.py +++ b/cms/djangoapps/contentstore/views.py @@ -848,9 +848,9 @@ def asset_index(request, org, course, name): display_info['url'] = StaticContent.get_url_path_from_location(asset_location) # note, due to the schema change we may not have a 'thumbnail_location' in the result set - thumbnail_location = Location(asset.get('thumbnail_location', None)) - - display_info['thumb_url'] = StaticContent.get_url_path_from_location(thumbnail_location) + _thumbnail_location = asset.get('thumbnail_location', None) + thumbnail_location = Location(_thumbnail_location) if _thumbnail_location is not None else None + display_info['thumb_url'] = StaticContent.get_url_path_from_location(thumbnail_location) if thumbnail_location is not None else None asset_display.append(display_info) diff --git a/cms/templates/asset_index.html b/cms/templates/asset_index.html index ad58819b62..1b3ffb6d5d 100644 --- a/cms/templates/asset_index.html +++ b/cms/templates/asset_index.html @@ -26,7 +26,11 @@ % for asset in assets:
    -
    +
    + % if asset['thumb_url'] is not None: + + % endif +
    ${asset['displayname']} From 258a467fa6db06a68666e88da0a17910c401973a Mon Sep 17 00:00:00 2001 From: Chris Dodge Date: Sat, 13 Oct 2012 20:55:49 -0400 Subject: [PATCH 4/4] make delete unit delete both the draft and non-draft versions --- cms/djangoapps/contentstore/views.py | 32 ++++++++++++++-------------- cms/static/js/base.js | 2 +- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/cms/djangoapps/contentstore/views.py b/cms/djangoapps/contentstore/views.py index 15edd68aa1..dd8b55ad9f 100644 --- a/cms/djangoapps/contentstore/views.py +++ b/cms/djangoapps/contentstore/views.py @@ -210,8 +210,6 @@ def edit_subsection(request, location): policy_metadata = dict((key,value) for key, value in item.metadata.iteritems() if key not in ['display_name', 'start', 'due', 'format'] and key not in item.system_metadata_fields) - logging.debug(policy_metadata) - return render_to_response('edit_subsection.html', {'subsection': item, 'context_course': course, @@ -483,20 +481,13 @@ def _xmodule_recurse(item, action): _xmodule_recurse(child, action) action(item) - -def _delete_item(item, recurse=False): - if recurse: - children = item.get_children() - for child in children: - _delete_item(child, recurse) - - modulestore().delete_item(item.location); @login_required @expect_json def delete_item(request): item_location = request.POST['id'] + item_loc = Location(item_location) # check permissions for this user within this course if not has_access(request.user, item_location): @@ -504,16 +495,28 @@ def delete_item(request): # optional parameter to delete all children (default False) delete_children = request.POST.get('delete_children', False) + delete_all_versions = request.POST.get('delete_all_versions', False) item = modulestore().get_item(item_location) + store = _modulestore(item_loc) - # @TODO: this probably leaves draft items dangling. + + # @TODO: this probably leaves draft items dangling. My preferance would be for the semantic to be + # if item.location.revision=None, then delete both draft and published version + # if caller wants to only delete the draft than the caller should put item.location.revision='draft' if delete_children: - _xmodule_recurse(item, lambda i: _modulestore(i.location).delete_item(i.location)) + _xmodule_recurse(item, lambda i: store.delete_item(i.location)) else: - _modulestore(item.location).delete_item(item.location) + store.delete_item(item.location) + + # cdodge: this is a bit of a hack until I can talk with Cale about the + # semantics of delete_item whereby the store is draft aware. Right now calling + # delete_item on a vertical tries to delete the draft version leaving the + # requested delete to never occur + if item.location.revision is None and item.location.category=='vertical' and delete_all_versions: + modulestore('direct').delete_item(item.location) return HttpResponse() @@ -886,9 +889,6 @@ def create_new_course(request): if existing_course is not None: return HttpResponse(json.dumps({'ErrMsg': 'There is already a course defined with this name.'})) - logging.debug(dest_location) - logging.debug(template) - new_course = modulestore('direct').clone_item(template, dest_location) if display_name is not None: diff --git a/cms/static/js/base.js b/cms/static/js/base.js index 7448a0e151..692f579397 100644 --- a/cms/static/js/base.js +++ b/cms/static/js/base.js @@ -244,7 +244,7 @@ function _deleteItem($el) { var id = $el.data('id'); $.post('/delete_item', - {'id': id, 'delete_children' : true}, + {'id': id, 'delete_children' : true, 'delete_all_versions' : true}, function(data) { $el.remove(); });