From f93cd061359f9060976d8209a0cc37d42b295edf Mon Sep 17 00:00:00 2001 From: Dennis Eriksen Date: Tue, 30 Apr 2013 09:09:55 +0200 Subject: working with project listing --- controllers/system.js | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'controllers/system.js') diff --git a/controllers/system.js b/controllers/system.js index e3a55bd..6bd9d22 100644 --- a/controllers/system.js +++ b/controllers/system.js @@ -54,11 +54,17 @@ exports.faq = function(req, res) { exports.dashboard = function(req, res) { console.log('/dashboard - ' + req.user); - res.render('dashboard', { - title: 'kanin', - loggedin: true + + Project.find(function(err, projects) { + if (err) return res.render('500'); + console.log(projects); + res.render('dashboard', { + title: 'Dashboad', + loggedin: true, + projects: projects + }); }); -}; +} @@ -73,7 +79,10 @@ exports.newProject = function(req, res) { exports.postNewProject = function(req, res) { var project = new Project(req.body); project.save(function(err) { - if (err) return res.render('newproject', { title: 'Nytt prosjekt - en feil oppstod', loggedin: true, errors: err.errors, project: project }); + if (err) { + console.log(err.errors); + return res.render('newproject', { title: 'Nytt prosjekt - en feil oppstod', loggedin: true, errors: err.errors, project: project }); + } return res.redirect('/dashboard'); }); } -- cgit v1.2.3