Update nonprofits structure and remove old directory

This commit is contained in:
Quincy Larson
2016-01-09 23:48:37 -06:00
committed by Berkeley Martinez
parent 7eefcb0705
commit 09b4f1caa2
6 changed files with 0 additions and 553 deletions

View File

@@ -1,107 +0,0 @@
var Rx = require('rx');
var debug = require('debug')('freecc:nonprofits');
var observeMethod = require('../utils/rx').observeMethod;
var unDasherize = require('../utils').unDasherize;
var dasherize = require('../utils').dasherize;
module.exports = function(app) {
var router = app.loopback.Router();
var Nonprofit = app.models.Nonprofit;
var findNonprofits = observeMethod(Nonprofit, 'find');
var findOneNonprofit = observeMethod(Nonprofit, 'findOne');
router.get('/nonprofits/directory', nonprofitsDirectory);
router.get('/nonprofits/:nonprofitName', returnIndividualNonprofit);
app.use(router);
function nonprofitsDirectory(req, res, next) {
findNonprofits({
order: 'moneySaved DESC'
})
.flatMap(
(nonprofits = []) => {
// turn array of nonprofits into observable array
return Rx.Observable.from(nonprofits)
.pluck('moneySaved')
.reduce((sum, moneySaved = 0) => sum + moneySaved, 0);
},
(nonprofits = [], totalSavings) => ({ nonprofits, totalSavings })
)
.subscribe(({ nonprofits, totalSavings }) => {
res.render('nonprofits/directory', {
title: 'Nonprofits we help',
nonprofits: nonprofits,
totalSavings: totalSavings.toString().replace(/000$/, ',000')
});
},
next
);
}
function returnIndividualNonprofit(req, res, next) {
var dashedName = req.params.nonprofitName;
var nonprofitName = unDasherize(dashedName);
var query = { where: { name: {
like: nonprofitName,
options: 'i'
} } };
debug('looking for %s', nonprofitName);
debug('query', query);
findOneNonprofit(query).subscribe(
function(nonprofit) {
if (!nonprofit) {
req.flash('errors', {
msg: "404: We couldn't find a nonprofit with that name. " +
'Please double check the name.'
});
return res.redirect('/nonprofits');
}
var dashedNameFull = dasherize(nonprofit.name);
if (dashedNameFull !== dashedName) {
return res.redirect('../nonprofit/' + dashedNameFull);
}
res.render('nonprofits/show', {
dashedName: dashedNameFull,
title: nonprofit.name,
logoUrl: nonprofit.logoUrl,
estimatedHours: nonprofit.estimatedHours,
projectDescription: nonprofit.projectDescription,
approvedOther:
nonprofit.approvedDeliverables.indexOf('other') > -1,
approvedWebsite:
nonprofit.approvedDeliverables.indexOf('website') > -1,
approvedDonor:
nonprofit.approvedDeliverables.indexOf('donor') > -1,
approvedInventory:
nonprofit.approvedDeliverables.indexOf('inventory') > -1,
approvedVolunteer:
nonprofit.approvedDeliverables.indexOf('volunteer') > -1,
approvedForm:
nonprofit.approvedDeliverables.indexOf('form') > -1,
approvedCommunity:
nonprofit.approvedDeliverables.indexOf('community') > -1,
approvedELearning:
nonprofit.approvedDeliverables.indexOf('eLearning') > -1,
websiteLink: nonprofit.websiteLink,
imageUrl: nonprofit.imageUrl,
whatDoesNonprofitDo: nonprofit.whatDoesNonprofitDo,
interestedCampers: nonprofit.interestedCampers,
assignedCampers: nonprofit.assignedCampers,
buttonActive: false,
moneySaved: nonprofit.moneySaved,
currentStatus: nonprofit.currentStatus
});
},
next
);
}
};

View File

@@ -1,27 +0,0 @@
extends ../layout
block content
script.
var challengeName = 'Nonprofits View';
.col-xs-12.col-sm-12.col-md-12
.panel.panel-info
.panel-heading.text-center Nonprofits We Help
.panel-body
.col-xs-12.col-sm-12.col-md-10.col-md-offset-1
h1.text-primary.text-center Our campers have saved nonprofits $#{totalSavings}.
.spacer
for nonprofit in nonprofits
.spacer
.row
.col-xs-12.col-sm-3
img.img-responsive.img-center(src=nonprofit.logoUrl)
.col-xs-12.col-sm-9
h2.negative-15= nonprofit.name
h3.negative-15= nonprofit.whatDoesNonprofitDo
if (nonprofit.moneySaved > 0)
h4.negative-15.text-primary Estimated Cost Savings for Nonprofit: $#{nonprofit.moneySaved.toString().replace(/000$/, ',000')}
a.text-center.btn.btn-primary.btn-lg(href='/nonprofits/' + nonprofit.name.toLowerCase().replace(/\s/g, '-')) Read more
.spacer
.col-xs-12.col-sm-8.col-sm-offset-2
if (!user)
a.btn.btn-cta.signup-btn.btn-block(href="/nonprofits-form") My nonprofit needs coding help
.spacer

