Commit be27907a by Ibrahim Awwal

Add permalinks to inline threads.

parent 21042890
...@@ -148,7 +148,7 @@ def forum_form_discussion(request, course_id): ...@@ -148,7 +148,7 @@ def forum_form_discussion(request, course_id):
@login_required @login_required
def single_thread(request, course_id, discussion_id, thread_id): 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') course = get_course_with_access(request.user, course_id, 'load')
cc_user = cc.User.from_django_user(request.user) cc_user = cc.User.from_django_user(request.user)
user_info = cc_user.to_dict() user_info = cc_user.to_dict()
......
...@@ -81,7 +81,7 @@ if Backbone? ...@@ -81,7 +81,7 @@ if Backbone?
class @Thread extends @Content class @Thread extends @Content
urlMappers: 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) 'reply' : -> DiscussionUtil.urlFor('create_comment', @id)
'unvote' : -> DiscussionUtil.urlFor("undo_vote_for_#{@get('type')}", @id) 'unvote' : -> DiscussionUtil.urlFor("undo_vote_for_#{@get('type')}", @id)
'upvote' : -> DiscussionUtil.urlFor("upvote_#{@get('type')}", @id) 'upvote' : -> DiscussionUtil.urlFor("upvote_#{@get('type')}", @id)
...@@ -91,6 +91,7 @@ if Backbone? ...@@ -91,6 +91,7 @@ if Backbone?
'delete' : -> DiscussionUtil.urlFor('delete_thread', @id) 'delete' : -> DiscussionUtil.urlFor('delete_thread', @id)
'follow' : -> DiscussionUtil.urlFor('follow_thread', @id) 'follow' : -> DiscussionUtil.urlFor('follow_thread', @id)
'unfollow' : -> DiscussionUtil.urlFor('unfollow_thread', @id) 'unfollow' : -> DiscussionUtil.urlFor('unfollow_thread', @id)
'permalink': -> DiscussionUtil.urlFor('permanent_link_thread', @get('commentable_id'), @identifier())
initialize: -> initialize: ->
@set('thread', @) @set('thread', @)
...@@ -135,6 +136,10 @@ if Backbone? ...@@ -135,6 +136,10 @@ if Backbone?
created_at_time: -> created_at_time: ->
new Date(@get("created_at")).getTime() 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 class @Comment extends @Content
urlMappers: urlMappers:
'reply': -> DiscussionUtil.urlFor('create_sub_comment', @id) 'reply': -> DiscussionUtil.urlFor('create_sub_comment', @id)
......
...@@ -66,7 +66,7 @@ class @DiscussionUtil ...@@ -66,7 +66,7 @@ class @DiscussionUtil
permanent_link_thread : "/courses/#{$$course_id}/discussion/#{param}/#{param1}" permanent_link_thread : "/courses/#{$$course_id}/discussion/#{param}/#{param1}"
permanent_link_comment : "/courses/#{$$course_id}/discussion/#{param}/#{param1}##{param2}" permanent_link_comment : "/courses/#{$$course_id}/discussion/#{param}/#{param1}##{param2}"
user_profile : "/courses/#{$$course_id}/discussion/users/#{param}" 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" threads : "/courses/#{$$course_id}/discussion"
}[name] }[name]
......
...@@ -136,4 +136,5 @@ if Backbone? ...@@ -136,4 +136,5 @@ if Backbone?
params = @model.toJSON() params = @model.toJSON()
if @model.get('username')? if @model.get('username')?
params = $.extend(params, user:{username: @model.username, user_url: @model.user_url}) params = $.extend(params, user:{username: @model.username, user_url: @model.user_url})
params = $.extend(params, permalink: @model.urlFor('permalink'))
Mustache.render(@template, params) Mustache.render(@template, params)
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
{{/user}} {{/user}}
<span class="timeago" title="{{created_at}}">{{created_at}}</span> <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"> <span class="post-status-closed top-post-status" style="display: none">
&bull; This thread is closed. &bull; This thread is closed.
</span> </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