From 24610899cf94be2fe842d8623a25afb883837e0d Mon Sep 17 00:00:00 2001 From: Rocky Duan Date: Mon, 30 Jul 2012 18:34:47 -0400 Subject: [PATCH] fix accordion --- .../django_comment_client/forum/urls.py | 2 +- .../django_comment_client/forum/views.py | 18 ++++++++---------- lms/templates/discussion/thread.html | 9 +++++---- lms/templates/notifications.html | 14 +++++++------- 4 files changed, 21 insertions(+), 22 deletions(-) diff --git a/lms/djangoapps/django_comment_client/forum/urls.py b/lms/djangoapps/django_comment_client/forum/urls.py index 0fd4f0e320..6ebdd04aba 100644 --- a/lms/djangoapps/django_comment_client/forum/urls.py +++ b/lms/djangoapps/django_comment_client/forum/urls.py @@ -3,6 +3,6 @@ import django_comment_client.forum.views urlpatterns = patterns('django_comment_client.forum.views', url(r'search$', 'search', name='search'), - url(r'threads/(?P\w+)$', 'single_thread', name='single_thread'), + url(r'(?P\w+)/threads/(?P\w+)$', 'single_thread', name='single_thread'), url(r'(?P\w+)$', 'forum_form_discussion', name='forum_form_discussion'), ) diff --git a/lms/djangoapps/django_comment_client/forum/views.py b/lms/djangoapps/django_comment_client/forum/views.py index 17bfa4c687..0a94603267 100644 --- a/lms/djangoapps/django_comment_client/forum/views.py +++ b/lms/djangoapps/django_comment_client/forum/views.py @@ -16,7 +16,10 @@ from django_comment_client.utils import get_categorized_discussion_info import json -def render_accordion(request, course, discussion_info, discussion_id): +def render_accordion(request, course, discussion_id): + + discussion_info = get_categorized_discussion_info(request, course) + context = { 'course': course, 'discussion_info': discussion_info, @@ -55,8 +58,6 @@ def forum_form_discussion(request, course_id, discussion_id): url_course_id = course_id.replace('/', '_').replace('.', '_') - discussion_info = get_categorized_discussion_info(request, course)#request.user, course, course_name, url_course_id) - search_text = request.GET.get('text', '') if len(search_text) > 0: @@ -70,12 +71,13 @@ def forum_form_discussion(request, course_id, discussion_id): 'course': course, 'init': '', 'content': render_discussion(request, course_id, threads, discussion_id, search_text), - 'accordion': render_accordion(request, course, discussion_info, discussion_id), + 'accordion': render_accordion(request, course, discussion_id), } return render_to_response('discussion/index.html', context) def render_single_thread(request, course_id, thread_id): + context = { 'thread': comment_client.get_thread(thread_id, recursive=True), 'user_info': comment_client.get_user_info(request.user.id, raw=True), @@ -84,7 +86,7 @@ def render_single_thread(request, course_id, thread_id): } return render_to_string('discussion/single_thread.html', context) -def single_thread(request, course_id, thread_id): +def single_thread(request, course_id, discussion_id, thread_id): course = check_course(course_id) @@ -92,7 +94,7 @@ def single_thread(request, course_id, thread_id): 'csrf': csrf(request)['csrf_token'], 'init': '', 'content': render_single_thread(request, course_id, thread_id), - 'accordion': '', + 'accordion': render_accordion(request, course, discussion_id), 'course': course, } @@ -106,10 +108,6 @@ def search(request, course_id): commentable_id = request.GET.get('commentable_id', None) tags = request.GET.get('tags', None) - print text - print commentable_id - print tags - threads = comment_client.search_threads({ 'text': text, 'commentable_id': commentable_id, diff --git a/lms/templates/discussion/thread.html b/lms/templates/discussion/thread.html index d82005ae51..c72bb5aad0 100644 --- a/lms/templates/discussion/thread.html +++ b/lms/templates/discussion/thread.html @@ -44,10 +44,11 @@ <%def name="render_title(content, type, **kwargs)"> <% - if kwargs.get('show_comments', False): - url_for_thread = "" - else: - url_for_thread = reverse('django_comment_client.forum.views.single_thread', args=[course_id, content['id']]) + if type == "thread": + if kwargs.get('show_comments', False): + url_for_thread = "" + else: + url_for_thread = reverse('django_comment_client.forum.views.single_thread', args=[course_id, content['commentable_id'], content['id']]) %> % if type == "thread": ${content['title'] | h} diff --git a/lms/templates/notifications.html b/lms/templates/notifications.html index a1ae988049..38cb74f46f 100644 --- a/lms/templates/notifications.html +++ b/lms/templates/notifications.html @@ -1,13 +1,13 @@ <%! from django.core.urlresolvers import reverse %> <% -def url_for_thread(thread_id): - return reverse('django_comment_client.forum.views.single_thread', args=[course.id, thread_id]) +def url_for_thread(discussion_id, thread_id): + return reverse('django_comment_client.forum.views.single_thread', args=[course.id, discussion_id, thread_id]) %> <% -def url_for_comment(thread_id, comment_id): - return reverse('django_comment_client.forum.views.single_thread', args=[course.id, thread_id]) + "#" + comment_id +def url_for_comment(discussion_id, thread_id, comment_id): + return url_for_thread(discussion_id, thread_id) + "#" + comment_id %> <% @@ -32,14 +32,14 @@ def discussion_title(discussion_id): <% info = notification['info'] %> % if notification['notification_type'] == 'post_reply': User No.${notification['actor_id']} posted a - comment + comment to the thread - ${info['thread_title']} + ${info['thread_title']} in discussion ${discussion_title(info['commentable_id'])} % elif notification['notification_type'] == 'post_topic': User No.${notification['actor_id']} posted a new thread - ${info['thread_title']} + ${info['thread_title']} in discussion ${discussion_title(info['commentable_id'])} % endif