Changing rebuild route so that it redirects back with a flash message rather than pinning to the 'view' page

This commit is contained in:
Andrew Davidson 2016-01-23 18:20:21 -05:00
parent c44dc8ce95
commit 4feee6f257

View file

@ -15,7 +15,12 @@ module.exports = function(app) {
var start = 0;
}
Post.getPosts(count, start, function(err, posts){
res.render('admin-post-list', {posts, user: req.user});
res.render('admin-post-list', {
successNotice: req.flash('successNotice'),
failureNotice: req.flash('failureNotice'),
posts: posts,
user: req.user
});
});
}
);
@ -156,12 +161,12 @@ module.exports = function(app) {
post.buildPost(function (err) {
if (!err) {
req.flash('successNotice', 'Post rebuilt successfully.');
res.redirect('/admin/post/view/'+req.params.uuid);
res.redirect(req.header('Referer') || '/admin');
}
else {
console.log(err);
req.flash('failureNotice', 'Post regeneration failed, check logs.');
res.redirect('/admin/post/view/'+req.params.uuid);
res.redirect(req.header('Referer') || '/admin');
}
});
});