[#1444] implement delete-tag (incl server route). run tags-cleanup migration

This commit is contained in:
Tyler Renelle
2013-09-09 00:04:02 -04:00
parent f99b496a29
commit 4caec6f737
6 changed files with 58 additions and 27 deletions
+24
View File
@@ -594,6 +594,30 @@ api.buyGems = function(req, res) {
});
};
/*
------------------------------------------------------------------------
Tags
------------------------------------------------------------------------
*/
api.deleteTag = function(req, res){
var user = res.locals.user;
var i = _.findIndex(user.tags, {id:req.params.tid});
if (~i) {
var tag = user.tags[i];
delete user.filters[tid];
user.tags.splice(i,1);
// remove tag from all tasks
_.each(user.tasks, function(task) {
delete user.tasks[task.id].tags[tag.id];
});
user.save(function(err,saved){
res.send(200);
})
} else {
res.json(400, {err:'Tag not found'});
}
}
/*
------------------------------------------------------------------------
Batch Update