1
0
mirror of https://github.com/stolksdorf/homebrewery.git synced 2025-12-13 20:05:56 +00:00

Added in the admin page

This commit is contained in:
Scott Tolksdorf
2016-01-06 20:04:45 -05:00
parent 25b53a7c24
commit 46186c0de2
11 changed files with 224 additions and 16 deletions

View File

@@ -1,12 +1,6 @@
var vitreumRender = require('vitreum/render');
var HomebrewModel = require('./homebrew.model.js').model;
module.exports = function(app){
@@ -49,6 +43,7 @@ module.exports = function(app){
if(!objs.length || err) return res.status(404).send("Can not find homebrew with that id");
var resEntry = objs[0];
resEntry.text = req.body.text;
resEntry.updatedAt = new Date();
resEntry.save(function(err, obj){
if(err) return res.status(500).send("Error while saving");
return res.status(200).send(obj);
@@ -56,6 +51,21 @@ module.exports = function(app){
});
});
app.get('/homebrew/remove/:id', function(req, res){
if(req.query && req.query.admin_key == process.env.ADMIN_KEY){
HomebrewModel.find({editId : req.params.id}, function(err, objs){
if(!objs.length || err) return res.status(404).send("Can not find homebrew with that id");
var resEntry = objs[0];
resEntry.remove(function(err){
if(err) return res.status(500).send("Error while removing");
return res.status(200).send();
})
});
}else{
return res.status(401).send('Access denied');
}
});
//Share Page
@@ -67,7 +77,9 @@ module.exports = function(app){
resObj = objs[0];
}
resObj.editId = null;
resObj.lastViewed = new Date();
resObj.views = resObj.views + 1;
resObj.save();
vitreumRender({
page: './build/homebrew/bundle.dot',