Mark responses and comments as staff
This commit is contained in:
@@ -236,6 +236,7 @@ def forum_form_discussion(request, course_id):
|
||||
'annotated_content_info': saxutils.escape(json.dumps(annotated_content_info),escapedict),
|
||||
'course_id': course.id,
|
||||
'category_map': category_map,
|
||||
'roles': saxutils.escape(json.dumps(utils.get_role_ids(course_id)), escapedict),
|
||||
}
|
||||
# print "start rendering.."
|
||||
return render_to_response('discussion/index.html', context)
|
||||
@@ -315,6 +316,7 @@ def single_thread(request, course_id, discussion_id, thread_id):
|
||||
'thread_id': thread_id,
|
||||
'threads': saxutils.escape(json.dumps(threads), escapedict),
|
||||
'category_map': category_map,
|
||||
'roles': saxutils.escape(json.dumps(utils.get_role_ids(course_id)), escapedict),
|
||||
}
|
||||
|
||||
return render_to_response('discussion/single_thread.html', context)
|
||||
|
||||
@@ -39,6 +39,14 @@ def strip_blank(dic):
|
||||
def merge_dict(dic1, dic2):
|
||||
return dict(dic1.items() + dic2.items())
|
||||
|
||||
def get_role_ids(course_id):
|
||||
roles = Role.objects.filter(course_id=course_id)
|
||||
staff = list(User.objects.filter(is_staff=True).values_list('id', flat=True))
|
||||
roles_with_ids = {'Staff': staff}
|
||||
for role in roles:
|
||||
roles_with_ids[role.name] = list(role.users.values_list('id', flat=True))
|
||||
return roles_with_ids
|
||||
|
||||
def get_full_modules():
|
||||
global _FULLMODULES
|
||||
if not _FULLMODULES:
|
||||
|
||||
@@ -15,6 +15,11 @@ class @DiscussionUtil
|
||||
@getTemplate: (id) ->
|
||||
$("script##{id}").html()
|
||||
|
||||
@isStaff: (user_id) ->
|
||||
ids = $("#discussion-container").data("roles")
|
||||
staff = _.union(ids['Staff'], ids['Moderator'], ids['Administrator'])
|
||||
_.include(staff, parseInt(user_id))
|
||||
|
||||
@bulkUpdateContentInfo: (infos) ->
|
||||
for id, info of infos
|
||||
Content.getContent(id).updateInfo(info)
|
||||
|
||||
@@ -18,6 +18,7 @@ if Backbone?
|
||||
@initLocal()
|
||||
@delegateEvents()
|
||||
@renderAttrs()
|
||||
@markAsStaff()
|
||||
@$el.find(".timeago").timeago()
|
||||
@convertMath()
|
||||
@
|
||||
@@ -29,3 +30,7 @@ if Backbone?
|
||||
body.children("p").each (index, elem) ->
|
||||
$(elem).replaceWith($(elem).html())
|
||||
MathJax.Hub.Queue ["Typeset", MathJax.Hub, body[0]]
|
||||
|
||||
markAsStaff: ->
|
||||
if DiscussionUtil.isStaff(@model.get("user_id"))
|
||||
@$el.find("a").after('<span class="staff-label">staff</span>')
|
||||
|
||||
@@ -18,6 +18,7 @@ if Backbone?
|
||||
@renderAttrs()
|
||||
@$el.find(".posted-details").timeago()
|
||||
@convertMath()
|
||||
@markAsStaff()
|
||||
@renderComments()
|
||||
@
|
||||
|
||||
@@ -26,6 +27,11 @@ if Backbone?
|
||||
element.html DiscussionUtil.postMathJaxProcessor DiscussionUtil.markdownWithHighlight element.html()
|
||||
MathJax.Hub.Queue ["Typeset", MathJax.Hub, element[0]]
|
||||
|
||||
markAsStaff: ->
|
||||
if DiscussionUtil.isStaff(@model.get("user_id"))
|
||||
@$el.addClass("staff")
|
||||
@$el.prepend('<div class="staff-banner">staff</div>')
|
||||
|
||||
renderComments: ->
|
||||
comments = new Comments()
|
||||
comments.comparator = (comment) ->
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
|
||||
<script type="text/javascript" src="${static.url('js/discussions-temp.js')}"></script>
|
||||
|
||||
<section class="discussion container" id="discussion-container" data-course-id="${course_id}" data-user-info="${user_info}" data-threads="${threads}">
|
||||
<section class="discussion container" id="discussion-container" data-roles="${roles}" data-course-id="${course_id}" data-user-info="${user_info}" data-threads="${threads}">
|
||||
<div class="discussion-body">
|
||||
<div class="sidebar"></div>
|
||||
<div class="discussion-column">
|
||||
@@ -36,4 +36,4 @@
|
||||
</section>
|
||||
|
||||
<%include file="_underscore_templates.html" />
|
||||
<%include file="_thread_list_template.html" />
|
||||
<%include file="_thread_list_template.html" />
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
|
||||
<%include file="_new_post.html" />
|
||||
|
||||
<section class="discussion container" id="discussion-container" data-course-id="${course_id}" data-user-info="${user_info}" data-threads="${threads}" data-content-info="${annotated_content_info}">
|
||||
<section class="discussion container" id="discussion-container" data-roles="${roles}" data-course-id="${course_id}" data-user-info="${user_info}" data-threads="${threads}" data-content-info="${annotated_content_info}">
|
||||
<div class="discussion-body">
|
||||
<div class="sidebar"></div>
|
||||
<div class="discussion-column"></div>
|
||||
|
||||
Reference in New Issue
Block a user