diff --git a/client/views/helpers/chunks/question_div/question_div.html b/client/views/helpers/chunks/question_div/question_div.html index cbf85c59..ad10a1aa 100644 --- a/client/views/helpers/chunks/question_div/question_div.html +++ b/client/views/helpers/chunks/question_div/question_div.html @@ -42,6 +42,9 @@ {{/if}} {{/if}} + {{#if adminButtons}} + + {{/if}} {{#if popular}} diff --git a/client/views/helpers/chunks/question_div/question_div.js b/client/views/helpers/chunks/question_div/question_div.js index fd5e8f3b..9149e4b9 100644 --- a/client/views/helpers/chunks/question_div/question_div.js +++ b/client/views/helpers/chunks/question_div/question_div.js @@ -101,4 +101,11 @@ Template.question_div.events({ const parentNode = document.getElementById('nav'); popoverTemplate = Blaze.renderWithData(Template.modify, template.data._id, parentNode); }, + 'click .adminquestiondelete': function (event, template) { + const quesId = template.data._id; + Meteor.call('adminQuesDel', quesId, (error, result) => { + console.log(error); + console.log(result); + }); + }, }); diff --git a/client/views/helpers/chunks/question_div/question_div.scss b/client/views/helpers/chunks/question_div/question_div.scss index 1e553660..2e46163f 100644 --- a/client/views/helpers/chunks/question_div/question_div.scss +++ b/client/views/helpers/chunks/question_div/question_div.scss @@ -137,7 +137,7 @@ $popular-question-color: #f1c40f; } .facebookbutton { - background-image: url('/facebook.png'); + background-image: url('/facebook.png'); &:hover { background-image: url('/facebook_blue.png'); @@ -152,6 +152,14 @@ $popular-question-color: #f1c40f; } } +.deletebutton { + background-image: url('/delete_black.png'); + + &:hover { + background-image: url('/delete_red.png'); + } +} + .hiddenanswers { display: none; } diff --git a/public/delete_black.png b/public/delete_black.png new file mode 100644 index 00000000..96bf49a0 Binary files /dev/null and b/public/delete_black.png differ diff --git a/public/delete_red.png b/public/delete_red.png new file mode 100644 index 00000000..71ba2c97 Binary files /dev/null and b/public/delete_red.png differ diff --git a/server/methods.js b/server/methods.js index 6d4b5233..ece70b59 100644 --- a/server/methods.js +++ b/server/methods.js @@ -499,6 +499,23 @@ Meteor.methods({ } return false; }, + adminQuesDel(quesid) { + // Ensures that the user has proper admin privileges + if (this.userId) { + Questions.remove({ _id: quesid }); + + const v_num = Votes.find({ qid: quesid }).count(); + const v_r = Votes.remove({ qid: quesid }); + if (v_num > v_r) { return false; } + + const a_num = Answers.find({ qid: quesid }).count(); + const a_r = Answers.remove({ qid: quesid }); + if (a_num > a_r) { return false; } + + return true; + } + return false; + }, rename(id, name, desc) { if (this.userId) { let result;