Make the "new task" form functional

This commit is contained in:
Rowan Manning
2013-09-16 11:09:49 +01:00
parent a7aad37ea0
commit 7fd93d114f
5 changed files with 54 additions and 2 deletions

View File

@@ -4,7 +4,22 @@ module.exports = route;
// Route definition
function route (app) {
app.express.get('/new', function (req, res) {
res.render('new');
});
app.express.post('/new', function (req, res) {
var newTask = {
url: req.body.url,
standard: req.body.standard
};
app.webservice.tasks.create(newTask, function (err, task) {
if (err) {
return res.render('new', {error: err});
}
res.redirect('/' + task.id + '?added');
});
});
}