continue work on nonprofit show views

This commit is contained in:
Michael Q Larson
2015-04-01 22:31:08 -07:00
parent fa74a1b454
commit 1248cde97f
6 changed files with 85 additions and 38 deletions

View File

@ -116,6 +116,7 @@ exports.returnIndividualNonprofit = function(req, res, next) {
return res.redirect('../nonprofit/' + dashedNameFull);
}
res.render('nonprofits/show', {
dashedName: dashedNameFull,
title: nonprofit.name,
logoUrl: nonprofit.logoUrl,
estimatedHours: nonprofit.estimatedHours,
@ -130,7 +131,8 @@ exports.returnIndividualNonprofit = function(req, res, next) {
approvedELearning: nonprofit.approvedDeliverables.indexOf('eLearning') > -1,
websiteLink: nonprofit.websiteLink,
imageUrl: nonprofit.imageUrl,
whatDoesNonprofitDo: nonprofit.whatDoesNonprofitDo
whatDoesNonprofitDo: nonprofit.whatDoesNonprofitDo,
interestedCampers: nonprofit.interestedCampers
});
});
};
@ -140,3 +142,15 @@ exports.showAllNonprofits = function(req, res) {
data.nonprofitsList = resources.allNonprofitNames();
res.send(data);
};
exports.interestedInNonprofit = function(req, res) {
if (req.user.uncompletedBonfires !== [] && req.user.uncompletedCoursewares !== []) {
Nonprofit.find({name: req.params.nonprofitName.replace(/-/, ' ')}, function(err, nonprofit) {
if (err) { return next(err); }
nonprofit.interestedCampers.push({"name": req.user.username, "picture": req.user.picture, "timeOfInterest": Date.now()});
req.flash('success', { msg: 'Thanks for expressing interest in this nonprofit project!' });
});
}
res.redirect('back');
};