From edf02dd90e3c0e2f488cfc146968bab71eb9c76e Mon Sep 17 00:00:00 2001 From: Arjun Singh Date: Fri, 14 Sep 2012 04:07:04 -0700 Subject: [PATCH] Fix context links for the 123187th time --- lms/djangoapps/django_comment_client/base/views.py | 1 + lms/djangoapps/django_comment_client/forum/views.py | 2 ++ lms/djangoapps/django_comment_client/utils.py | 5 +++-- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lms/djangoapps/django_comment_client/base/views.py b/lms/djangoapps/django_comment_client/base/views.py index 56009f0209..63d69427c9 100644 --- a/lms/djangoapps/django_comment_client/base/views.py +++ b/lms/djangoapps/django_comment_client/base/views.py @@ -112,6 +112,7 @@ def _create_comment(request, course_id, thread_id=None, parent_id=None): post = request.POST comment = cc.Comment(**extract(post, ['body'])) + course = get_course_with_access(request.user, course_id, 'load') if course.metadata.get("allow_anonymous", True): anonymous = post.get('anonymous', 'false').lower() == 'true' else: diff --git a/lms/djangoapps/django_comment_client/forum/views.py b/lms/djangoapps/django_comment_client/forum/views.py index 2297cd9fa7..6bb1cd0d51 100644 --- a/lms/djangoapps/django_comment_client/forum/views.py +++ b/lms/djangoapps/django_comment_client/forum/views.py @@ -212,6 +212,8 @@ def single_thread(request, course_id, discussion_id, thread_id): category_map = utils.get_discussion_category_map(course) try: threads, query_params = get_threads(request, course_id) + thread = cc.Thread.find(thread_id).retrieve(recursive=True) + threads.append(thread.to_dict()) except (cc.utils.CommentClientError, cc.utils.CommentClientUnknownError) as err: raise Http404 diff --git a/lms/djangoapps/django_comment_client/utils.py b/lms/djangoapps/django_comment_client/utils.py index d7c1884580..dd7c658fd6 100644 --- a/lms/djangoapps/django_comment_client/utils.py +++ b/lms/djangoapps/django_comment_client/utils.py @@ -146,8 +146,9 @@ def initialize_discussion_info(course): category = module.metadata['discussion_category'] title = module.metadata['for'] sort_key = module.metadata.get('sort_key', title) - discussion_id_map[id] = {"location": location, "title": title} category = " / ".join([x.strip() for x in category.split("/")]) + last_category = category.split("/")[-1] + discussion_id_map[id] = {"location": location, "title": last_category + " / " + title} unexpanded_category_map[category].append({"title": title, "id": id, "sort_key": sort_key, "start_date": module.start}) @@ -333,7 +334,7 @@ def safe_content(content): 'endorsed', 'parent_id', 'thread_id', 'votes', 'closed', 'created_at', 'updated_at', 'depth', 'type', 'commentable_id', 'comments_count', 'at_position_list', 'children', 'highlighted_title', 'highlighted_body', - 'courseware_title', 'courseware_location', 'tags' + 'courseware_title', 'courseware_url', 'tags' ] if (content.get('anonymous') is False) and (content.get('anonymous_to_peers') is False):