Skip to content
Merged
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
4 changes: 2 additions & 2 deletions controllers/remove.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ exports.rm = function (aReq, aRes, aNext) {
});
}

// Simple error check for string null and reserved phrase
// Simple error check for string null
reason = reason.trim();
if (reason === '' || /^User removed$/i.test(reason)) {
if (reason === '') {
return statusCodePage(aReq, aRes, aNext, {
statusCode: 403,
statusMessage: 'Invalid reason for removal.'
Expand Down
10 changes: 9 additions & 1 deletion libs/modelParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,15 @@ var parseRemovedItem = function (aRemovedItemData) {
parseDateProperty(removedItem, 'removed');

// User
removedItem.remover = parseUser({ name: removedItem.removerName });
removedItem.remover = parseUser({
name: removedItem.removerName,
automated: removedItem.removerAutomated
});

// Reason
removedItem.reason = removedItem.reason ?
removedItem.reason :
(removedItem.removerAutomated ? removedItem.model + ' removed' : null);

// Content
var parseModelFn = parseModelFnMap[removedItem.model];
Expand Down
13 changes: 8 additions & 5 deletions libs/remove.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,15 @@ function removeable(aModel, aContent, aUser, aCallback) {
}
exports.removeable = removeable;

function remove(aModel, aContent, aUser, aReason, aCallback) {
function remove(aModel, aContent, aUser, aReason, aAutomated, aCallback) {
var removeModel = new Remove({
'model': aModel.modelName,
'content': aContent.toObject(),
'removed': new Date(),
'reason': aReason,
'removerName': aUser.name,
'removerRole': aUser.role,
'removerAutomated': aAutomated,
'_removerId': aUser._id
});

Expand All @@ -67,22 +68,24 @@ function remove(aModel, aContent, aUser, aReason, aCallback) {

exports.remove = function (aModel, aContent, aUser, aReason, aCallback) {
removeable(aModel, aContent, aUser, function (aCanRemove, aAuthor) {
if (!aCanRemove) { return aCallback(false); }
if (!aCanRemove) {
return aCallback(false);
}

if (aModel.modelName !== 'User') {
remove(aModel, aContent, aUser, aReason, aCallback);
remove(aModel, aContent, aUser, aReason, false, aCallback);
} else {
// Remove all the user's content
async.each(modelNames, function (aModelName, aCallback) {
var model = models[aModelName];
model.find({ _authorId: aContent._id },
function (aErr, aContentArr) {
async.each(aContentArr, function (aContent, innerCb) {
remove(model, aContent, aUser, 'User removed', innerCb);
remove(model, aContent, aUser, '', true, innerCb);
}, aCallback);
});
}, function () {
remove(aModel, aContent, aUser, aReason, aCallback);
remove(aModel, aContent, aUser, aReason, false, aCallback);
});
}
});
Expand Down
1 change: 1 addition & 0 deletions models/remove.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ var removeSchema = new Schema({
reason: String,
removerName: String,
removerRole: Number,
removerAutomated: Boolean,
_removerId: Schema.Types.ObjectId
});

Expand Down
4 changes: 4 additions & 0 deletions public/css/common.css
Original file line number Diff line number Diff line change
Expand Up @@ -291,3 +291,7 @@ a.panel-heading {
text-align: center;
width: 1.28571429em;
}

.reason-automated {
opacity: 0.25;
}
8 changes: 4 additions & 4 deletions views/includes/removedItemList.html
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<table class="table table-hover table-condensed">
<thead>
<tr>
<th class="text-center td-fit"><a href="?orderBy=model&orderDir={{orderDir.model}}">Type</a></th>
<th class="text-center td-fit"><a href="?orderBy=model&orderDir={{orderDir.model}}{{#searchBarValue}}&q={{searchBarValue}}{{/searchBarValue}}">Type</a></th>
<th>Item</th>
<th>Reason</th>
<th class="text-center td-fit"><a href="?orderBy=removerName&orderDir={{orderDir.removerName}}">Removed By</a></th>
<th class="text-center td-fit"><a href="?orderBy=removed&orderDir={{orderDir.removed}}">Date</a></th>
<th class="text-center td-fit"><a href="?orderBy=removerName&orderDir={{orderDir.removerName}}{{#searchBarValue}}&q={{searchBarValue}}{{/searchBarValue}}">Removed By</a></th>
<th class="text-center td-fit"><a href="?orderBy=removed&orderDir={{orderDir.removed}}{{#searchBarValue}}&q={{searchBarValue}}{{/searchBarValue}}">Date</a></th>
</tr>
</thead>
<tbody>
Expand All @@ -18,7 +18,7 @@
<p><a href="{{{url}}}" class="tr-link-a">{{item.description}}</a></p>
</td>
<td>
<p>{{reason}}</p>
<p{{#remover.automated}} class="reason-automated"{{/remover.automated}}>{{reason}}</p>
</td>
<td class="td-fit">
<p>
Expand Down
11 changes: 8 additions & 3 deletions views/pages/removedItemListPage.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,14 @@ <h2 class="page-heading">
{{> includes/searchBarPanel.html }}
<h3>Filters</h3>
<div class="list-group">
<a href="?q=Script" class="list-group-item">Scripts</a>
<a href="?q=User" class="list-group-item">Users</a>
<a href="?q=" class="list-group-item">All Types</a>
<a href="./removed" class="list-group-item"><i class="fa fa-fw fa-times"></i> Clear search</a>
<a href="?q=User" class="list-group-item"><i class="fa fa-fw fa-search"></i> Users</a>
<a href="?q=Script" class="list-group-item"><i class="fa fa-fw fa-search"></i> Scripts</a>
<a href="?q=Comment" class="list-group-item"><i class="fa fa-fw fa-search"></i> Comments</a>
<a href="?q=Discussion" class="list-group-item"><i class="fa fa-fw fa-search"></i> Discussion</a>
<a href="?q=Flag" class="list-group-item"><i class="fa fa-fw fa-search"></i> Flags</a>
<a href="?q=Group" class="list-group-item"><i class="fa fa-fw fa-search"></i> Groups</a>
<a href="?q=Vote" class="list-group-item"><i class="fa fa-fw fa-search"></i> Votes</a>
</div>
</div>
</div>
Expand Down