|
|
|
@ -27,26 +27,32 @@ groupsController.list = function(req, res, next) {
|
|
|
|
|
groupsController.details = function(req, res, next) {
|
|
|
|
|
var uid = req.user ? parseInt(req.user.uid, 10) : 0;
|
|
|
|
|
|
|
|
|
|
async.parallel({
|
|
|
|
|
group: function(next) {
|
|
|
|
|
groups.getByGroupslug(req.params.slug, {
|
|
|
|
|
expand: true,
|
|
|
|
|
uid: uid
|
|
|
|
|
}, next);
|
|
|
|
|
},
|
|
|
|
|
posts: function(next) {
|
|
|
|
|
groups.getLatestMemberPosts(req.params.slug, 10, uid, next);
|
|
|
|
|
}
|
|
|
|
|
}, function(err, results) {
|
|
|
|
|
if (err) {
|
|
|
|
|
return next(err);
|
|
|
|
|
}
|
|
|
|
|
groups.existsBySlug(req.params.slug, function(err, exists) {
|
|
|
|
|
if (exists) {
|
|
|
|
|
async.parallel({
|
|
|
|
|
group: function(next) {
|
|
|
|
|
groups.getByGroupslug(req.params.slug, {
|
|
|
|
|
expand: true,
|
|
|
|
|
uid: uid
|
|
|
|
|
}, next);
|
|
|
|
|
},
|
|
|
|
|
posts: function(next) {
|
|
|
|
|
groups.getLatestMemberPosts(req.params.slug, 10, uid, next);
|
|
|
|
|
}
|
|
|
|
|
}, function(err, results) {
|
|
|
|
|
if (err) {
|
|
|
|
|
return next(err);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!results.group) {
|
|
|
|
|
return helpers.notFound(req, res);
|
|
|
|
|
}
|
|
|
|
|
if (!results.group) {
|
|
|
|
|
return helpers.notFound(req, res);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
res.render('groups/details', results);
|
|
|
|
|
res.render('groups/details', results);
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
return res.locals.isAPI ? res.status(302).json('/groups') : res.redirect('/groups');
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|