Merge branch 'master' of github.com:dementrock/mitx into discussion2
This commit is contained in:
@@ -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<thread_id>\w+)$', 'single_thread', name='single_thread'),
|
||||
url(r'(?P<discussion_id>\w+)/threads/(?P<thread_id>\w+)$', 'single_thread', name='single_thread'),
|
||||
url(r'(?P<discussion_id>\w+)$', 'forum_form_discussion', name='forum_form_discussion'),
|
||||
)
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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":
|
||||
<a class="thread-title" name="${content['id']}" href="${url_for_thread}">${content['title'] | h}</a>
|
||||
|
||||
@@ -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
|
||||
<a href="${url_for_comment(info['thread_id'], info['comment_id'])}">comment</a>
|
||||
<a href="${url_for_comment(info['commentable_id', info['thread_id'], info['comment_id'])}">comment</a>
|
||||
to the thread
|
||||
<a href="${url_for_thread(info['thread_id'])}">${info['thread_title']}</a>
|
||||
<a href="${url_for_thread(info['commentable_id'], info['thread_id'])}">${info['thread_title']}</a>
|
||||
in discussion
|
||||
<a href="${url_for_discussion(info['commentable_id'])}">${discussion_title(info['commentable_id'])}</a>
|
||||
% elif notification['notification_type'] == 'post_topic':
|
||||
User No.${notification['actor_id']} posted a new thread
|
||||
<a href="${url_for_thread(info['thread_id'])}">${info['thread_title']}</a>
|
||||
<a href="${url_for_thread(info['commentable_id'], info['thread_id'])}">${info['thread_title']}</a>
|
||||
in discussion
|
||||
<a href="${url_for_discussion(info['commentable_id'])}">${discussion_title(info['commentable_id'])}</a>
|
||||
% endif
|
||||
|
||||
Reference in New Issue
Block a user