From fcbd030b36426843acfb13ac567e80014910b628 Mon Sep 17 00:00:00 2001 From: Dennis Eriksen Date: Fri, 24 May 2013 10:12:25 +0200 Subject: fixed some nicklists and other stuffs --- controllers/system.js | 23 +++++++++++++---------- views/dashboard.ejs | 12 ++++++++++-- 2 files changed, 23 insertions(+), 12 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) { }); */ }); - }); /* diff --git a/views/dashboard.ejs b/views/dashboard.ejs index 1c1c4df..7fd41fa 100644 --- a/views/dashboard.ejs +++ b/views/dashboard.ejs @@ -18,10 +18,18 @@
-

<%= projects.project.user.username %>/<%= projects.project.name %>

+

<%= projects.project.name %>

- Meg, Robert, Turid-Laila, Kurt, Stian, Aleksander, Frank, Olav, Heidi, Anette, Kristine + + <% var ppl = 'Meg'; + participants.forEach(function(participant) { + if (String(participant.project) === String(projects.project._id) && String(participant.user._id) !== String(user._id)) { + ppl += ', ' + participant.user.name; + } + }); %> + <%- ppl %> +
Oppgjør: -200 kr -- cgit v1.2.3