Commit be27907a by Ibrahim Awwal

Add permalinks to inline threads.

parent 21042890
......@@ -148,7 +148,7 @@ def forum_form_discussion(request, course_id):
@login_required
def single_thread(request, course_id, discussion_id, thread_id):
# TODO: Why is discussion_id passed in here just to pass it straight back out in the JSON?
course = get_course_with_access(request.user, course_id, 'load')
cc_user = cc.User.from_django_user(request.user)
user_info = cc_user.to_dict()
......
......@@ -81,7 +81,7 @@ if Backbone?
class @Thread extends @Content
urlMappers:
'retrieve' : -> DiscussionUtil.urlFor('retrieve_single_thread', @discussion.id, @id)
'retrieve' : -> DiscussionUtil.urlFor('retrieve_single_thread', @discussion.id, @id)# Not sure if this ID means anything anymore, or if it ever did.
'reply' : -> DiscussionUtil.urlFor('create_comment', @id)
'unvote' : -> DiscussionUtil.urlFor("undo_vote_for_#{@get('type')}", @id)
'upvote' : -> DiscussionUtil.urlFor("upvote_#{@get('type')}", @id)
......@@ -91,6 +91,7 @@ if Backbone?
'delete' : -> DiscussionUtil.urlFor('delete_thread', @id)
'follow' : -> DiscussionUtil.urlFor('follow_thread', @id)
'unfollow' : -> DiscussionUtil.urlFor('unfollow_thread', @id)
'permalink': -> DiscussionUtil.urlFor('permanent_link_thread', @get('commentable_id'), @identifier())
initialize: ->
@set('thread', @)
......@@ -135,6 +136,10 @@ if Backbone?
created_at_time: ->
new Date(@get("created_at")).getTime()
identifier: ->
# Both the slug and the mongoDB ID are valid ways to get to a thread
@get('slug') or @get('id')
class @Comment extends @Content
urlMappers:
'reply': -> DiscussionUtil.urlFor('create_sub_comment', @id)
......
......@@ -66,7 +66,7 @@ class @DiscussionUtil
permanent_link_thread : "/courses/#{$$course_id}/discussion/#{param}/#{param1}"
permanent_link_comment : "/courses/#{$$course_id}/discussion/#{param}/#{param1}##{param2}"
user_profile : "/courses/#{$$course_id}/discussion/users/#{param}"
followed_threads : "/courses/#{$$course_id}/discussion/users/#{param}/followed"
followed_threads : "/courses/#{$$course_id}/discussion/users/#{param}/followed"
threads : "/courses/#{$$course_id}/discussion"
}[name]
......
......@@ -136,4 +136,5 @@ if Backbone?
params = @model.toJSON()
if @model.get('username')?
params = $.extend(params, user:{username: @model.username, user_url: @model.user_url})
params = $.extend(params, permalink: @model.urlFor('permalink'))
Mustache.render(@template, params)
......@@ -12,7 +12,7 @@
{{/user}}
<span class="timeago" title="{{created_at}}">{{created_at}}</span>
<span><a href="{{permalink}}">Permanent Link</a></span>
<span class="post-status-closed top-post-status" style="display: none">
&bull; This thread is closed.
</span>
......
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