From a78dad77ff4bc3c72214fc9994fa1b912b568c41 Mon Sep 17 00:00:00 2001 From: David Baumgold Date: Fri, 31 Jan 2014 15:35:35 -0500 Subject: [PATCH 1/4] Pass component display name to Mako template STUD-1241 --- .../contentstore/features/component.feature | 7 +++++++ cms/djangoapps/contentstore/features/component.py | 13 +++++++++++++ cms/djangoapps/contentstore/views/item.py | 3 ++- cms/templates/component.html | 1 + 4 files changed, 23 insertions(+), 1 deletion(-) diff --git a/cms/djangoapps/contentstore/features/component.feature b/cms/djangoapps/contentstore/features/component.feature index 5df49e59fd..1712aaa245 100644 --- a/cms/djangoapps/contentstore/features/component.feature +++ b/cms/djangoapps/contentstore/features/component.feature @@ -112,3 +112,10 @@ Feature: CMS.Component Adding Then I see a Problem component with display name "Blank Common Problem" in position "0" And I see a Problem component with display name "Duplicate of 'Blank Common Problem'" in position "1" And I see a Problem component with display name "Multiple Choice" in position "2" + + Scenario: I can set the display name of a component + Given I am in Studio editing a new unit + When I add a "Text" "HTML" component + Then I see the display name is "Text" + When I change the display name to "I'm the Cuddliest!" + Then I see the display name is "I'm the Cuddliest!" diff --git a/cms/djangoapps/contentstore/features/component.py b/cms/djangoapps/contentstore/features/component.py index cfe4053b2f..9d45cc11ff 100644 --- a/cms/djangoapps/contentstore/features/component.py +++ b/cms/djangoapps/contentstore/features/component.py @@ -154,3 +154,16 @@ def see_component_in_position(step, display_name, index): return world.css_text(component_css, int(index)).startswith(display_name.upper()) world.wait_for(find_problem, timeout_msg='Did not find the duplicated problem') + + +@step(u'I see the display name is "([^"]*)"') +def check_component_display_name(step, display_name): + label = world.css_text(".component-header") + assert display_name == label + + +@step(u'I change the display name to "([^"]*)"') +def change_display_name(step, display_name): + world.edit_component_and_select_settings() + world.css_fill("ul.settings-list li:first-child input", display_name) + world.save_component(step) diff --git a/cms/djangoapps/contentstore/views/item.py b/cms/djangoapps/contentstore/views/item.py index 116fa33894..7388d927a5 100644 --- a/cms/djangoapps/contentstore/views/item.py +++ b/cms/djangoapps/contentstore/views/item.py @@ -113,7 +113,8 @@ def xblock_handler(request, tag=None, package_id=None, branch=None, version_guid return render_to_response('component.html', { 'preview': get_preview_html(request, component), - 'editor': content + 'editor': content, + 'display_name': component.display_name, }) elif request.method == 'DELETE': delete_children = str_to_bool(request.REQUEST.get('recurse', 'False')) diff --git a/cms/templates/component.html b/cms/templates/component.html index 554cc9ec93..5764fd3108 100644 --- a/cms/templates/component.html +++ b/cms/templates/component.html @@ -28,6 +28,7 @@
+ ${display_name}
- ${display_name} + ${label}