render permalink in backend
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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 = [
|
||||
|
||||
@@ -344,7 +344,7 @@ class @ContentView extends Backbone.View
|
||||
@initLocal()
|
||||
@initTimeago()
|
||||
@initBody()
|
||||
@initPermalink()
|
||||
#@initPermalink()
|
||||
@initCommentViews()
|
||||
|
||||
class @Thread extends @Content
|
||||
|
||||
@@ -55,7 +55,7 @@
|
||||
{{#thread}}
|
||||
<li><div class="follow-wrapper"><a class="discussion-link discussion-follow-thread" href="javascript:void(0)">Follow</a></div></li>
|
||||
{{/thread}}
|
||||
<li><a class="discussion-link discussion-permanent-link" href="javascript:void(0)">Permanent Link</a></li>
|
||||
<li><a class="discussion-link discussion-permanent-link" href="{{content.permalink}}">Permanent Link</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user