From a90af0c471d49da14cbb6e90ea3e7d7c1080e904 Mon Sep 17 00:00:00 2001 From: Rocky Duan Date: Tue, 21 Aug 2012 23:26:06 -0700 Subject: [PATCH] render permalink in backend --- lms/djangoapps/django_comment_client/helpers.py | 7 +++++++ lms/lib/comment_client/comment.py | 2 +- lms/static/coffee/src/backbone_discussion/content.coffee | 2 +- lms/templates/discussion/mustache/_content.mustache | 2 +- 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/lms/djangoapps/django_comment_client/helpers.py b/lms/djangoapps/django_comment_client/helpers.py index 73bd123e12..6ef1baff23 100644 --- a/lms/djangoapps/django_comment_client/helpers.py +++ b/lms/djangoapps/django_comment_client/helpers.py @@ -2,6 +2,7 @@ from django.core.urlresolvers import reverse from django.conf import settings from mitxmako.shortcuts import render_to_string from mustache_helpers import mustache_helpers +from django.core.urlresolvers import reverse from functools import partial from utils import * @@ -40,6 +41,12 @@ def render_content(content, additional_context={}): 'displayed_body': content.get('highlighted_body') or content.get('body', ''), 'raw_tags': ','.join(content.get('tags', [])), } + if content['type'] == 'thread': + content_info['permalink'] = reverse('django_comment_client.forum.views.single_thread', + args=[content['course_id'], content['commentable_id'], content['id']]) + else: + content_info['permalink'] = reverse('django_comment_client.forum.views.single_thread', + args=[content['course_id'], content['commentable_id'], content['thread_id']]) + '#' + content['id'] context = { 'content': merge_dict(content, content_info), content['type']: True, diff --git a/lms/lib/comment_client/comment.py b/lms/lib/comment_client/comment.py index 34cb3d5d06..f8c29ba80d 100644 --- a/lms/lib/comment_client/comment.py +++ b/lms/lib/comment_client/comment.py @@ -10,7 +10,7 @@ class Comment(models.Model): 'endorsed', 'parent_id', 'thread_id', 'username', 'votes', 'user_id', 'closed', 'created_at', 'updated_at', 'depth', - 'at_position_list', 'type', + 'at_position_list', 'type', 'commentable_id', ] updatable_fields = [ diff --git a/lms/static/coffee/src/backbone_discussion/content.coffee b/lms/static/coffee/src/backbone_discussion/content.coffee index 606d063c53..98223fc55a 100644 --- a/lms/static/coffee/src/backbone_discussion/content.coffee +++ b/lms/static/coffee/src/backbone_discussion/content.coffee @@ -344,7 +344,7 @@ class @ContentView extends Backbone.View @initLocal() @initTimeago() @initBody() - @initPermalink() + #@initPermalink() @initCommentViews() class @Thread extends @Content diff --git a/lms/templates/discussion/mustache/_content.mustache b/lms/templates/discussion/mustache/_content.mustache index 5e40096d4c..c38fc4e37c 100644 --- a/lms/templates/discussion/mustache/_content.mustache +++ b/lms/templates/discussion/mustache/_content.mustache @@ -55,7 +55,7 @@ {{#thread}}
  • {{/thread}} -
  • Permanent Link
  • +
  • Permanent Link