diff options
Diffstat (limited to 'controllers/system.js')
-rw-r--r-- | controllers/system.js | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/controllers/system.js b/controllers/system.js index ffbb16b..07f6704 100644 --- a/controllers/system.js +++ b/controllers/system.js @@ -94,17 +94,21 @@ exports.dashboard = function(req, res) { */ Access.loadUser(req.user._id, function(err, projects) { if (err) return res.status(500).render('error', { title: '500', text: 'En serverfeil oppstod', error: err.stack }); - Project.populate(projects, { path: 'project.user', model: User }, function(err, projects) { - var projectIDs = []; - projects.forEach(function(project) { projectIDs.push(project.project._id); console.log(project.project.name); }); + var projectIDs = []; + projects.forEach(function(project) { projectIDs.push(project.project._id); console.log(project.project.name); }); + Access.loadProjects(projectIDs, function(err, participants) { + if (err) return res.status(500).render('error', { title: '500', text: 'En serverfeil oppstod', error: err.stack }); pPost.loadByProjects(projectIDs, function(err, posts) { - console.log(posts); if (err) return res.status(500).render('error', { title: '500', text: 'En serverfeil oppstod', error: err.stack }); - res.render('dashboard', { - title: 'Dashboard', - user: req.user, - projects: projects, - posts: posts + Access.loadProjects(projectIDs, function(err, participants) { + if (err) return res.status(500).render('error', { title: '500', text: 'En serverfeil oppstod', error: err.stack }); + res.render('dashboard', { + title: 'Dashboard', + user: req.user, + projects: projects, + posts: posts, + participants: participants + }); }); }); /* res.render('dashboard', { @@ -114,7 +118,6 @@ exports.dashboard = function(req, res) { }); */ }); - }); /* |