Commit 29b020b8 by Ibrahim Awwal

Fix staff markers for inline threads and double staff markers for threads with…

Fix staff markers for inline threads and double staff markers for threads with deeply nested comments.
parent ee1e090e
......@@ -172,7 +172,8 @@ def inline_discussion(request, course_id, discussion_id):
'user_info': user_info,
'annotated_content_info': annotated_content_info,
'page': query_params['page'],
'num_pages': query_params['num_pages']
'num_pages': query_params['num_pages'],
'roles': utils.get_role_ids(course_id),
})
@login_required
......
......@@ -67,6 +67,7 @@ if Backbone?
renderDiscussion: ($elem, response, textStatus, discussionId) =>
window.user = new DiscussionUser(response.user_info)
Content.loadContentInfos(response.annotated_content_info)
DiscussionUtil.loadRoles(response.roles)
# $elem.html("Hide Discussion")
@discussion = new Discussion()
@discussion.reset(response.discussion_data, {silent: false})
......
......@@ -2,6 +2,7 @@ if Backbone?
DiscussionApp =
start: (elem)->
# TODO: Perhaps eliminate usage of global variables when possible
DiscussionUtil.loadRolesFromContainer()
element = $(elem)
window.$$course_id = element.data("course-id")
user_info = element.data("user-info")
......
......@@ -15,9 +15,14 @@ class @DiscussionUtil
@getTemplate: (id) ->
$("script##{id}").html()
@loadRoles: (roles)->
@roleIds = roles
@loadRolesFromContainer: ->
@loadRoles($("#discussion-container").data("roles"))
@isStaff: (user_id) ->
ids = $("#discussion-container").data("roles")
staff = _.union(ids['Staff'], ids['Moderator'], ids['Administrator'])
staff = _.union(@roleIds['Staff'], @roleIds['Moderator'], @roleIds['Administrator'])
_.include(staff, parseInt(user_id))
@bulkUpdateContentInfo: (infos) ->
......
......@@ -33,4 +33,4 @@ if Backbone?
markAsStaff: ->
if DiscussionUtil.isStaff(@model.get("user_id"))
@$el.find("a").after('<span class="staff-label">staff</span>')
@$el.find("a.profile-link").after('<span class="staff-label">staff</span>')
......@@ -99,7 +99,7 @@
<a href="#comment_${'<%- parent_id %>'}">@${'<%- parent_username %>'}</a>:
${'<% }%>'}
<span class="response-body">${'<%- body %>'}</span>
<span class="posted-details">&ndash;posted <span class="timeago" title="${'<%- created_at %>'}">${'<%- created_at %>'}</span> by <a href="${'<%- user_url %>'}">${'<%- username %>'}</a></span>
<span class="posted-details">&ndash;posted <span class="timeago" title="${'<%- created_at %>'}">${'<%- created_at %>'}</span> by <a href="${'<%- user_url %>'}" class="profile-link">${'<%- username %>'}</a></span>
</p>
</script>
......
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