From a7550912f875565b4107cbaf47be247d919e2817 Mon Sep 17 00:00:00 2001 From: attiyaishaque Date: Tue, 4 Apr 2017 16:37:37 +0500 Subject: [PATCH] TNL-6284 Empty subcategory will not render in inline discussion modules. --- .../django_comment_client/tests/test_utils.py | 16 ++++++++++++++++ lms/djangoapps/django_comment_client/utils.py | 2 +- lms/templates/discussion/_discussion_inline.html | 6 +++++- lms/templates/discussion/_filter_dropdown.html | 2 ++ 4 files changed, 24 insertions(+), 2 deletions(-) diff --git a/lms/djangoapps/django_comment_client/tests/test_utils.py b/lms/djangoapps/django_comment_client/tests/test_utils.py index 5e93d75069..0977e8a180 100644 --- a/lms/djangoapps/django_comment_client/tests/test_utils.py +++ b/lms/djangoapps/django_comment_client/tests/test_utils.py @@ -178,6 +178,22 @@ class CoursewareContextTestCase(ModuleStoreTestCase): assertThreadCorrect(threads[0], self.discussion1, "Chapter / Discussion 1") assertThreadCorrect(threads[1], self.discussion2, "Subsection / Discussion 2") + def test_empty_discussion_subcategory_title(self): + """ + Test that for empty subcategory inline discussion modules, + the divider " / " is not rendered on a post or inline discussion topic label. + """ + discussion = ItemFactory.create( + parent_location=self.course.location, + category="discussion", + discussion_id="discussion", + discussion_category="Chapter", + discussion_target="" # discussion-subcategory + ) + thread = {"commentable_id": discussion.discussion_id} + utils.add_courseware_context([thread], self.course, self.user) + self.assertNotIn('/', thread.get("courseware_title")) + @ddt.data((ModuleStoreEnum.Type.mongo, 2), (ModuleStoreEnum.Type.split, 1)) @ddt.unpack def test_get_accessible_discussion_xblocks(self, modulestore_type, expected_discussion_xblocks): diff --git a/lms/djangoapps/django_comment_client/utils.py b/lms/djangoapps/django_comment_client/utils.py index 6d8808fdee..cd49c871d1 100644 --- a/lms/djangoapps/django_comment_client/utils.py +++ b/lms/djangoapps/django_comment_client/utils.py @@ -147,7 +147,7 @@ def get_discussion_id_map_entry(xblock): xblock.discussion_id, { "location": xblock.location, - "title": xblock.discussion_category.split("/")[-1].strip() + " / " + xblock.discussion_target + "title": xblock.discussion_category.split("/")[-1].strip() + (" / " + xblock.discussion_target if xblock.discussion_target else "") } ) diff --git a/lms/templates/discussion/_discussion_inline.html b/lms/templates/discussion/_discussion_inline.html index f4d87fb6e2..a1bb344769 100644 --- a/lms/templates/discussion/_discussion_inline.html +++ b/lms/templates/discussion/_discussion_inline.html @@ -15,7 +15,11 @@ from openedx.core.djangolib.js_utils import js_escaped_string data-read-only="${'false' if can_create_thread else 'true'}">

${_(display_name)}

-
${_("Topic:")} ${discussion_category} / ${discussion_target}
+
${_("Topic:")} ${discussion_category} + % if discussion_target: + / ${discussion_target} + %endif +