From b31eee0dd6ffbb52bc36399c2f15b57e19e718c3 Mon Sep 17 00:00:00 2001 From: Aditya Anand M C Date: Wed, 19 Feb 2020 19:28:29 +0530 Subject: [PATCH] feat: ability to delete comments --- app/app/urls.py | 1 + app/assets/v2/js/activity.js | 39 ++++++++++++++++++++++++--- app/townsquare/views.py | 51 ++++++++++++++++++++++++++++++++++++ 3 files changed, 87 insertions(+), 4 deletions(-) diff --git a/app/app/urls.py b/app/app/urls.py index 689eae31a9b..97ecded2ede 100644 --- a/app/app/urls.py +++ b/app/app/urls.py @@ -118,6 +118,7 @@ url(r'^api/v0.1/profile/settings', dashboard.views.profile_settings, name='profile_settings'), url(r'^api/v0.1/profile/backup', dashboard.views.profile_backup, name='profile_backup'), path('api/v0.1/activity/', townsquare.views.api, name='townsquare_api'), + path('api/v0.1/comment/', townsquare.views.comment_v1, name='comment_v1'), path('api/v0.1/emailsettings/', townsquare.views.emailsettings, name='townsquare_emailsettings'), url(r'^api/v0.1/activity', retail.views.create_status_update, name='create_status_update'), url( diff --git a/app/assets/v2/js/activity.js b/app/assets/v2/js/activity.js index 53cd5d898c8..8e075e329cf 100644 --- a/app/assets/v2/js/activity.js +++ b/app/assets/v2/js/activity.js @@ -345,15 +345,17 @@ $(document).ready(function() { $parent.parents('.activity.box').find('.loading').addClass('hidden'); $target.addClass('filled'); $target.html(''); - for (var i = 0; i < response['comments'].length; i++) { + for (let i = 0; i < response['comments'].length; i++) { let comment = sanitizeAPIResults(response['comments'])[i]; let the_comment = comment['comment']; the_comment = urlify(the_comment); the_comment = linkify(the_comment); the_comment = the_comment.replace(/\r\n|\r|\n/g, '
'); - var timeAgo = timedifferenceCvrt(new Date(comment['created_on'])); - var show_tip = true; + const timeAgo = timedifferenceCvrt(new Date(comment['created_on'])); + const show_tip = true; + const is_comment_owner = document.contxt.github_handle == comment['profile_handle']; + let html = `
@@ -384,8 +386,11 @@ $(document).ready(function() { ${the_comment}
+ ${is_comment_owner ? + `| ` + : ''} ${show_tip ? ` -