Merge branch 'ccp0101/moderation' of github.com:dementrock/mitx into merge
Conflicts: lms/djangoapps/django_comment_client/forum/views.py lms/djangoapps/django_comment_client/permissions.py lms/static/coffee/src/discussion/content.coffee lms/static/coffee/src/discussion/utils.coffee lms/templates/discussion/_recent_active_posts.html lms/templates/discussion/_search_bar.html lms/templates/discussion/_thread.html lms/templates/discussion/_trending_tags.html lms/urls.py
This commit is contained in:
@@ -72,26 +72,25 @@ def check_conditions_permissions(user, permissions, course_id, **kwargs):
|
||||
|
||||
|
||||
VIEW_PERMISSIONS = {
|
||||
'update_thread' : ['edit_content', ['update_thread', 'is_open', 'author']],
|
||||
# 'create_comment' : [["create_comment", "is_open"]],
|
||||
'create_comment' : ["create_comment"],
|
||||
'delete_thread' : ['delete_thread'],
|
||||
'update_comment' : ['edit_content', ['update_comment', 'is_open', 'author']],
|
||||
'endorse_comment' : ['endorse_comment'],
|
||||
'openclose_thread' : ['openclose_thread'],
|
||||
'create_sub_comment' : [['create_sub_comment', 'is_open']],
|
||||
'delete_comment' : ['delete_comment'],
|
||||
'vote_for_comment' : [['vote', 'is_open']],
|
||||
'undo_vote_for_comment' : [['unvote', 'is_open']],
|
||||
'vote_for_thread' : [['vote', 'is_open']],
|
||||
'undo_vote_for_thread' : [['unvote', 'is_open']],
|
||||
'follow_thread' : ['follow_thread'],
|
||||
'follow_commentable' : ['follow_commentable'],
|
||||
'follow_user' : ['follow_user'],
|
||||
'unfollow_thread' : ['unfollow_thread'],
|
||||
'unfollow_commentable' : ['unfollow_commentable'],
|
||||
'unfollow_user' : ['unfollow_user'],
|
||||
'create_thread' : ['create_thread'],
|
||||
'update_thread' : ['edit_content', ['update_thread', 'is_open', 'is_author']],
|
||||
'create_comment' : [["create_comment", "is_open"]],
|
||||
'delete_thread' : ['delete_thread'],
|
||||
'update_comment' : ['edit_content', ['update_comment', 'is_open', 'is_author']],
|
||||
'endorse_comment' : ['endorse_comment'],
|
||||
'openclose_thread' : ['openclose_thread'],
|
||||
'create_sub_comment': [['create_sub_comment', 'is_open']],
|
||||
'delete_comment' : ['delete_comment'],
|
||||
'vote_for_comment' : [['vote', 'is_open']],
|
||||
'undo_vote_for_comment': [['unvote', 'is_open']],
|
||||
'vote_for_thread' : [['vote', 'is_open']],
|
||||
'undo_vote_for_thread': [['unvote', 'is_open']],
|
||||
'follow_thread' : ['follow_thread'],
|
||||
'follow_commentable': ['follow_commentable'],
|
||||
'follow_user' : ['follow_user'],
|
||||
'unfollow_thread' : ['unfollow_thread'],
|
||||
'unfollow_commentable': ['unfollow_commentable'],
|
||||
'unfollow_user' : ['unfollow_user'],
|
||||
'create_thread' : ['create_thread'],
|
||||
'update_moderator_status' : ['manage_moderator'],
|
||||
}
|
||||
|
||||
|
||||
@@ -131,6 +131,7 @@ def get_annotated_content_info(course_id, content, user, type):
|
||||
'can_reply': check_permissions_by_view(user, course_id, content, "create_comment" if type == 'thread' else "create_sub_comment"),
|
||||
'can_endorse': check_permissions_by_view(user, course_id, content, "endorse_comment") if type == 'comment' else False,
|
||||
'can_delete': check_permissions_by_view(user, course_id, content, "delete_thread" if type == 'thread' else "delete_comment"),
|
||||
'can_openclose': check_permissions_by_view(user, course_id, content, "openclose_thread") if type == 'thread' else False,
|
||||
}
|
||||
|
||||
def get_annotated_content_infos(course_id, thread, user, type='thread'):
|
||||
|
||||
@@ -232,14 +232,12 @@ initializeFollowThread = (thread) ->
|
||||
handleDelete = (elem) ->
|
||||
if $content.hasClass("thread")
|
||||
url = Discussion.urlFor('delete_thread', id)
|
||||
confirmValue = confirm("Are you sure? This will delete the thread and all comments associated with it and cannot be recovered.")
|
||||
c = confirm "Are you sure to delete thread \"" + $content.find("a.thread-title").text() + "\"?"
|
||||
else
|
||||
url = Discussion.urlFor('delete_comment', id)
|
||||
confirmValue = confirm("Are you sure? This will delete the comment and all replies associated with it and cannot be recovered.")
|
||||
|
||||
if not confirmValue
|
||||
c = confirm "Are you sure to delete this comment? "
|
||||
if c != true
|
||||
return
|
||||
|
||||
Discussion.safeAjax
|
||||
$elem: $(elem)
|
||||
url: url
|
||||
@@ -375,6 +373,15 @@ initializeFollowThread = (thread) ->
|
||||
|
||||
MathJax.Hub.Queue ["Typeset", MathJax.Hub, $contentBody.attr("id")]
|
||||
id = $content.attr("_id")
|
||||
|
||||
discussion_id = $content.parents(".discussion").attr("_id")
|
||||
if $content.hasClass("thread")
|
||||
permalink = Discussion.urlFor("permanent_link_thread", discussion_id, id)
|
||||
else
|
||||
thread_id = $content.parents(".thread").attr("_id")
|
||||
permalink = Discussion.urlFor("permanent_link_comment", discussion_id, thread_id, id)
|
||||
$local(".discussion-permanent-link").attr "href", permalink
|
||||
|
||||
if not Discussion.getContentInfo id, 'editable'
|
||||
$local(".admin-edit").remove()
|
||||
if not Discussion.getContentInfo id, 'can_reply'
|
||||
@@ -383,3 +390,5 @@ initializeFollowThread = (thread) ->
|
||||
$local(".admin-endorse").remove()
|
||||
if not Discussion.getContentInfo id, 'can_delete'
|
||||
$local(".admin-delete").remove()
|
||||
if not Discussion.getContentInfo id, 'can_openclose'
|
||||
$local(".discussion-openclose").remove()
|
||||
|
||||
@@ -16,7 +16,7 @@ wmdEditors = {}
|
||||
.addClass(cls).html(txt)
|
||||
.click -> handler(this)
|
||||
|
||||
urlFor: (name, param, param1) ->
|
||||
urlFor: (name, param, param1, param2) ->
|
||||
{
|
||||
follow_discussion : "/courses/#{$$course_id}/discussion/#{param}/follow"
|
||||
unfollow_discussion : "/courses/#{$$course_id}/discussion/#{param}/unfollow"
|
||||
@@ -44,6 +44,9 @@ wmdEditors = {}
|
||||
retrieve_discussion : "/courses/#{$$course_id}/discussion/forum/#{param}/inline"
|
||||
retrieve_single_thread : "/courses/#{$$course_id}/discussion/forum/#{param}/threads/#{param1}"
|
||||
update_moderator_status : "/courses/#{$$course_id}/discussion/users/#{param}/update_moderator_status"
|
||||
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}"
|
||||
}[name]
|
||||
|
||||
safeAjax: (params) ->
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
<article class="discussion-sidebar-following sidebar-module">
|
||||
<header>
|
||||
<h4>Following</h4>
|
||||
<a href="#" class="sidebar-view-all">view all ›</a>
|
||||
</header>
|
||||
<ol class="discussion-sidebar-following-list">
|
||||
% for thread in recent_active_threads:
|
||||
<li><a href="#"><span class="sidebar-following-name">${thread['title']}</span> <span class="sidebar-vote-count">${thread['votes']['point']}</span></a></li>
|
||||
% endfor
|
||||
<ol>
|
||||
</article>
|
||||
% if recent_active_threads:
|
||||
<article class="discussion-sidebar-following sidebar-module">
|
||||
<header>
|
||||
<h4>Following</h4>
|
||||
<a href="#" class="sidebar-view-all">view all ›</a>
|
||||
</header>
|
||||
<ol class="discussion-sidebar-following-list">
|
||||
% for thread in recent_active_threads:
|
||||
<li><a href="#"><span class="sidebar-following-name">${thread['title']}</span> <span class="sidebar-vote-count">${thread['votes']['point']}</span></a></li>
|
||||
% endfor
|
||||
<ol>
|
||||
</article>
|
||||
% endif
|
||||
|
||||
@@ -9,16 +9,10 @@ def base_url_for_search():
|
||||
%>
|
||||
|
||||
<form action="${base_url_for_search()}" method="get" class="discussion-search-form">
|
||||
<%
|
||||
if tags:
|
||||
displayed_value = "[" + tags + "]" + text
|
||||
else:
|
||||
displayed_value = text
|
||||
%>
|
||||
% if 'tag' in query_params:
|
||||
<input class="search-input" type="text" value="${displayed_value}" id="keywords" autocomplete="off"/>
|
||||
% if query_params.get('tags', None):
|
||||
<input class="search-input" type="text" value="[${tags}]${text}" id="keywords" autocomplete="off"/>
|
||||
% else:
|
||||
<input class="search-input" type="text" value="${displayed_value}" id="keywords" autocomplete="off"/>
|
||||
<input class="search-input" type="text" value="${text}" id="keywords" autocomplete="off"/>
|
||||
% endif
|
||||
<div class="discussion-link discussion-search-link" href="javascript:void(0)">Search posts</div>
|
||||
</form>
|
||||
|
||||
@@ -47,6 +47,15 @@
|
||||
% endif
|
||||
<li><a href="javascript:void(0)" class="admin-edit">Edit</a></li>
|
||||
<li><a href="javascript:void(0)" class="admin-delete">Delete</a></li>
|
||||
% if type == "thread":
|
||||
<li>
|
||||
% if content['closed']:
|
||||
<a class="discussion-openclose" id="discussion-openclose-${content['id']}" href="javascript:void(0);">Re-open thread</a>
|
||||
% else:
|
||||
<a class="discussion-openclose" id="discussion-openclose-${content['id']}" href="javascript:void(0);">Close thread</a>
|
||||
% endif
|
||||
</li>
|
||||
% endif
|
||||
</ul>
|
||||
|
||||
${render_title(content, type, **kwargs)}
|
||||
@@ -98,7 +107,12 @@
|
||||
<ul class="discussion-actions">
|
||||
<li>${render_link("discussion-link discussion-reply discussion-reply-" + type, "Reply")}</li>
|
||||
<li><div class="follow-wrapper"></div></li>
|
||||
<li>${render_link("discussion-link discussion-permanent-link", "Permanent Link")}</li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</%def>
|
||||
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
<article class="discussion-sidebar-tags sidebar-module">
|
||||
<header>
|
||||
<h4>Recent Tags</h4>
|
||||
</header>
|
||||
<ol class="discussion-sidebar-tags-list">
|
||||
% for tag, count in trending_tags:
|
||||
<li><a href="#" class="thread-tag">${tag}</a><span class="sidebar-tag-count">×${count}</span></li>
|
||||
% endfor
|
||||
<ol>
|
||||
</article>
|
||||
% if trending_tags:
|
||||
<article class="discussion-sidebar-tags sidebar-module">
|
||||
<header>
|
||||
<h4>Recent Tags</h4>
|
||||
</header>
|
||||
<ol class="discussion-sidebar-tags-list">
|
||||
% for tag, count in trending_tags:
|
||||
<li><a href="#" class="thread-tag">${tag}</a><span class="sidebar-tag-count">×${count}</span></li>
|
||||
% endfor
|
||||
<ol>
|
||||
</article>
|
||||
% endif
|
||||
|
||||
@@ -147,6 +147,7 @@ if settings.COURSEWARE_ENABLED:
|
||||
# For the instructor
|
||||
url(r'^courses/(?P<course_id>[^/]+/[^/]+/[^/]+)/instructor$',
|
||||
'courseware.views.instructor_dashboard', name="instructor_dashboard"),
|
||||
|
||||
url(r'^courses/(?P<course_id>[^/]+/[^/]+/[^/]+)/gradebook$',
|
||||
'courseware.views.gradebook', name='gradebook'),
|
||||
url(r'^courses/(?P<course_id>[^/]+/[^/]+/[^/]+)/grade_summary$',
|
||||
|
||||
Reference in New Issue
Block a user