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