added delete link
This commit is contained in:
@@ -133,6 +133,7 @@ def get_annotated_content_info(content, user, is_thread):
|
||||
'editable': check_permissions_by_view(user, content, "update_thread" if is_thread else "update_comment"),
|
||||
'can_reply': check_permissions_by_view(user, content, "create_comment" if is_thread else "create_sub_comment"),
|
||||
'can_endorse': check_permissions_by_view(user, content, "endorse_comment") if not is_thread else False,
|
||||
'can_delete': check_permissions_by_view(user, content, "delete_thread" if is_thread else "delete_comment"),
|
||||
}
|
||||
|
||||
def get_annotated_content_infos(thread, user):
|
||||
|
||||
@@ -223,6 +223,24 @@ initializeFollowThread = (thread) ->
|
||||
error: (response, textStatus, e) ->
|
||||
console.log e
|
||||
|
||||
handleDelete = (elem) ->
|
||||
if $content.hasClass("thread")
|
||||
url = Discussion.urlFor('delete_thread', id)
|
||||
else
|
||||
url = Discussion.urlFor('delete_comment', id)
|
||||
|
||||
Discussion.safeAjax
|
||||
$elem: $(elem)
|
||||
url: url
|
||||
type: "POST"
|
||||
dataType: "json"
|
||||
data: {}
|
||||
success: (response, textStatus) =>
|
||||
if textStatus == "success"
|
||||
$(content).remove()
|
||||
error: (response, textStatus, e) ->
|
||||
console.log e
|
||||
|
||||
handleHideSingleThread = (elem) ->
|
||||
$threadTitle = $local(".thread-title")
|
||||
$showComments = $local(".discussion-show-comments")
|
||||
@@ -308,6 +326,9 @@ initializeFollowThread = (thread) ->
|
||||
else
|
||||
handleEditComment(this)
|
||||
|
||||
"click .discussion-delete": ->
|
||||
handleDelete(this)
|
||||
|
||||
initializeContent: (content) ->
|
||||
$content = $(content)
|
||||
initializeVote $content
|
||||
@@ -326,3 +347,5 @@ initializeFollowThread = (thread) ->
|
||||
$local(".discussion-reply").remove()
|
||||
if not Discussion.getContentInfo id, 'can_endorse'
|
||||
$local(".discussion-endorse-control").remove()
|
||||
if not Discussion.getContentInfo id, 'can_delete'
|
||||
$local(".discussion-delete").remove()
|
||||
|
||||
@@ -95,6 +95,9 @@
|
||||
<a class="discussion-openclose" id="discussion-openclose-${content['id']}" href="javascript:void(0);">Close thread</a>
|
||||
% endif
|
||||
% endif
|
||||
|
||||
${render_link("discussion-link discussion-delete", "Delete")}
|
||||
|
||||
</div>
|
||||
</%def>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user