Commit 112f8836 by Mike Chen

added permanent link for threads

parent 4167fc88
......@@ -136,16 +136,16 @@ def get_annotated_content_info(content, user, is_thread):
'can_delete': check_permissions_by_view(user, content, "delete_thread" if is_thread else "delete_comment"),
}
def get_annotated_content_infos(thread, user):
def get_annotated_content_infos(thread, user, is_thread=True):
infos = {}
def _annotate(content, is_thread=True):
def _annotate(content, is_thread=is_thread):
infos[str(content['id'])] = get_annotated_content_info(content, user, is_thread)
for child in content.get('children', []):
_annotate(child, is_thread=False)
_annotate(thread)
return infos
def render_single_thread(request, course_id, thread_id):
def render_single_thread(request, discussion_id, course_id, thread_id):
thread = comment_client.get_thread(thread_id, recursive=True)
......@@ -153,6 +153,7 @@ def render_single_thread(request, course_id, thread_id):
user=request.user, is_thread=True)
context = {
'discussion_id': discussion_id,
'thread': thread,
'user_info': comment_client.get_user_info(request.user.id, raw=True),
'annotated_content_info': json.dumps(annotated_content_info),
......@@ -179,9 +180,10 @@ def single_thread(request, course_id, discussion_id, thread_id):
course = check_course(course_id)
context = {
'discussion_id': discussion_id,
'csrf': csrf(request)['csrf_token'],
'init': '',
'content': render_single_thread(request, course_id, thread_id),
'content': render_single_thread(request, discussion_id, course_id, thread_id),
'accordion': render_accordion(request, course, discussion_id),
'course': course,
}
......
......@@ -87,6 +87,10 @@
${render_link("discussion-link discussion-reply discussion-reply-" + type, "Reply")}
${render_link("discussion-link discussion-edit", "Edit")}
% if type == "thread":
<a class="discussion-link discussion-permanent-link" href="${reverse('django_comment_client.forum.views.single_thread', kwargs={'discussion_id':discussion_id, 'thread_id':content['id'], 'course_id':course_id})}">Permanent Link</a>
% endif
<span class="discussion-endorse-control">
% if content.get('endorsed', False):
<input type="checkbox" checked="checked" class="discussion-link discussion-endorse" id="discussion-endorse-${content['id']}" />
......
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