Commit b26cf0e7 by Xavier Antoviaque

Merge pull request #330 from open-craft/eugeny/discussion-backport

Discussion course production deployment issues fix
parents 114dbeb2 45422e07
...@@ -1295,6 +1295,7 @@ class DiscussionService(object): ...@@ -1295,6 +1295,7 @@ class DiscussionService(object):
course_settings = make_course_settings(course) course_settings = make_course_settings(course)
context = { context = {
'user': user,
'course': course, 'course': course,
'course_id': course_id, 'course_id': course_id,
'staff_access': has_access(user, 'staff', course), 'staff_access': has_access(user, 'staff', course),
...@@ -1311,11 +1312,7 @@ class DiscussionService(object): ...@@ -1311,11 +1312,7 @@ class DiscussionService(object):
'sort_preference': user_info['default_sort_key'], 'sort_preference': user_info['default_sort_key'],
'cohorted_commentables': cohorted_commentables, 'cohorted_commentables': cohorted_commentables,
'is_course_cohorted': course_settings['is_cohorted'], 'is_course_cohorted': course_settings['is_cohorted'],
'course_settings': saxutils.escape(json.dumps(course_settings), escapedict), 'course_settings': saxutils.escape(json.dumps(course_settings), escapedict)
'has_permission_to_create_thread': cached_has_permission(user, "create_thread", course_id),
'has_permission_to_create_comment': cached_has_permission(user, "create_comment", course_id),
'has_permission_to_create_subcomment': cached_has_permission(user, "create_subcomment", course_id),
'has_permission_to_openclose_thread': cached_has_permission(user, "openclose_thread", course_id)
} }
return context return context
......
<%! from django.utils.translation import ugettext as _ %> <%! from django.utils.translation import ugettext as _ %>
<%! from django.template.defaultfilters import escapejs %> <%! from django.template.defaultfilters import escapejs %>
<%! from django_comment_client.permissions import has_permission %> <%! from django_comment_client.permissions import cached_has_permission %>
<%namespace name='static' file='../static_content.html'/> <%namespace name='static' file='../static_content.html'/>
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
</div> </div>
<div class="post-extended-content"> <div class="post-extended-content">
<div class="response-count"/> <div class="response-count"/>
% if course is UNDEFINED or has_permission(user, 'create_comment', course.id): % if course is UNDEFINED or cached_has_permission(user, 'create_comment', course.id):
<div class="add-response"> <div class="add-response">
<button class="button add-response-btn"> <button class="button add-response-btn">
<i class="icon icon-reply"></i> <i class="icon icon-reply"></i>
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
<div class="post-status-closed bottom-post-status" style="display: none"> <div class="post-status-closed bottom-post-status" style="display: none">
${_("This thread is closed.")} ${_("This thread is closed.")}
</div> </div>
% if course is UNDEFINED or has_permission(user, 'create_comment', course.id): % if course is UNDEFINED or cached_has_permission(user, 'create_comment', course.id):
<form class="discussion-reply-new" data-id="${'<%- id %>'}"> <form class="discussion-reply-new" data-id="${'<%- id %>'}">
<h4>${_("Post a response:")}</h4> <h4>${_("Post a response:")}</h4>
<ul class="discussion-errors"></ul> <ul class="discussion-errors"></ul>
...@@ -78,7 +78,7 @@ ...@@ -78,7 +78,7 @@
</a> </a>
<ol class="comments"> <ol class="comments">
<li class="new-comment"> <li class="new-comment">
% if course is UNDEFINED or has_permission(user, 'create_sub_comment', course.id): % if course is UNDEFINED or cached_has_permission(user, 'create_sub_comment', course.id):
<form class="comment-form" data-id="${'<%- wmdId %>'}"> <form class="comment-form" data-id="${'<%- wmdId %>'}">
<ul class="discussion-errors"></ul> <ul class="discussion-errors"></ul>
<label class="sr" for="add-new-comment">${_("Add a comment")}</label> <label class="sr" for="add-new-comment">${_("Add a comment")}</label>
......
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