Commit 90b392b2 by Arjun Singh

Allow students to delete threads / respones; prepare for edit view for response…

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