View File

@@ -1,75 +0,0 @@
extends ../layout
block content
script.
var challengeName = 'Nonprofits View';
.row
.col-xs-12.col-sm-10.col-sm-offset-1
.row
.col-xs-12
img.img-center.img-responsive(src=imageUrl)
.spacer
.row
.col-xs-12.col-sm-4
img.img-responsive(src=logoUrl)
.col-xs-12.col-sm-8
.col-xs-12
h4= whatDoesNonprofitDo
h4
a(href=websiteLink)= websiteLink
.spacer
h3 Project Description:
.col-xs-12
h4.negative-15 #{projectDescription} (About #{estimatedHours} hours per camper)
.spacer
h3 This project involves building:
h4.negative-15.col-xs-12
if (approvedWebsite)
.ion-android-globe   Website
if (approvedDonor)
.ion-card   Donor Management System
if (approvedInventory)
.ion-ios-box   Inventory Management System
if (approvedVolunteer)
.ion-android-calendar   Volunteer Management System
if (approvedForm)
.ion-ios-list   Webform
if (approvedCommunity)
.ion-ios-people   Community Management System
if (approvedELearning)
.ion-university   E-learning Platform
if (approvedOther)
.ion-settings   Other tools
h3 Project Status: #{currentStatus}
if (moneySaved > 0)
h3.text-primary Estimated Cost Savings for Nonprofit: $#{moneySaved.toString().replace(/000$/, ',000')}
if (interestedCampers && interestedCampers.length > 0)
h3 Interested campers:
.col-xs-12.text-left
for interestedCamper in interestedCampers
a(href='/' + interestedCamper.username class="interested-camper-image")
img.profile-picture.float-right(src=interestedCamper.picture)
if (assignedCampers && assignedCampers.length > 0)
h3 Assigned campers:
.col-xs-12.text-left
for assignedCamper in assignedCampers
a(href='/' + assignedCamper.username class="interested-camper-image")
img.profile-picture.float-right(src=assignedCamper.picture)
if (!buttonActive)
.col-xs-12.col-sm-8.col-sm-offset-2
.text-center
if !user
a.btn.btn-cta.signup-btn.btn-block(href="/login") Start learning to code (it's free)
.button-spacer
else
a.btn.btn-primary.btn-big.btn-block.disabled(href='/nonprofits/interested-in-nonprofit/#{dashedName}') I'm interested in building this project *
p * Complete all our Bonfires, Ziplines, and Basejumps to unlock this.
a.btn.btn-info.btn-big.btn-block(href='/nonprofits/directory') Show all Nonprofit Projects
.spacer
if (buttonActive)
.col-xs-12.col-sm-8.col-sm-offset-2
.text-center
a.btn.btn-primary.btn-big.btn-block(href='/nonprofits/interested-in-nonprofit/#{dashedName}') I'm interested in building this project
.button-spacer
a.btn.btn-info.btn-big.btn-block(href='/nonprofits/directory') Show all Nonprofit Projects
.spacer

View File

@@ -71,5 +71,3 @@ block content
.row
.col-xs-12.col-sm-8.col-sm-offset-2
a.btn.btn-cta.signup-btn.btn-block(href="/nonprofits-form") My nonprofit needs coding help
.button-spacer
a.btn.btn-lg.btn-primary.btn-primary-ghost.btn-block(href="/nonprofits/directory") Browse our directory of nonprofits we've helped

View File

@@ -37,12 +37,6 @@ urlset(xmlns="http://www.sitemaps.org/schemas/sitemap/0.9")
lastmod= now
priority= 0.9
url
loc http://www.freecodecamp.com/twitch
changefreq weekly
lastmod= now
priority= 0.9
url
loc http://www.freecodecamp.com/jobs
changefreq weekly
@@ -76,10 +70,3 @@ urlset(xmlns="http://www.sitemaps.org/schemas/sitemap/0.9")
lastmod= now
changefreq weekly
priority= 0.5
each nonprofit in nonprofits
url
loc #{appUrl}/nonprofits/#{nonprofit.replace(/\s/g, '-')}
lastmod= now
changefreq weekly
priority= 0.9