Commit 5df5cf98 by Mike Chen

fix Close Thread showing for students and empty bracket in search bar

parent ca2a2d2f
...@@ -149,12 +149,14 @@ def forum_form_discussion(request, course_id, discussion_id): ...@@ -149,12 +149,14 @@ def forum_form_discussion(request, course_id, discussion_id):
def get_annotated_content_info(course_id, content, user, is_thread): def get_annotated_content_info(course_id, content, user, is_thread):
return { permissions = {
'editable': check_permissions_by_view(user, course_id, content, "update_thread" if is_thread else "update_comment"), 'editable': check_permissions_by_view(user, course_id, content, "update_thread" if is_thread else "update_comment"),
'can_reply': check_permissions_by_view(user, course_id, content, "create_comment" if is_thread else "create_sub_comment"), 'can_reply': check_permissions_by_view(user, course_id, content, "create_comment" if is_thread else "create_sub_comment"),
'can_endorse': check_permissions_by_view(user, course_id, content, "endorse_comment") if not is_thread else False, 'can_endorse': check_permissions_by_view(user, course_id, content, "endorse_comment") if not is_thread else False,
'can_delete': check_permissions_by_view(user, course_id, content, "delete_thread" if is_thread else "delete_comment"), 'can_delete': check_permissions_by_view(user, course_id, content, "delete_thread" if is_thread else "delete_comment"),
'can_openclose': check_permissions_by_view(user, course_id, content, "openclose_thread") if is_thread else False,
} }
return permissions
def get_annotated_content_infos(course_id, thread, user, is_thread=True): def get_annotated_content_infos(course_id, thread, user, is_thread=True):
infos = {} infos = {}
......
...@@ -67,11 +67,10 @@ def check_conditions_permissions(user, permissions, course_id, **kwargs): ...@@ -67,11 +67,10 @@ def check_conditions_permissions(user, permissions, course_id, **kwargs):
VIEW_PERMISSIONS = { VIEW_PERMISSIONS = {
'update_thread' : ['edit_content', ['update_thread', 'is_open', 'author']], 'update_thread' : ['edit_content', ['update_thread', 'is_open', 'is_author']],
# 'create_comment' : [["create_comment", "is_open"]], 'create_comment' : [["create_comment", "is_open"]],
'create_comment' : ["create_comment"],
'delete_thread' : ['delete_thread'], 'delete_thread' : ['delete_thread'],
'update_comment' : ['edit_content', ['update_comment', 'is_open', 'author']], 'update_comment' : ['edit_content', ['update_comment', 'is_open', 'is_author']],
'endorse_comment' : ['endorse_comment'], 'endorse_comment' : ['endorse_comment'],
'openclose_thread' : ['openclose_thread'], 'openclose_thread' : ['openclose_thread'],
'create_sub_comment': [['create_sub_comment', 'is_open']], 'create_sub_comment': [['create_sub_comment', 'is_open']],
......
...@@ -372,3 +372,5 @@ initializeFollowThread = (thread) -> ...@@ -372,3 +372,5 @@ initializeFollowThread = (thread) ->
$local(".discussion-endorse-control").remove() $local(".discussion-endorse-control").remove()
if not Discussion.getContentInfo id, 'can_delete' if not Discussion.getContentInfo id, 'can_delete'
$local(".discussion-delete").remove() $local(".discussion-delete").remove()
if not Discussion.getContentInfo id, 'can_openclose'
$local(".discussion-openclose").remove()
...@@ -12,7 +12,7 @@ def base_url_for_search(): ...@@ -12,7 +12,7 @@ def base_url_for_search():
% if query_params.get('tags', None): % if query_params.get('tags', None):
<input class="search-input" type="text" value="[${tags}]${text}" id="keywords" autocomplete="off"/> <input class="search-input" type="text" value="[${tags}]${text}" id="keywords" autocomplete="off"/>
% else: % else:
<input class="search-input" type="text" value="[${tags}]${text}" id="keywords" autocomplete="off"/> <input class="search-input" type="text" value="${text}" id="keywords" autocomplete="off"/>
% endif % endif
<div class="discussion-link discussion-search-link" href="javascript:void(0)">Search posts</div> <div class="discussion-link discussion-search-link" href="javascript:void(0)">Search posts</div>
</form> </form>
...@@ -98,7 +98,7 @@ ...@@ -98,7 +98,7 @@
<label class="discussion-link" for="discussion-endorse-${content['id']}">Endorsed</label> <label class="discussion-link" for="discussion-endorse-${content['id']}">Endorsed</label>
</span> </span>
% if type == "thread" and request.user.is_staff: % if type == "thread":
% if content['closed']: % if content['closed']:
<a class="discussion-openclose" id="discussion-openclose-${content['id']}" href="javascript:void(0);">Re-open thread</a> <a class="discussion-openclose" id="discussion-openclose-${content['id']}" href="javascript:void(0);">Re-open thread</a>
% else: % else:
......
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