Commit 28a7b3e2 by Douglas Hall

Merge remote-tracking branch 'origin/release' into merge-release-into-master

parents 7ac287af 8d066796
......@@ -289,6 +289,27 @@ class TestCourseIndex(CourseTestCase):
response = self.client.get_html(course_outline_url_split)
self.assertEqual(response.status_code, 404)
def test_course_outline_with_display_course_number_as_none(self):
"""
Tests course outline when 'display_coursenumber' field is none.
"""
# Change 'display_coursenumber' field to None and update the course.
self.course.display_coursenumber = None
updated_course = self.update_course(self.course, self.user.id)
# Assert that 'display_coursenumber' field has been changed successfully.
self.assertEqual(updated_course.display_coursenumber, None)
# Perform GET request on course outline url with the course id.
course_outline_url = reverse_course_url('course_handler', updated_course.id)
response = self.client.get_html(course_outline_url)
# Assert that response code is 200.
self.assertEqual(response.status_code, 200)
# Assert that 'display_course_number' is being set to "" (as display_coursenumber was None).
self.assertIn('display_course_number: ""', response.content)
@ddt.ddt
class TestCourseOutline(CourseTestCase):
......
......@@ -85,7 +85,7 @@ from openedx.core.lib.js_utils import (
url_name: "${context_course.location.name | h}",
org: "${context_course.location.org | h}",
num: "${context_course.location.course | h}",
display_course_number: "${_(context_course.display_coursenumber)}",
display_course_number: "${_(context_course.display_coursenumber) if context_course.display_coursenumber else ''}",
revision: "${context_course.location.revision | h}",
self_paced: ${escape_json_dumps(context_course.self_paced) | n}
});
......
......@@ -119,7 +119,7 @@ class @Sequence
sequence_links = @content_container.find('a.seqnav')
sequence_links.click @goto
@el.find('.path').html(@el.find('.nav-item.active').data('path'))
@el.find('.path').text(@el.find('.nav-item.active').data('path'))
@sr_container.focus();
# @$("a.active").blur()
......
......@@ -191,7 +191,11 @@ class SequenceModule(SequenceFields, ProctoringFields, XModule):
bookmarks_service = self.runtime.service(self, "bookmarks")
context["username"] = self.runtime.service(self, "user").get_current_user().opt_attrs['edx-platform.username']
display_names = [self.get_parent().display_name or '', self.display_name or '']
parent_module = self.get_parent()
display_names = [
parent_module.display_name_with_default,
self.display_name_with_default
]
# We do this up here because proctored exam functionality could bypass
# rendering after this section.
......@@ -228,7 +232,7 @@ class SequenceModule(SequenceFields, ProctoringFields, XModule):
'type': child.get_icon_class(),
'id': child.scope_ids.usage_id.to_deprecated_string(),
'bookmarked': is_bookmarked,
'path': " > ".join(display_names + [child.display_name or '']),
'path': " > ".join(display_names + [child.display_name_with_default]),
}
if childinfo['title'] == '':
childinfo['title'] = child.display_name_with_default_escaped
......
......@@ -47,9 +47,14 @@
view.setBookmarkState(true);
},
error: function (jqXHR) {
var response = jqXHR.responseText ? JSON.parse(jqXHR.responseText) : '';
var userMessage = response ? response.user_message : '';
view.showError(userMessage);
try {
var response = jqXHR.responseText ? JSON.parse(jqXHR.responseText) : '';
var userMessage = response ? response.user_message : '';
view.showError(userMessage);
}
catch(err) {
view.showError();
}
},
complete: function () {
view.$el.prop('disabled', false);
......
......@@ -10,7 +10,7 @@
<a class="bookmarks-results-list-item" href="<%= bookmark.blockUrl() %>" aria-labelledby="bookmark-link-<%= index %>" data-bookmark-id="<%= bookmark.get('id') %>" data-component-type="<%= bookmark.get('block_type') %>" data-usage-id="<%= bookmark.get('usage_id') %>" aria-describedby="bookmark-type-<%= index %> bookmark-date-<%= index %>">
<div class="list-item-content">
<div class="list-item-left-section">
<h3 id="bookmark-link-<%= index %>" class="list-item-breadcrumbtrail"> <%= _.pluck(bookmark.get('path'), 'display_name').concat([bookmark.get('display_name')]).join(' <i class="icon fa fa-caret-right" aria-hidden="true"></i><span class="sr">-</span> ') %> </h3>
<h3 id="bookmark-link-<%= index %>" class="list-item-breadcrumbtrail"> <%= _.map(_.pluck(bookmark.get('path'), 'display_name'), _.escape).concat([_.escape(bookmark.get('display_name'))]).join(' <i class="icon fa fa-caret-right" aria-hidden="true"></i><span class="sr">-</span> ') %> </h3>
<p id="bookmark-date-<%= index %>" class="list-item-date"> <%= gettext("Bookmarked on") %> <%= humanFriendlyDate(bookmark.get('created')) %> </p>
</div>
......
......@@ -19,7 +19,7 @@
data-element="${idx+1}"
href="javascript:void(0);"
data-page-title="${item['page_title']|h}"
data-path="${item['path']}"
data-path="${item['path']|h}"
aria-controls="seq_contents_${idx}"
id="tab_${idx}"
tabindex="0">
......
......@@ -81,7 +81,7 @@ class Bookmark(TimeStampedModel):
xblock_cache = XBlockCache.create({
'usage_key': usage_key,
'display_name': block.display_name,
'display_name': block.display_name_with_default,
})
data['_path'] = prepare_path_for_serialization(Bookmark.updated_path(usage_key, xblock_cache))
......@@ -238,7 +238,6 @@ class XBlockCache(TimeStampedModel):
usage_key = usage_key.replace(course_key=modulestore().fill_in_run(usage_key.course_key))
data['course_key'] = usage_key.course_key
xblock_cache, created = cls.objects.get_or_create(usage_key=usage_key, defaults=data)
if not created:
......
......@@ -229,6 +229,15 @@ class BookmarkModelTests(BookmarksTestsBase):
"""
Test the Bookmark model.
"""
def setUp(self):
super(BookmarkModelTests, self).setUp()
self.vertical_4 = ItemFactory.create(
parent_location=self.sequential_2.location,
category='vertical',
display_name=None
)
def get_bookmark_data(self, block, user=None):
"""
Returns bookmark data for testing.
......@@ -297,6 +306,15 @@ class BookmarkModelTests(BookmarksTestsBase):
self.assertNotEqual(bookmark, bookmark3)
self.assert_bookmark_model_is_valid(bookmark3, bookmark_data_different_user)
def test_create_bookmark_successfully_with_display_name_none(self):
"""
Tests creation of bookmark with display_name None.
"""
bookmark_data = self.get_bookmark_data(self.vertical_4)
bookmark, __ = Bookmark.create(bookmark_data)
bookmark_data['display_name'] = self.vertical_4.display_name_with_default
self.assert_bookmark_model_is_valid(bookmark, bookmark_data)
@ddt.data(
(-30, [[PathItem(EXAMPLE_USAGE_KEY_1, '1')]], 1),
(30, None, 2),
......
......@@ -94,7 +94,7 @@ git+https://github.com/edx/xblock-utils.git@v1.0.0#egg=xblock-utils==v1.0.0
-e git+https://github.com/edx/edx-reverification-block.git@0.0.5#egg=edx-reverification-block==0.0.5
-e git+https://github.com/edx/edx-user-state-client.git@30c0ad4b9f57f8d48d6943eb585ec8a9205f4469#egg=edx-user-state-client
git+https://github.com/edx/edx-organizations.git@release-2015-12-08#egg=edx-organizations==0.2.0
git+https://github.com/edx/edx-proctoring.git@0.12.4#egg=edx-proctoring==0.12.4
git+https://github.com/edx/edx-proctoring.git@0.12.5#egg=edx-proctoring==0.12.5
git+https://github.com/edx/xblock-lti-consumer.git@v1.0.1#egg=xblock-lti-consumer==1.0.1
# Third Party XBlocks
......
......@@ -28,7 +28,7 @@ DB_CACHE_DIR="common/test/db_cache"
echo "CREATE DATABASE IF NOT EXISTS edxtest;" | mysql -u root
# Clear out the test database
./manage.py lms --settings bok_choy flush --traceback --noinput
./manage.py lms --settings bok_choy reset_db --traceback --noinput
# If there are cached database schemas/data, load them
if [[ -f $DB_CACHE_DIR/bok_choy_schema.sql && -f $DB_CACHE_DIR/bok_choy_migrations_data.sql && -f $DB_CACHE_DIR/bok_choy_data.json ]]; then
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment