Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#97 Allows admins to delete a specific question of an instance #98

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions client/views/helpers/chunks/question_div/question_div.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@
</span>
{{/if}}
{{/if}}
{{#if adminButtons}}
<span class="image-icon deletebutton adminquestiondelete" id="{{text}}" title="Delete"></span>
{{/if}}
</span>
<span class="sharing">
{{#if popular}}
Expand Down
7 changes: 7 additions & 0 deletions client/views/helpers/chunks/question_div/question_div.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
},
});
10 changes: 9 additions & 1 deletion client/views/helpers/chunks/question_div/question_div.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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;
}
Expand Down
Binary file added public/delete_black.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/delete_red.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions server/methods.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down