From 2f64da625ef0e28aa7c92f41be0e9bb10febfb37 Mon Sep 17 00:00:00 2001 From: Zambom Date: Thu, 9 Feb 2017 20:09:50 -0200 Subject: [PATCH] Adding comment deletion --- amadeus/static/css/base/amadeus.css | 2 +- amadeus/static/js/mural.js | 43 +++++++++++++++++++++++++++++++++++++++++++ mural/templates/mural/_view_comment.html | 2 +- mural/templates/mural/delete.html | 2 +- mural/urls.py | 2 ++ mural/views.py | 30 ++++++++++++++++++++++++++++++ 6 files changed, 78 insertions(+), 3 deletions(-) diff --git a/amadeus/static/css/base/amadeus.css b/amadeus/static/css/base/amadeus.css index e5b9c00..bd1051f 100755 --- a/amadeus/static/css/base/amadeus.css +++ b/amadeus/static/css/base/amadeus.css @@ -1026,7 +1026,7 @@ li.item .notify_badge { margin: 0; } -.post .post-user .btn-group .dropdown-menu a { +.post .post-user .btn-group .dropdown-menu a, .comment .comment-user .btn-group .dropdown-menu a { cursor: pointer; } diff --git a/amadeus/static/js/mural.js b/amadeus/static/js/mural.js index 2869388..18d20e9 100644 --- a/amadeus/static/js/mural.js +++ b/amadeus/static/js/mural.js @@ -268,4 +268,47 @@ function setCommentFormSubmit(post, comment = "") { return false; }); +} + +function deleteComment(btn) { + var url = btn.data('url'); + var comment = btn.data('id'); + + console.log(comment); + + $.ajax({ + url: url, + success: function (data) { + $('#post-modal-form').html(data); + + setCommentDeleteSubmit(comment); + + $('#post-modal-form').modal('show'); + } + }); +} + +function setCommentDeleteSubmit (comment) { + var frm = $("#delete_form"); + + frm.submit(function () { + $.ajax({ + type: frm.attr('method'), + url: frm.attr('action'), + data: frm.serialize(), + success: function (response) { + + $("#comment-" + comment).remove(); + + $('#post-modal-form').modal('hide'); + + alertify.success(response.msg); + }, + error: function (data) { + console.log(data); + } + }); + + return false; + }); } \ No newline at end of file diff --git a/mural/templates/mural/_view_comment.html b/mural/templates/mural/_view_comment.html index 6e0cc3a..c6c5bd0 100644 --- a/mural/templates/mural/_view_comment.html +++ b/mural/templates/mural/_view_comment.html @@ -21,7 +21,7 @@ {% endif %} diff --git a/mural/templates/mural/delete.html b/mural/templates/mural/delete.html index 28ac6c0..08b1b46 100644 --- a/mural/templates/mural/delete.html +++ b/mural/templates/mural/delete.html @@ -5,7 +5,7 @@