Commit fde77b7a by Rocky Duan

fixed user link and back button

parent e3728f68
This diff is collapsed. Click to expand it.
......@@ -8,6 +8,7 @@ class User(models.Model):
accessible_fields = ['username', 'email', 'follower_ids', 'upvoted_ids', 'downvoted_ids',
'id', 'external_id', 'subscribed_user_ids', 'children', 'course_id',
'subscribed_thread_ids', 'subscribed_commentable_ids',
'default_sort_key',
'threads_count', 'comments_count',
]
......
......@@ -47,6 +47,7 @@ if Backbone?
initialize: ->
DiscussionUtil.addContent @id, @
@set 'user_url', DiscussionUtil.urlFor('user_profile', @get('user_id'))
@resetComments(@get('children'))
......
......@@ -64,13 +64,16 @@ class @DiscussionUtil
openclose_thread : "/courses/#{$$course_id}/discussion/threads/#{param}/close"
permanent_link_thread : "/courses/#{$$course_id}/discussion/forum/#{param}/threads/#{param1}"
permanent_link_comment : "/courses/#{$$course_id}/discussion/forum/#{param}/threads/#{param1}##{param2}"
user_profile : "/courses/#{$$course_id}/discussion/forum/users/#{param}"
}[name]
@safeAjax: (params) ->
$elem = params.$elem
if $elem.attr("disabled")
if $elem and $elem.attr("disabled")
return
params["url"] = URI(params["url"]).addSearch ajax: 1
params["beforeSend"] = ->
if $elem
$elem.attr("disabled", "disabled")
if params["$loading"]
if params["loadingCallback"]?
......@@ -78,6 +81,7 @@ class @DiscussionUtil
else
params["$loading"].loading()
$.ajax(params).always ->
if $elem
$elem.removeAttr("disabled")
if params["$loading"]
if params["loadedCallback"]?
......
......@@ -29,7 +29,9 @@ class @DiscussionThreadView extends Backbone.View
MathJax.Hub.Queue ["Typeset", MathJax.Hub, element.attr("id")]
renderResponses: ->
$.ajax @model.id, success: (data, textStatus, xhr) =>
DiscussionUtil.safeAjax
url: @model.id
success: (data, textStatus, xhr) =>
@$(".loading").remove()
comments = new Comments(data['content']['children'])
comments.each @renderResponse
......
<%namespace name="renderer" file="_content_renderer.html"/>
<%! from django_comment_client.mustache_helpers import url_for_user %>
<article class="discussion-article" data-id="${discussion_id| h}">
<a href="#" class="dogear"></a>
......@@ -8,7 +9,7 @@
<h1>${thread['title']}</h1>
<p class="posted-details">
<span class="timeago" title="${thread['created_at'] | h}">sometime</span> by
<a href="${thread['user_id']}">${thread['username']}</a>
<a href="${url_for_user(thread, thread['user_id'])}">${thread['username']}</a>
</p>
</header>
<div class="post-body">
......
......@@ -34,7 +34,7 @@
<h1>${'<%= title %>'}</h1>
<p class="posted-details">
<span class="timeago" title="${'<%= created_at %>'}">sometime</span> by
<a href="${'<%= user_id %>'}">${'<%= username %>'}</a>
<a href="${'<%= user_url %>'}">${'<%= username %>'}</a>
</p>
</header>
<div class="post-body">
......@@ -58,7 +58,7 @@
<script type="text/template" id="thread-response-template">
<header>
<a href="#" class="vote-btn" data-tooltip="vote"><span class="plus-icon"></span><span class="votes-count-number">${"<%= votes['up_count'] %>"}</span></a>
<a href="#" class="posted-by">${"<%= username %>"}</a>
<a href="${'<%= user_url %>'}" class="posted-by">${"<%= username %>"}</a>
<p class="posted-details" title="${'<%= created_at %>'}">Sometime</p>
</header>
<div class="response-body">${"<%= body %>"}</div>
......@@ -72,7 +72,7 @@
</script>
<script type="text/template" id="response-comment-template">
<p>${'<%= body %>'}<span class="posted-details">posted <span class="timeago" title="${'<%= created_at %>'}">sometime</span> by <a href="#">${'<%= username %>'}</a></span></p>
<p>${'<%= body %>'}<span class="posted-details">posted <span class="timeago" title="${'<%= created_at %>'}">sometime</span> by <a href="${'<%= user_url %>'}">${'<%= username %>'}</a></span></p>
</script>
<script type="text/template" id="thread-list-item-template">
......
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