Allow students to delete threads / respones; prepare for edit view for response comments (but not complete)
This commit is contained in:
@@ -76,12 +76,12 @@ def check_conditions_permissions(user, permissions, course_id, **kwargs):
|
||||
VIEW_PERMISSIONS = {
|
||||
'update_thread' : ['edit_content', ['update_thread', 'is_open', 'is_author']],
|
||||
'create_comment' : [["create_comment", "is_open"]],
|
||||
'delete_thread' : ['delete_thread'],
|
||||
'delete_thread' : ['delete_thread', ['update_thread', 'is_author']],
|
||||
'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'],
|
||||
'delete_comment' : ['delete_comment', ['update_comment', 'is_open', 'is_author']],
|
||||
'vote_for_comment' : [['vote', 'is_open']],
|
||||
'undo_vote_for_comment': [['unvote', 'is_open']],
|
||||
'vote_for_thread' : [['vote', 'is_open']],
|
||||
|
||||
@@ -2,35 +2,30 @@ if Backbone?
|
||||
class @ResponseCommentView extends DiscussionContentView
|
||||
tagName: "li"
|
||||
|
||||
initLocal: ->
|
||||
# TODO .response-local is the parent of the comments so @$local is null, not sure what was intended here...
|
||||
@$local = @$el.find(".response-local")
|
||||
@$delegateElement = @$local
|
||||
$: (selector) ->
|
||||
@$el.find(selector)
|
||||
|
||||
initialize: ->
|
||||
super()
|
||||
@createShowView()
|
||||
|
||||
render: ->
|
||||
@template = _.template($("#response-comment-template").html())
|
||||
params = @model.toJSON()
|
||||
params['deep'] = @model.hasOwnProperty('parent')
|
||||
if @model.hasOwnProperty('parent')
|
||||
params['parent_id'] = @model.parent.id
|
||||
params['parent_username'] = @model.parent.get('username')
|
||||
@$el.html(@template(params))
|
||||
@initLocal()
|
||||
@delegateEvents()
|
||||
@renderAttrs()
|
||||
@markAsStaff()
|
||||
@$el.find(".timeago").timeago()
|
||||
@convertMath()
|
||||
@renderShowView()
|
||||
@
|
||||
|
||||
convertMath: ->
|
||||
body = @$el.find(".response-body")
|
||||
body.html DiscussionUtil.postMathJaxProcessor DiscussionUtil.markdownWithHighlight body.html()
|
||||
# This removes paragraphs so that comments are more compact
|
||||
body.children("p").each (index, elem) ->
|
||||
$(elem).replaceWith($(elem).html())
|
||||
MathJax.Hub.Queue ["Typeset", MathJax.Hub, body[0]]
|
||||
createShowView: () ->
|
||||
|
||||
markAsStaff: ->
|
||||
if DiscussionUtil.isStaff(@model.get("user_id"))
|
||||
@$el.find("a.profile-link").after('<span class="staff-label">staff</span>')
|
||||
if @editView?
|
||||
@editView.undelegateEvents()
|
||||
@editView.$el.empty()
|
||||
@editView = null
|
||||
|
||||
@showView = new ResponseCommentShowView(model: @model)
|
||||
|
||||
renderSubView: (view) ->
|
||||
view.setElement(@$el)
|
||||
view.render()
|
||||
view.delegateEvents()
|
||||
|
||||
renderShowView: () ->
|
||||
@renderSubView(@showView)
|
||||
|
||||
@@ -93,7 +93,7 @@
|
||||
</ol>
|
||||
</script>
|
||||
|
||||
<script type="text/template" id="response-comment-template">
|
||||
<script type="text/template" id="response-comment-show-template">
|
||||
<p id="comment_${'<%- id %>'}">
|
||||
${'<% if (deep) {%>'}
|
||||
<a href="#comment_${'<%- parent_id %>'}">@${'<%- parent_username %>'}</a>:
|
||||
|
||||
Reference in New Issue
Block a user