From 3f96490aff5352a00317801d189cbfba3e1bb77c Mon Sep 17 00:00:00 2001 From: Berkeley Martinez Date: Mon, 5 Oct 2015 22:21:46 -0700 Subject: [PATCH 01/15] Add pledge model --- common/models/pledge.json | 54 +++++++++++++++++++++++++++++++++++++++ server/model-config.json | 4 +++ 2 files changed, 58 insertions(+) create mode 100644 common/models/pledge.json diff --git a/common/models/pledge.json b/common/models/pledge.json new file mode 100644 index 0000000000..b563d4629e --- /dev/null +++ b/common/models/pledge.json @@ -0,0 +1,54 @@ +{ + "name": "pledge", + "base": "PersistedModel", + "idInjection": true, + "trackChanges": false, + "properties": { + "nonprofit": { + "type": "string" + }, + "amount": { + "type": "number" + }, + "dateStarted": { + "type": "date", + "defaultFn": "now" + }, + "dateEnded": { + "type": "date" + } + }, + "validations": [], + "relations": { + "camper": { + "type": "hasMany", + "model": "user" + } + }, + "acls": [ + { + "accessType": "*", + "principalType": "ROLE", + "principalId": "$everyone", + "permission": "DENY" + }, + { + "accessType": "READ", + "principalType": "ROLE", + "principalId": "$everyone", + "permission": "ALLOW" + } + ], + "methods": [], + "indexes": { + "nonprofit_amount":{ + "keys": { + "nonprofit": 1, + "amount": 1 + }, + "options": { + "unique": true + } + } + } +} diff --git a/server/model-config.json b/server/model-config.json index 508ff05abc..c993d603df 100644 --- a/server/model-config.json +++ b/server/model-config.json @@ -47,6 +47,10 @@ "dataSource": "db", "public": true }, + "pledge": { + "dataSource": "db", + "public": true + }, "user": { "dataSource": "db", "public": true From d1c0276f4e76aaa6f1949e44319a3c4504618e4e Mon Sep 17 00:00:00 2001 From: Berkeley Martinez Date: Mon, 5 Oct 2015 23:08:31 -0700 Subject: [PATCH 02/15] fix spiffy up the commit form --- server/views/commit/index.jade | 88 ++++++++++++++++------------------ 1 file changed, 41 insertions(+), 47 deletions(-) diff --git a/server/views/commit/index.jade b/server/views/commit/index.jade index ba15d37fc1..9b9cb73834 100644 --- a/server/views/commit/index.jade +++ b/server/views/commit/index.jade @@ -3,52 +3,46 @@ block content .panel.panel-info .panel-body h3.text-center Commit to yourself. Commit to a nonprofit. - .col-xs-12.col-sm-6.col-sm-offset-3 - p Are you looking for a burst of motivation? Do you want to help nonprofits before you’re ready to code for them? You can do both by pledging a monthly donation to a nonprofit until you've earned either your Front End or Full Stack Development certificate. Join Commit below or click "maybe later". - .col-xs-12.col-sm-6.col-sm-offset-3 - h4 Step 1: Choose your goal - .radio - label - input(type='radio' id='front-end-development-certificate' name='goal') - | Front End Development Certificate (takes about 400 hours) - .radio - label - input(type='radio' id='full-stack-development-certificate' name='goal') - | Full Stack Development Certificate (takes about 800 hours) + .row + .col-xs-12.col-sm-6.col-sm-offset-3 + p Are you looking for a burst of motivation? Do you want to help nonprofits before you’re ready to code for them? You can do both by pledging a monthly donation to a nonprofit until you've earned either your Front End or Full Stack Development certificate. Join Commit below or click "maybe later". + .row + .col-xs-12.col-sm-6.col-sm-offset-3.text-center + h4 Our Featured Nonprofit + a(href="http://i.imgur.com/U1CyEuA.jpg" data-lightbox="img-enlarge") + img.img-responsive(src='http://i.imgur.com/U1CyEuA.jpg' alt="Girl Develop It participants coding at tables.") + p Girl Develop It is a nonprofit that provides in-person classes for women to learn to code. .spacer - h4 Step 2: Choose one of our nonprofits + form.form .row - .col-xs-12.col-sm-6 - a(href="http://i.imgur.com/U1CyEuA.jpg" data-lightbox="img-enlarge") - img.img-responsive(src='http://i.imgur.com/U1CyEuA.jpg' alt="Girl Develop It participants coding at tables.") - .radio - label - input(type='radio' id='girl-develop-it' name='nonprofit') - | Girl Develop It is a nonprofit that provides in-person classes for women to learn to code. - .col-xs-12.col-sm-6 - a(href="http://i.imgur.com/NERytFF.jpg" data-lightbox="img-enlarge") - img.img-responsive(src='http://i.imgur.com/NERytFF.jpg' alt="Vets in Tech participants standing together at a conference.") - .radio - label - input(type='radio' id='vets-in-tech' name='nonprofit') - | Vets in Tech is a nonprofit that helps veterans prepare for tech jobs. - .spacer - h4 Step 3: Choose your monthly pledge - .radio - label - input(type='radio' id='5-dollar-pledge' name='pledge-amount') - | $5 per month - .radio - label - input(type='radio' id='10-dollar-pledge' name='pledge-amount') - | $10 per month - .radio - label - input(type='radio' id='50-dollar-pledge' name='pledge-amount') - | $50 per month - - .spacer - a.button.btn.btn-block.btn-primary(href='https://www.paypal.com/us/cgi-bin/webscr?cmd=_flow&SESSION=T3x0DY-bLMFXuhmjYZXs-BhmDoiXfuNh5BWad5VBcMomkkDSZY0b_-_W3HS&dispatch=5885d80a13c0db1f8e263663d3faee8d0b9dcb01a9b6dc564e45f62871326a5e') Commit - .button-spacer - a.button.btn.btn-block.btn-warning(href='/') Maybe later - .spacer + .col-xs-12.col-sm-6.col-sm-offset-3 + h4 Step 1: Choose your goal + .btn-group.btn-group-justified(data-toggle='buttons' role='group') + label.btn.btn-info.active + input(type='radio' id='front-end-development-certificate' name='goal') + | Front End Development Certificate (takes about 400 hours) + label.btn.btn-info + input(type='radio' id='full-stack-development-certificate' name='goal') + | Full Stack Development Certificate (takes about 800 hours) + .spacer + .row + .col-xs-12.col-sm-6.col-sm-offset-3 + h4 Step 2: Choose how much you want to donate each month + .btn-group.btn-group-justified(data-toggle='buttons' role='group') + label.btn.btn-primary + input(type='radio' id='5-dollar-pledge' name='pledge-amount') + | $5 per month + label.btn.btn-primary.active + input(type='radio' id='10-dollar-pledge' name='pledge-amount') + | $10 per month + label.btn.btn-primary + input(type='radio' id='50-dollar-pledge' name='pledge-amount') + | $50 per month + .spacer + .row + .col-xs-12.col-sm-6.col-sm-offset-3 + h4 Step 3: Commit + a.btn.btn-block.btn-primary(href='https://www.girldevelopit.com/donate') Commit + .button-spacer + a.btn.btn-block.btn-warning(href='/') Maybe later + .spacer From bc6a9c6db24deade66515b452773a4f6cce5bf41 Mon Sep 17 00:00:00 2001 From: Berkeley Martinez Date: Tue, 6 Oct 2015 00:13:51 -0700 Subject: [PATCH 03/15] Add redirect to user page on submit --- client/main.js | 15 +++++++++++---- server/boot/commit.js | 31 +++++++++++++++++++++++++++++++ server/utils/middleware.js | 8 +++++++- server/views/commit/index.jade | 22 +++++++++++++++------- server/views/commit/pledge.jade | 15 +++++++++++++++ 5 files changed, 79 insertions(+), 12 deletions(-) create mode 100644 server/views/commit/pledge.jade diff --git a/client/main.js b/client/main.js index c1578c1d6f..af32484411 100644 --- a/client/main.js +++ b/client/main.js @@ -1,12 +1,19 @@ -var mapShareKey = 'map-shares'; +var main = window.main || {}; + +main.mapShareKey = 'map-shares'; + var lastCompleted = typeof lastCompleted !== 'undefined' ? lastCompleted : ''; function getMapShares() { - var alreadyShared = JSON.parse(localStorage.getItem(mapShareKey) || '[]'); + var alreadyShared = JSON.parse( + localStorage.getItem(main.mapShareKey) || + '[]' + ); + if (!alreadyShared || !Array.isArray(alreadyShared)) { - localStorage.setItem(mapShareKey, JSON.stringify([])); + localStorage.setItem(main.mapShareKey, JSON.stringify([])); alreadyShared = []; } return alreadyShared; @@ -23,7 +30,7 @@ function setMapShare(id) { if (!found) { alreadyShared.push(id); } - localStorage.setItem(mapShareKey, JSON.stringify(alreadyShared)); + localStorage.setItem(main.mapShareKey, JSON.stringify(alreadyShared)); return alreadyShared; } diff --git a/server/boot/commit.js b/server/boot/commit.js index a54dc19506..40203fca32 100644 --- a/server/boot/commit.js +++ b/server/boot/commit.js @@ -1,9 +1,21 @@ +import dedent from 'dedent'; +import { + ifNoUserRedirectTo +} from '../utils/middleware'; + +const sendNonUserToFront = ifNoUserRedirectTo('/'); + export default function commit(app) { const router = app.loopback.Router(); router.get( '/commit', commitToNonprofit ); + router.get( + '/commit/pledge', + sendNonUserToFront, + pledge + ); app.use(router); @@ -12,4 +24,23 @@ export default function commit(app) { title: 'Commit to a nonprofit. Commit to your goal.' }); } + + function pledge(req, res) { + const { user } = req; + const { + nonprofit = 'girl develop it', + amount = '5', + goal = 'front end certification' + } = req.query; + + req.flash('success', { + msg: dedent` + Congratulations, you have commit to giving ${nonprofit} ${amount} + dollars a month until you have reached your goal + of completing your ${goal} + ` + }); + + res.redirect('/' + user.username); + } } diff --git a/server/utils/middleware.js b/server/utils/middleware.js index 3c541cbb11..f9d4919c9b 100644 --- a/server/utils/middleware.js +++ b/server/utils/middleware.js @@ -1,8 +1,14 @@ -export function ifNoUserRedirectTo(url) { +export function ifNoUserRedirectTo(url, message) { return function(req, res, next) { + const { path } = req; if (req.user) { return next(); } + + req.flash('errors', { + msg: message || `You must be signed to go to ${path}` + }); + return res.redirect(url); }; } diff --git a/server/views/commit/index.jade b/server/views/commit/index.jade index 9b9cb73834..7fd469ca1a 100644 --- a/server/views/commit/index.jade +++ b/server/views/commit/index.jade @@ -13,16 +13,18 @@ block content img.img-responsive(src='http://i.imgur.com/U1CyEuA.jpg' alt="Girl Develop It participants coding at tables.") p Girl Develop It is a nonprofit that provides in-person classes for women to learn to code. .spacer - form.form + form.form(name='commit') + .hidden + input(type='text' value='girl develop it' name='nonprofit') .row .col-xs-12.col-sm-6.col-sm-offset-3 h4 Step 1: Choose your goal .btn-group.btn-group-justified(data-toggle='buttons' role='group') label.btn.btn-info.active - input(type='radio' id='front-end-development-certificate' name='goal') + input(type='radio' id='front-end-development-certificate' value='front end certification' name='goal' checked="checked") | Front End Development Certificate (takes about 400 hours) label.btn.btn-info - input(type='radio' id='full-stack-development-certificate' name='goal') + input(type='radio' id='full-stack-development-certificate' value='full stack certification' name='goal') | Full Stack Development Certificate (takes about 800 hours) .spacer .row @@ -30,19 +32,25 @@ block content h4 Step 2: Choose how much you want to donate each month .btn-group.btn-group-justified(data-toggle='buttons' role='group') label.btn.btn-primary - input(type='radio' id='5-dollar-pledge' name='pledge-amount') + input(type='radio' id='5-dollar-pledge' value='5' name='amount') | $5 per month label.btn.btn-primary.active - input(type='radio' id='10-dollar-pledge' name='pledge-amount') + input(type='radio' id='10-dollar-pledge' value='10' name='amount' checked="checked") | $10 per month label.btn.btn-primary - input(type='radio' id='50-dollar-pledge' name='pledge-amount') + input(type='radio' id='50-dollar-pledge' value='50' name='amount') | $50 per month .spacer .row .col-xs-12.col-sm-6.col-sm-offset-3 h4 Step 3: Commit - a.btn.btn-block.btn-primary(href='https://www.girldevelopit.com/donate') Commit + a#commit-btn-submit.btn.btn-block.btn-primary(href='https://www.girldevelopit.com/donate' target='_blank') Commit .button-spacer a.btn.btn-block.btn-warning(href='/') Maybe later .spacer + script. + $(function() { + $('#commit-btn-submit').click(function() { + window.location.href = '/commit/pledge?' + $('form').serialize(); + }); + }); diff --git a/server/views/commit/pledge.jade b/server/views/commit/pledge.jade new file mode 100644 index 0000000000..84ce52ad49 --- /dev/null +++ b/server/views/commit/pledge.jade @@ -0,0 +1,15 @@ +extends ../layout +block content + .panel.panel-info + .panel-body + h3.text-center You've commited! + .row + .col-xs-12.col-sm-6.col-sm-offset-3 + p Congratulations, you have commit to giving + span(style='text-transform: capitalize') #{nonprofit} + | #{amount} dollars a month until you have reached your goal + | of completing your #{goal} + .row + .col-xs-12.col-sm-6.col-sm-offset-3 + img.img-responsive(src='http://i.imgur.com/U1CyEuA.jpg' alt="Girl Develop It participants coding at tables.") + p Girl Develop It is a nonprofit that provides in-person classes for women to learn to code. From c8da944caf7ec60ad2926845043109ecf91aa6f1 Mon Sep 17 00:00:00 2001 From: Berkeley Martinez Date: Tue, 6 Oct 2015 12:27:53 -0700 Subject: [PATCH 04/15] Add logic to load nonprofit on query Add logic to model update --- common/models/pledge.json | 31 ++++++------ common/models/user.json | 5 ++ server/boot/commit.js | 88 +++++++++++++++++++++++++++++----- server/utils/commit.json | 10 ++++ server/views/commit/index.jade | 45 ++++++++--------- 5 files changed, 129 insertions(+), 50 deletions(-) create mode 100644 server/utils/commit.json diff --git a/common/models/pledge.json b/common/models/pledge.json index b563d4629e..08e46df414 100644 --- a/common/models/pledge.json +++ b/common/models/pledge.json @@ -5,7 +5,8 @@ "trackChanges": false, "properties": { "nonprofit": { - "type": "string" + "type": "string", + "index": true }, "amount": { "type": "number" @@ -16,13 +17,24 @@ }, "dateEnded": { "type": "date" + }, + "formerUserId": { + "type": "string" + }, + "isOrphaned": { + "type": "boolean" + }, + "isCompleted": { + "type": "boolean", + "default": "false" } }, "validations": [], "relations": { - "camper": { + "user": { "type": "hasMany", - "model": "user" + "model": "user", + "foreignKey": "userId" } }, "acls": [ @@ -39,16 +51,5 @@ "permission": "ALLOW" } ], - "methods": [], - "indexes": { - "nonprofit_amount":{ - "keys": { - "nonprofit": 1, - "amount": 1 - }, - "options": { - "unique": true - } - } - } + "methods": [] } diff --git a/common/models/user.json b/common/models/user.json index 776c2c500e..f85cc1023c 100644 --- a/common/models/user.json +++ b/common/models/user.json @@ -166,6 +166,11 @@ "type": "hasMany", "model": "userIdentity", "foreignKey": "" + }, + "pledge": { + "type": "hasOne", + "model": "pledge", + "foreignKey": "" } }, "acls": [ diff --git a/server/boot/commit.js b/server/boot/commit.js index 40203fca32..be08d85348 100644 --- a/server/boot/commit.js +++ b/server/boot/commit.js @@ -1,16 +1,33 @@ +import _ from 'lodash'; +import debugFactory from 'debug'; import dedent from 'dedent'; +import nonprofits from '../utils/commit.json'; + +import { + unDasherize +} from '../utils'; + +import { + observeQuery, + saveInstance +} from '../utils/rx'; + import { ifNoUserRedirectTo } from '../utils/middleware'; const sendNonUserToFront = ifNoUserRedirectTo('/'); +const debug = debugFactory('freecc:commit'); export default function commit(app) { const router = app.loopback.Router(); + const { Pledge } = app.models; + router.get( '/commit', commitToNonprofit ); + router.get( '/commit/pledge', sendNonUserToFront, @@ -20,27 +37,72 @@ export default function commit(app) { app.use(router); function commitToNonprofit(req, res) { - res.render('commit/', { - title: 'Commit to a nonprofit. Commit to your goal.' - }); + let nonprofitName = unDasherize(req.query.nonprofit); + let nonprofit; + + debug('looking for nonprofit', nonprofitName); + if (nonprofitName) { + nonprofit = _.find(nonprofits, (nonprofit) => { + return nonprofitName === nonprofit.name; + }); + } + + nonprofit = nonprofit || nonprofits[0]; + + res.render( + 'commit/', + Object.assign( + { title: 'Commit to a nonprofit. Commit to your goal.' }, + nonprofit + ) + ); } - function pledge(req, res) { + function pledge(req, res, next) { const { user } = req; const { nonprofit = 'girl develop it', amount = '5', - goal = 'front end certification' + goal = 'Front End Development Certification' } = req.query; - req.flash('success', { - msg: dedent` - Congratulations, you have commit to giving ${nonprofit} ${amount} - dollars a month until you have reached your goal - of completing your ${goal} - ` - }); + observeQuery(user, 'pledge') + .flatMap(oldPledge => { + // create new pledge for user + const pledge = Pledge({ + nonprofit, + amount, + goal, + userId: user.id + }); + + if (oldPledge) { + debug('user already has pledge, creating a new one'); + // we orphan last pledge since a user only has one pledge at a time + oldPledge.userId = ''; + oldPledge.formerUser = user.id; + oldPledge.endDate = new Date(); + oldPledge.isOrphaned = true; + return saveInstance(oldPledge) + .flatMap(() => { + return saveInstance(pledge); + }); + } + return saveInstance(pledge); + }) + .subscribe( + ({ nonprofit, goal, amount }) => { + req.flash('success', { + msg: dedent` + Congratulations, you have committed to giving + ${nonprofit} $${amount} each month until you have completed + your ${goal}. + ` + }); + res.redirect('/' + user.username); + }, + next + ); - res.redirect('/' + user.username); } } diff --git a/server/utils/commit.json b/server/utils/commit.json new file mode 100644 index 0000000000..41d16d36c8 --- /dev/null +++ b/server/utils/commit.json @@ -0,0 +1,10 @@ +[ + { + "name": "girl develop it", + "displayName": "Girl Develop It", + "donateUrl": "https://www.girldevelopit.com/donate", + "description": "Girl Develop It provides in-person classes for women to learn to code.", + "imgAlt": "Girl Develop It participants coding at tables.", + "imgUrl": "http://i.imgur.com/U1CyEuA.jpg" + } +] diff --git a/server/views/commit/index.jade b/server/views/commit/index.jade index 7fd469ca1a..1402545af7 100644 --- a/server/views/commit/index.jade +++ b/server/views/commit/index.jade @@ -5,48 +5,49 @@ block content h3.text-center Commit to yourself. Commit to a nonprofit. .row .col-xs-12.col-sm-6.col-sm-offset-3 - p Are you looking for a burst of motivation? Do you want to help nonprofits before you’re ready to code for them? You can do both by pledging a monthly donation to a nonprofit until you've earned either your Front End or Full Stack Development certificate. Join Commit below or click "maybe later". + p Give yourself ongoing motivation and help nonprofits right away. Pledge a monthly donation to a nonprofit until you’ve earned either your Front End or Full Stack Development Certification. .row .col-xs-12.col-sm-6.col-sm-offset-3.text-center - h4 Our Featured Nonprofit - a(href="http://i.imgur.com/U1CyEuA.jpg" data-lightbox="img-enlarge") - img.img-responsive(src='http://i.imgur.com/U1CyEuA.jpg' alt="Girl Develop It participants coding at tables.") - p Girl Develop It is a nonprofit that provides in-person classes for women to learn to code. - .spacer + h4 Pledge to #{displayName} + .spacer + a(href='#{imgUrl}' data-lightbox='img-enlarge' alt='#{imgAlt}') + img.img-responsive(src='#{imgUrl}' alt='#{imgAlt}') + p= description + a or browse our directory + .spacer form.form(name='commit') .hidden - input(type='text' value='girl develop it' name='nonprofit') + input(type='text' value='#{name}' name='nonprofit') .row .col-xs-12.col-sm-6.col-sm-offset-3 - h4 Step 1: Choose your goal + h4 Choose your goal: .btn-group.btn-group-justified(data-toggle='buttons' role='group') - label.btn.btn-info.active - input(type='radio' id='front-end-development-certificate' value='front end certification' name='goal' checked="checked") + label.btn.btn-primary.btn-lg.active + input(type='radio' id='front-end-development-certificate' value='Front End Development Certification' name='goal' checked="checked") | Front End Development Certificate (takes about 400 hours) - label.btn.btn-info - input(type='radio' id='full-stack-development-certificate' value='full stack certification' name='goal') + label.btn.btn-primary.btn-lg + input(type='radio' id='full-stack-development-certificate' value='Full Stack Development Certification' name='goal') | Full Stack Development Certificate (takes about 800 hours) - .spacer + .spacer .row .col-xs-12.col-sm-6.col-sm-offset-3 - h4 Step 2: Choose how much you want to donate each month + h4 Choose how much you want to pledge each month: .btn-group.btn-group-justified(data-toggle='buttons' role='group') - label.btn.btn-primary + label.btn.btn-success input(type='radio' id='5-dollar-pledge' value='5' name='amount') | $5 per month - label.btn.btn-primary.active + label.btn.btn-success.active input(type='radio' id='10-dollar-pledge' value='10' name='amount' checked="checked") | $10 per month - label.btn.btn-primary + label.btn.btn-success input(type='radio' id='50-dollar-pledge' value='50' name='amount') | $50 per month - .spacer + .spacer .row - .col-xs-12.col-sm-6.col-sm-offset-3 - h4 Step 3: Commit - a#commit-btn-submit.btn.btn-block.btn-primary(href='https://www.girldevelopit.com/donate' target='_blank') Commit + .col-xs-12.col-sm-6.col-sm-offset-3.text-center + a#commit-btn-submit.btn.btn-block.btn-lg.signup-btn(href='https://www.girldevelopit.com/donate' target='_blank') Commit (and open donate page) .button-spacer - a.btn.btn-block.btn-warning(href='/') Maybe later + a(href='/') Maybe later .spacer script. $(function() { From 362efd4365cff76c1ab228af49b4505259176b4f Mon Sep 17 00:00:00 2001 From: Berkeley Martinez Date: Tue, 6 Oct 2015 14:54:59 -0700 Subject: [PATCH 05/15] Add display on user profile when user commits --- server/boot/commit.js | 41 +++++++++++++++++++++------------- server/boot/user.js | 9 ++++++-- server/views/account/show.jade | 6 +++++ 3 files changed, 39 insertions(+), 17 deletions(-) diff --git a/server/boot/commit.js b/server/boot/commit.js index be08d85348..c04169f732 100644 --- a/server/boot/commit.js +++ b/server/boot/commit.js @@ -19,6 +19,18 @@ import { const sendNonUserToFront = ifNoUserRedirectTo('/'); const debug = debugFactory('freecc:commit'); +function findNonprofit(name) { + let nonprofit; + if (name) { + nonprofit = _.find(nonprofits, (nonprofit) => { + return name === nonprofit.name; + }); + } + + nonprofit = nonprofit || nonprofits[0]; + return nonprofit; +} + export default function commit(app) { const router = app.loopback.Router(); const { Pledge } = app.models; @@ -38,16 +50,9 @@ export default function commit(app) { function commitToNonprofit(req, res) { let nonprofitName = unDasherize(req.query.nonprofit); - let nonprofit; + const nonprofit = findNonprofit(nonprofitName); debug('looking for nonprofit', nonprofitName); - if (nonprofitName) { - nonprofit = _.find(nonprofits, (nonprofit) => { - return nonprofitName === nonprofit.name; - }); - } - - nonprofit = nonprofit || nonprofits[0]; res.render( 'commit/', @@ -61,20 +66,26 @@ export default function commit(app) { function pledge(req, res, next) { const { user } = req; const { - nonprofit = 'girl develop it', + nonprofit: nonprofitName = 'girl develop it', amount = '5', goal = 'Front End Development Certification' } = req.query; + const nonprofit = findNonprofit(nonprofitName); + observeQuery(user, 'pledge') .flatMap(oldPledge => { // create new pledge for user - const pledge = Pledge({ - nonprofit, - amount, - goal, - userId: user.id - }); + const pledge = Pledge( + Object.assign( + { + amount, + goal, + userId: user.id + }, + nonprofit + ) + ); if (oldPledge) { debug('user already has pledge, creating a new one'); diff --git a/server/boot/user.js b/server/boot/user.js index ae6453f5d8..f266fa6f12 100644 --- a/server/boot/user.js +++ b/server/boot/user.js @@ -164,7 +164,10 @@ module.exports = function(app) { const username = req.params.username.toLowerCase(); const { path } = req; User.findOne( - { where: { username } }, + { + where: { username }, + include: 'pledge' + }, function(err, profileUser) { if (err) { return next(err); @@ -175,6 +178,7 @@ module.exports = function(app) { }); return res.redirect('/'); } + profileUser = profileUser.toJSON(); var cals = profileUser .progressTimestamps @@ -217,7 +221,6 @@ module.exports = function(app) { return (obj.name || '').match(/^Waypoint/i); }); - debug('user is fec', profileUser.isFrontEndCert); res.render('account/show', { title: 'Camper ' + profileUser.username + '\'s portfolio', username: profileUser.username, @@ -227,6 +230,8 @@ module.exports = function(app) { isGithubCool: profileUser.isGithubCool, isLocked: !!profileUser.isLocked, + pledge: profileUser.pledge, + isFrontEndCert: profileUser.isFrontEndCert, isFullStackCert: profileUser.isFullStackCert, isHonest: profileUser.isHonest, diff --git a/server/views/account/show.jade b/server/views/account/show.jade index e48c80eff9..ae7c9a3e0e 100644 --- a/server/views/account/show.jade +++ b/server/views/account/show.jade @@ -58,6 +58,12 @@ block content h1.flat-top.wrappable= name h1.flat-top.wrappable= location h1.flat-top.text-primary= "[ " + (progressTimestamps.length) + " ]" + if pledge + .spacer + h4 I am commited to giving $#{pledge.amount} to + a(href='#{pledge.donate}') #{pledge.displayName} + | each month until I have complete the #{pledge.goal} + .spacer if isFrontEndCert a.btn.btn-primary(href='/' + username + '/front-end-certification') View My Front End Development Certification if isFullStackCert From d132978df95043f6bd9d8bda9182120188610327 Mon Sep 17 00:00:00 2001 From: Berkeley Martinez Date: Tue, 6 Oct 2015 17:52:57 -0700 Subject: [PATCH 06/15] Add ability to edit commit --- server/boot/commit.js | 47 ++++++++++++++++++++++++++-------- server/utils/commit.json | 8 ++++++ server/views/account/show.jade | 11 +++++--- 3 files changed, 53 insertions(+), 13 deletions(-) diff --git a/server/boot/commit.js b/server/boot/commit.js index c04169f732..7e4b7c21c0 100644 --- a/server/boot/commit.js +++ b/server/boot/commit.js @@ -1,4 +1,5 @@ import _ from 'lodash'; +import { Observable } from 'rx'; import debugFactory from 'debug'; import dedent from 'dedent'; import nonprofits from '../utils/commit.json'; @@ -48,19 +49,46 @@ export default function commit(app) { app.use(router); - function commitToNonprofit(req, res) { + function commitToNonprofit(req, res, next) { + const { user } = req; let nonprofitName = unDasherize(req.query.nonprofit); - const nonprofit = findNonprofit(nonprofitName); debug('looking for nonprofit', nonprofitName); + const nonprofit = findNonprofit(nonprofitName); + + Observable.just(user) + .flatMap(user => { + if (user) { + debug('getting user pledge'); + return observeQuery(user, 'pledge'); + } + return Observable.just(); + }) + .subscribe( + pledge => { + if (pledge) { + debug('found previous pledge'); + req.flash('info', { + msg: dedent` + Looks like you already have a pledge to ${pledge.displayName}. + Hitting commit here will replace your old commitment. + ` + }); + } + res.render( + 'commit/', + Object.assign( + { + title: 'Commit to a nonprofit. Commit to your goal.', + pledge + }, + nonprofit + ) + ); + }, + next + ); - res.render( - 'commit/', - Object.assign( - { title: 'Commit to a nonprofit. Commit to your goal.' }, - nonprofit - ) - ); } function pledge(req, res, next) { @@ -114,6 +142,5 @@ export default function commit(app) { }, next ); - } } diff --git a/server/utils/commit.json b/server/utils/commit.json index 41d16d36c8..c0e09277c4 100644 --- a/server/utils/commit.json +++ b/server/utils/commit.json @@ -6,5 +6,13 @@ "description": "Girl Develop It provides in-person classes for women to learn to code.", "imgAlt": "Girl Develop It participants coding at tables.", "imgUrl": "http://i.imgur.com/U1CyEuA.jpg" + }, + { + "name": "black girls code", + "displayName": "Black Girls CODE", + "donateUrl": "http://www.blackgirlscode.com/", + "description": "Black Girls CODE is devoted to showing the world that black girls can code, and do so much more.", + "imgAlt": "Girls developing code with instructor", + "imgUrl": "http://i.imgur.com/HBVrdaj.jpg" } ] diff --git a/server/views/account/show.jade b/server/views/account/show.jade index ae7c9a3e0e..267d281b20 100644 --- a/server/views/account/show.jade +++ b/server/views/account/show.jade @@ -60,9 +60,10 @@ block content h1.flat-top.text-primary= "[ " + (progressTimestamps.length) + " ]" if pledge .spacer - h4 I am commited to giving $#{pledge.amount} to - a(href='#{pledge.donate}') #{pledge.displayName} - | each month until I have complete the #{pledge.goal} + h4 + | This camper has committed to giving $#{pledge.amount} to + a(href='#{pledge.donateUrl}?ref=freecodecamp.com' target='_blank') #{pledge.displayName} + | each month until they have completed the #{pledge.goal} .spacer if isFrontEndCert a.btn.btn-primary(href='/' + username + '/front-end-certification') View My Front End Development Certification @@ -174,6 +175,10 @@ block content a.btn.btn-lg.btn-block.btn-info.btn-link-social(href='/toggle-lockdown-mode') span.ion-unlocked | Let other people see all my solutions + .col-xs-12 + a.btn.btn-lg.btn-block.btn-success.btn-link-social(href='/commit') + span.ion-android-exit + | Edit my pledge .col-xs-12 a.btn.btn-lg.btn-block.btn-warning.btn-link-social(href='/logout') span.ion-android-exit From 0b716c0057ef8566e9f0f85ad9df55918ee38f3a Mon Sep 17 00:00:00 2001 From: Berkeley Martinez Date: Tue, 6 Oct 2015 18:22:12 -0700 Subject: [PATCH 07/15] Add stop commit functionality --- server/boot/commit.js | 38 ++++++++++++++++++++++++++++++++++ server/views/commit/index.jade | 13 ++++++++++-- 2 files changed, 49 insertions(+), 2 deletions(-) diff --git a/server/boot/commit.js b/server/boot/commit.js index 7e4b7c21c0..ef2ce5d6ba 100644 --- a/server/boot/commit.js +++ b/server/boot/commit.js @@ -18,6 +18,10 @@ import { } from '../utils/middleware'; const sendNonUserToFront = ifNoUserRedirectTo('/'); +const sendNonUserToCommit = ifNoUserRedirectTo( + '/commit', + 'Must be signed in to update commit' +); const debug = debugFactory('freecc:commit'); function findNonprofit(name) { @@ -47,6 +51,12 @@ export default function commit(app) { pledge ); + router.post( + '/commit/stop-commitment', + sendNonUserToCommit, + stopCommit + ); + app.use(router); function commitToNonprofit(req, res, next) { @@ -143,4 +153,32 @@ export default function commit(app) { next ); } + + function stopCommit(req, res, next) { + const { user } = req; + + observeQuery(user, 'pledge') + .flatMap(pledge => { + if (!pledge) { + return Observable.just(); + } + + pledge.formerUserId = pledge.userId; + pledge.userId = null; + pledge.isOrphaned = true; + pledge.dateEnded = new Date(); + return saveInstance(pledge); + }) + .subscribe( + pledge => { + let msg = `You have successfully stopped your pledge.`; + if (!pledge) { + msg = `No pledge found for user ${user.username}.`; + } + req.flash('errors', { msg }); + return res.redirect('/commit'); + }, + next + ); + } } diff --git a/server/views/commit/index.jade b/server/views/commit/index.jade index 1402545af7..014275a608 100644 --- a/server/views/commit/index.jade +++ b/server/views/commit/index.jade @@ -5,7 +5,7 @@ block content h3.text-center Commit to yourself. Commit to a nonprofit. .row .col-xs-12.col-sm-6.col-sm-offset-3 - p Give yourself ongoing motivation and help nonprofits right away. Pledge a monthly donation to a nonprofit until you’ve earned either your Front End or Full Stack Development Certification. + p Give yourself external motivation and help nonprofits right away. Pledge a monthly donation to a nonprofit until you’ve earned either your Front End or Full Stack Development Certification. .row .col-xs-12.col-sm-6.col-sm-offset-3.text-center h4 Pledge to #{displayName} @@ -47,8 +47,17 @@ block content .col-xs-12.col-sm-6.col-sm-offset-3.text-center a#commit-btn-submit.btn.btn-block.btn-lg.signup-btn(href='https://www.girldevelopit.com/donate' target='_blank') Commit (and open donate page) .button-spacer + .spacer + if pledge + form.row(name='stop-pledge' action='/commit/stop-commitment' method='post') + .col-xs-12.col-sm-6.col-sm-offset-3.text-center + button.btn.btn-sm.btn-danger(name='submit' type='submit') Stop my pledge + .spacer + else + .row + .col-xs-12.col-sm-6.col-sm-offset-3.text-center a(href='/') Maybe later - .spacer + .spacer script. $(function() { $('#commit-btn-submit').click(function() { From 49c06b266ef6fffb073b703989947a6b4fc7db12 Mon Sep 17 00:00:00 2001 From: Berkeley Martinez Date: Tue, 6 Oct 2015 19:49:38 -0700 Subject: [PATCH 08/15] Add complete commit endpoint --- server/boot/commit.js | 46 +++++++++++++++++++++++++++++++++- server/utils/commit-goals.json | 4 +++ server/views/commit/index.jade | 4 +-- 3 files changed, 51 insertions(+), 3 deletions(-) create mode 100644 server/utils/commit-goals.json diff --git a/server/boot/commit.js b/server/boot/commit.js index ef2ce5d6ba..b15a02468b 100644 --- a/server/boot/commit.js +++ b/server/boot/commit.js @@ -2,7 +2,9 @@ import _ from 'lodash'; import { Observable } from 'rx'; import debugFactory from 'debug'; import dedent from 'dedent'; + import nonprofits from '../utils/commit.json'; +import commitGoals from '../utils/commit-goals.json'; import { unDasherize @@ -57,6 +59,12 @@ export default function commit(app) { stopCommit ); + router.post( + '/commit/complete-goal', + sendNonUserToCommit, + completeCommitment + ); + app.use(router); function commitToNonprofit(req, res, next) { @@ -90,7 +98,9 @@ export default function commit(app) { Object.assign( { title: 'Commit to a nonprofit. Commit to your goal.', - pledge + pledge, + frontEndCert: commitGoals.frontEndCert, + fullStackCert: commitGoals.fullStackCert }, nonprofit ) @@ -154,6 +164,40 @@ export default function commit(app) { ); } + function completeCommitment(req, res, next) { + const { user } = req; + const { isFrontEndCert, isFullStackCert } = user; + + observeQuery(user, 'pledge') + .flatMap(pledge => { + const { goal } = pledge; + if (!pledge) { + return Observable.just('No pledge found'); + } + if ( + isFrontEndCert && goal === commitGoals.frontEndCert || + isFullStackCert && goal === commitGoals.fullStackCert + ) { + pledge.isCompleted = true; + pledge.dateEnded = new Date(); + return saveInstance(pledge); + } + return Observable.just(dedent` + You have not yet reached your goal of completing the ${goal} + Please retry when you have met the requirements. + `); + }) + .subscribe( + msgOrPledge => { + if (typeof msgOrPledge === 'string') { + return res.send(msgOrPledge); + } + return res.send(true); + }, + next + ); + } + function stopCommit(req, res, next) { const { user } = req; diff --git a/server/utils/commit-goals.json b/server/utils/commit-goals.json new file mode 100644 index 0000000000..8391145e6b --- /dev/null +++ b/server/utils/commit-goals.json @@ -0,0 +1,4 @@ +{ + "frontEndCert": "front-end-development-certificate", + "fullStackCert": "full-stack-development-certificate" +} diff --git a/server/views/commit/index.jade b/server/views/commit/index.jade index 014275a608..591c285919 100644 --- a/server/views/commit/index.jade +++ b/server/views/commit/index.jade @@ -23,10 +23,10 @@ block content h4 Choose your goal: .btn-group.btn-group-justified(data-toggle='buttons' role='group') label.btn.btn-primary.btn-lg.active - input(type='radio' id='front-end-development-certificate' value='Front End Development Certification' name='goal' checked="checked") + input(type='radio' id=frontEndCert value='Front End Development Certification' name='goal' checked="checked") | Front End Development Certificate (takes about 400 hours) label.btn.btn-primary.btn-lg - input(type='radio' id='full-stack-development-certificate' value='Full Stack Development Certification' name='goal') + input(type='radio' id=fullStackCert value='Full Stack Development Certification' name='goal') | Full Stack Development Certificate (takes about 800 hours) .spacer .row From 2864f607cc3241e2e347033a926f98f5922333dc Mon Sep 17 00:00:00 2001 From: Berkeley Martinez Date: Tue, 6 Oct 2015 21:08:24 -0700 Subject: [PATCH 09/15] Add on certification, complete goal and stop pledge --- server/boot/certificate.js | 19 +++++++++++++++++- server/boot/commit.js | 28 ++++++-------------------- server/utils/commit.js | 36 ++++++++++++++++++++++++++++++++++ server/views/commit/index.jade | 4 ++-- 4 files changed, 62 insertions(+), 25 deletions(-) create mode 100644 server/utils/commit.js diff --git a/server/boot/certificate.js b/server/boot/certificate.js index b084d9f4b8..400d756bcc 100644 --- a/server/boot/certificate.js +++ b/server/boot/certificate.js @@ -18,6 +18,10 @@ import { fullStackChallangeId } from '../utils/constantStrings.json'; +import { + completeCommitment$ +} from '../utils/commit'; + const debug = debugFactory('freecc:certification'); const sendMessageToNonUser = ifNoUserSend( 'must be logged in to complete.' @@ -114,7 +118,20 @@ export default function certificate(app) { completedDate: new Date(), challengeType }); - return saveUser(user); + return saveUser(user) + // If user has commited to nonprofit, + // this will complete his pledge + .flatMap( + user => completeCommitment$(user), + (user, pledgeOrMessage) => { + if (typeof pledgeOrMessage === 'string') { + debug(pledgeOrMessage); + } + // we are only interested in the user object + // so we ignore return from completeCommitment$ + return user; + } + ); } return Observable.just(user); }) diff --git a/server/boot/commit.js b/server/boot/commit.js index b15a02468b..4b04950c63 100644 --- a/server/boot/commit.js +++ b/server/boot/commit.js @@ -4,7 +4,10 @@ import debugFactory from 'debug'; import dedent from 'dedent'; import nonprofits from '../utils/commit.json'; -import commitGoals from '../utils/commit-goals.json'; +import { + commitGoals, + completeCommitment$ +} from '../utils/commit'; import { unDasherize @@ -116,7 +119,7 @@ export default function commit(app) { const { nonprofit: nonprofitName = 'girl develop it', amount = '5', - goal = 'Front End Development Certification' + goal = commitGoals.frontEndCert } = req.query; const nonprofit = findNonprofit(nonprofitName); @@ -166,27 +169,8 @@ export default function commit(app) { function completeCommitment(req, res, next) { const { user } = req; - const { isFrontEndCert, isFullStackCert } = user; - observeQuery(user, 'pledge') - .flatMap(pledge => { - const { goal } = pledge; - if (!pledge) { - return Observable.just('No pledge found'); - } - if ( - isFrontEndCert && goal === commitGoals.frontEndCert || - isFullStackCert && goal === commitGoals.fullStackCert - ) { - pledge.isCompleted = true; - pledge.dateEnded = new Date(); - return saveInstance(pledge); - } - return Observable.just(dedent` - You have not yet reached your goal of completing the ${goal} - Please retry when you have met the requirements. - `); - }) + return completeCommitment$(user) .subscribe( msgOrPledge => { if (typeof msgOrPledge === 'string') { diff --git a/server/utils/commit.js b/server/utils/commit.js new file mode 100644 index 0000000000..6eb48d139b --- /dev/null +++ b/server/utils/commit.js @@ -0,0 +1,36 @@ +import dedent from 'dedent'; +import debugFactory from 'debug'; +import { Observable } from 'rx'; + +import commitGoals from './commit-goals.json'; +const debug = debugFactory('freecc:utils/commit'); + +export { commitGoals }; + +export function completeCommitment$(user) { + const { isFrontEndCert, isFullStackCert } = user; + return Observable.fromNodeCallback(user.pledge, user)() + .flatMap(pledge => { + if (!pledge) { + return Observable.just('No pledge found'); + } + + const { goal } = pledge; + + if ( + isFrontEndCert && goal === commitGoals.frontEndCert || + isFullStackCert && goal === commitGoals.fullStackCert + ) { + debug('marking goal complete'); + pledge.isCompleted = true; + pledge.dateEnded = new Date(); + pledge.formerUserId = pledge.userId; + pledge.userId = null; + return Observable.fromNodeCallback(pledge.save, pledge)(); + } + return Observable.just(dedent` + You have not yet reached your goal of completing the ${goal} + Please retry when you have met the requirements. + `); + }); +} diff --git a/server/views/commit/index.jade b/server/views/commit/index.jade index 591c285919..52528046f0 100644 --- a/server/views/commit/index.jade +++ b/server/views/commit/index.jade @@ -23,10 +23,10 @@ block content h4 Choose your goal: .btn-group.btn-group-justified(data-toggle='buttons' role='group') label.btn.btn-primary.btn-lg.active - input(type='radio' id=frontEndCert value='Front End Development Certification' name='goal' checked="checked") + input(type='radio' id=frontEndCert value=frontEndCert name='goal' checked="checked") | Front End Development Certificate (takes about 400 hours) label.btn.btn-primary.btn-lg - input(type='radio' id=fullStackCert value='Full Stack Development Certification' name='goal') + input(type='radio' id=fullStackCert value=fullStackCert name='goal') | Full Stack Development Certificate (takes about 800 hours) .spacer .row From 364f79818f1d1a27826c5459b06a1799de034ab8 Mon Sep 17 00:00:00 2001 From: Berkeley Martinez Date: Tue, 6 Oct 2015 23:26:15 -0700 Subject: [PATCH 10/15] Fix dynamic commit link --- server/views/commit/index.jade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/views/commit/index.jade b/server/views/commit/index.jade index 52528046f0..f050211e35 100644 --- a/server/views/commit/index.jade +++ b/server/views/commit/index.jade @@ -45,7 +45,7 @@ block content .spacer .row .col-xs-12.col-sm-6.col-sm-offset-3.text-center - a#commit-btn-submit.btn.btn-block.btn-lg.signup-btn(href='https://www.girldevelopit.com/donate' target='_blank') Commit (and open donate page) + a#commit-btn-submit.btn.btn-block.btn-lg.signup-btn(href=donateUrl target='_blank') Commit (and open donate page) .button-spacer .spacer if pledge From 3273593b9c0e956704bad1bc90d5988c44a7f515 Mon Sep 17 00:00:00 2001 From: Berkeley Martinez Date: Tue, 6 Oct 2015 23:32:31 -0700 Subject: [PATCH 11/15] Change order of edit buttons on profile --- server/views/account/show.jade | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/server/views/account/show.jade b/server/views/account/show.jade index 267d281b20..9b11ef7778 100644 --- a/server/views/account/show.jade +++ b/server/views/account/show.jade @@ -161,6 +161,10 @@ block content .panel.panel-info .panel-heading.text-center Manage Your Account .panel-body + .col-xs-12 + a.btn.btn-lg.btn-block.btn-warning.btn-link-social(href='/logout') + span.ion-android-exit + | Sign me out of Free Code Camp .col-xs-12 a.btn.btn-lg.btn-block.btn-primary.btn-link-social(href='mailto:team@freecodecamp.com') span.ion-email @@ -177,12 +181,8 @@ block content | Let other people see all my solutions .col-xs-12 a.btn.btn-lg.btn-block.btn-success.btn-link-social(href='/commit') - span.ion-android-exit + span.ion-edit | Edit my pledge - .col-xs-12 - a.btn.btn-lg.btn-block.btn-warning.btn-link-social(href='/logout') - span.ion-android-exit - | Sign me out of Free Code Camp .col-xs-12 a.btn.btn-lg.btn-block.btn-danger.btn-link-social.confirm-deletion span.ion-trash-b From f5966c0959bc88c3e8e03e86f99b9915b85f5354 Mon Sep 17 00:00:00 2001 From: Berkeley Martinez Date: Tue, 6 Oct 2015 23:33:17 -0700 Subject: [PATCH 12/15] Change redirect and text on commit --- server/boot/commit.js | 2 +- server/views/commit/index.jade | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/server/boot/commit.js b/server/boot/commit.js index 4b04950c63..b34d9716a0 100644 --- a/server/boot/commit.js +++ b/server/boot/commit.js @@ -204,7 +204,7 @@ export default function commit(app) { msg = `No pledge found for user ${user.username}.`; } req.flash('errors', { msg }); - return res.redirect('/commit'); + return res.redirect(`/${user.username}`); }, next ); diff --git a/server/views/commit/index.jade b/server/views/commit/index.jade index f050211e35..179afd92cd 100644 --- a/server/views/commit/index.jade +++ b/server/views/commit/index.jade @@ -47,15 +47,13 @@ block content .col-xs-12.col-sm-6.col-sm-offset-3.text-center a#commit-btn-submit.btn.btn-block.btn-lg.signup-btn(href=donateUrl target='_blank') Commit (and open donate page) .button-spacer - .spacer if pledge form.row(name='stop-pledge' action='/commit/stop-commitment' method='post') .col-xs-12.col-sm-6.col-sm-offset-3.text-center button.btn.btn-sm.btn-danger(name='submit' type='submit') Stop my pledge - .spacer else .row - .col-xs-12.col-sm-6.col-sm-offset-3.text-center + h4.col-xs-12.col-sm-6.col-sm-offset-3.text-center a(href='/') Maybe later .spacer script. From 92b9f7153251c21808b7e7a7864ecb4a1bba8e45 Mon Sep 17 00:00:00 2001 From: Berkeley Martinez Date: Wed, 7 Oct 2015 00:05:26 -0700 Subject: [PATCH 13/15] Add commit directory page --- server/boot/commit.js | 12 ++++++++++++ server/views/commit/directory.jade | 21 +++++++++++++++++++++ server/views/commit/index.jade | 2 +- 3 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 server/views/commit/directory.jade diff --git a/server/boot/commit.js b/server/boot/commit.js index b34d9716a0..9a48ea5236 100644 --- a/server/boot/commit.js +++ b/server/boot/commit.js @@ -56,6 +56,11 @@ export default function commit(app) { pledge ); + router.get( + '/commit/directory', + renderDirectory + ); + router.post( '/commit/stop-commitment', sendNonUserToCommit, @@ -167,6 +172,13 @@ export default function commit(app) { ); } + function renderDirectory(req, res) { + res.render('commit/directory', { + title: 'Commit Directory', + nonprofits + }); + } + function completeCommitment(req, res, next) { const { user } = req; diff --git a/server/views/commit/directory.jade b/server/views/commit/directory.jade new file mode 100644 index 0000000000..5ae6aadf4d --- /dev/null +++ b/server/views/commit/directory.jade @@ -0,0 +1,21 @@ +extends ../layout +block content + .panel.panel-info + .panel-heading.text-center Commit to one of these nonprofits + .panel-body + .row + .col-xs-12.col-sm-6.col-sm-offset-3 + for nonprofit in nonprofits + .spacer + .row + .text-center + h2= nonprofit.displayName + .row + .col-xs-12.col-sm-8.col-sm-offset-2 + img.img-responsive.img-center(src=nonprofit.imgUrl) + p= nonprofit.description + .row + .col-xs-12.col-sm-8.col-sm-offset-2 + a.text-center.btn.btn-primary.btn-lg.btn-block(href='/commit?nonprofit=#{nonprofit.name}') Go to #{nonprofit.displayName} + .spacer + diff --git a/server/views/commit/index.jade b/server/views/commit/index.jade index 179afd92cd..8d7a065f33 100644 --- a/server/views/commit/index.jade +++ b/server/views/commit/index.jade @@ -13,7 +13,7 @@ block content a(href='#{imgUrl}' data-lightbox='img-enlarge' alt='#{imgAlt}') img.img-responsive(src='#{imgUrl}' alt='#{imgAlt}') p= description - a or browse our directory + a(href='/commit/directory') or browse our directory .spacer form.form(name='commit') .hidden From f7500c4bb0d5b998d69e4f25eb0647db25e79b11 Mon Sep 17 00:00:00 2001 From: Quincy Larson Date: Wed, 7 Oct 2015 00:44:46 -0700 Subject: [PATCH 14/15] improve style --- server/views/commit/directory.jade | 21 ++++++++++----------- server/views/commit/index.jade | 25 +++++++++++++++---------- 2 files changed, 25 insertions(+), 21 deletions(-) diff --git a/server/views/commit/directory.jade b/server/views/commit/directory.jade index 5ae6aadf4d..2ba3836f30 100644 --- a/server/views/commit/directory.jade +++ b/server/views/commit/directory.jade @@ -4,18 +4,17 @@ block content .panel-heading.text-center Commit to one of these nonprofits .panel-body .row - .col-xs-12.col-sm-6.col-sm-offset-3 + .col-xs-12.col-sm-10.col-sm-offset-1 for nonprofit in nonprofits - .spacer - .row + .col-xs-12.col-sm-6.col-md-4.story-section .text-center h2= nonprofit.displayName - .row - .col-xs-12.col-sm-8.col-sm-offset-2 - img.img-responsive.img-center(src=nonprofit.imgUrl) + img.testimonial-image.img-responsive.img-center(src=nonprofit.imgUrl) + .button-spacer + a.text-center(href='/commit?nonprofit=#{nonprofit.name}') Commmit to #{nonprofit.displayName} p= nonprofit.description - .row - .col-xs-12.col-sm-8.col-sm-offset-2 - a.text-center.btn.btn-primary.btn-lg.btn-block(href='/commit?nonprofit=#{nonprofit.name}') Go to #{nonprofit.displayName} - .spacer - + .spacer + .col-xs-12 + a.btn.btn-lg.btn-block.btn-primary.btn-link-social(href='mailto:team@freecodecamp.com?subject=Supporting%20Nonprofits') + span.ion-email + | Email us about adding your nonprofit here diff --git a/server/views/commit/index.jade b/server/views/commit/index.jade index 8d7a065f33..fae22ee978 100644 --- a/server/views/commit/index.jade +++ b/server/views/commit/index.jade @@ -2,36 +2,38 @@ extends ../layout block content .panel.panel-info .panel-body - h3.text-center Commit to yourself. Commit to a nonprofit. + h2.text-center Commit to yourself. Commit to a nonprofit. .row .col-xs-12.col-sm-6.col-sm-offset-3 p Give yourself external motivation and help nonprofits right away. Pledge a monthly donation to a nonprofit until you’ve earned either your Front End or Full Stack Development Certification. + .row .col-xs-12.col-sm-6.col-sm-offset-3.text-center - h4 Pledge to #{displayName} - .spacer + h3 Pledge to #{displayName}  + .button-spacer a(href='#{imgUrl}' data-lightbox='img-enlarge' alt='#{imgAlt}') img.img-responsive(src='#{imgUrl}' alt='#{imgAlt}') - p= description - a(href='/commit/directory') or browse our directory + p.large-p + = description + a(href='/commit/directory') ...or see other nonprofits .spacer form.form(name='commit') .hidden input(type='text' value='#{name}' name='nonprofit') .row .col-xs-12.col-sm-6.col-sm-offset-3 - h4 Choose your goal: + h3 Choose your goal: .btn-group.btn-group-justified(data-toggle='buttons' role='group') label.btn.btn-primary.btn-lg.active input(type='radio' id=frontEndCert value=frontEndCert name='goal' checked="checked") - | Front End Development Certificate (takes about 400 hours) + | Front End Development Certification (takes about 400 hours) label.btn.btn-primary.btn-lg input(type='radio' id=fullStackCert value=fullStackCert name='goal') - | Full Stack Development Certificate (takes about 800 hours) + | Full Stack Development Certification (takes about 800 hours) .spacer .row .col-xs-12.col-sm-6.col-sm-offset-3 - h4 Choose how much you want to pledge each month: + h3 Choose your monthly pledge: .btn-group.btn-group-justified(data-toggle='buttons' role='group') label.btn.btn-success input(type='radio' id='5-dollar-pledge' value='5' name='amount') @@ -39,6 +41,9 @@ block content label.btn.btn-success.active input(type='radio' id='10-dollar-pledge' value='10' name='amount' checked="checked") | $10 per month + label.btn.btn-success.active + input(type='radio' id='25-dollar-pledge' value='25' name='amount' checked="checked") + | $25 per month label.btn.btn-success input(type='radio' id='50-dollar-pledge' value='50' name='amount') | $50 per month @@ -46,7 +51,7 @@ block content .row .col-xs-12.col-sm-6.col-sm-offset-3.text-center a#commit-btn-submit.btn.btn-block.btn-lg.signup-btn(href=donateUrl target='_blank') Commit (and open donate page) - .button-spacer + if pledge form.row(name='stop-pledge' action='/commit/stop-commitment' method='post') .col-xs-12.col-sm-6.col-sm-offset-3.text-center From adfbdd7f9fa9e57182e4a01b021e33756bb38a4f Mon Sep 17 00:00:00 2001 From: Quincy Larson Date: Wed, 7 Oct 2015 01:06:36 -0700 Subject: [PATCH 15/15] more style improvements --- server/utils/commit-goals.json | 4 ++-- server/views/account/show.jade | 2 +- server/views/commit/index.jade | 12 +++++++----- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/server/utils/commit-goals.json b/server/utils/commit-goals.json index 8391145e6b..d9f20e47ff 100644 --- a/server/utils/commit-goals.json +++ b/server/utils/commit-goals.json @@ -1,4 +1,4 @@ { - "frontEndCert": "front-end-development-certificate", - "fullStackCert": "full-stack-development-certificate" + "frontEndCert": "Front End Development Certification", + "fullStackCert": "Full Stack Development Certification" } diff --git a/server/views/account/show.jade b/server/views/account/show.jade index 9b11ef7778..e5385a7e72 100644 --- a/server/views/account/show.jade +++ b/server/views/account/show.jade @@ -63,7 +63,7 @@ block content h4 | This camper has committed to giving $#{pledge.amount} to a(href='#{pledge.donateUrl}?ref=freecodecamp.com' target='_blank') #{pledge.displayName} - | each month until they have completed the #{pledge.goal} + | each month until they have completed their #{pledge.goal}. .spacer if isFrontEndCert a.btn.btn-primary(href='/' + username + '/front-end-certification') View My Front End Development Certification diff --git a/server/views/commit/index.jade b/server/views/commit/index.jade index fae22ee978..34c307a39e 100644 --- a/server/views/commit/index.jade +++ b/server/views/commit/index.jade @@ -41,7 +41,7 @@ block content label.btn.btn-success.active input(type='radio' id='10-dollar-pledge' value='10' name='amount' checked="checked") | $10 per month - label.btn.btn-success.active + label.btn.btn-success input(type='radio' id='25-dollar-pledge' value='25' name='amount' checked="checked") | $25 per month label.btn.btn-success @@ -55,12 +55,14 @@ block content if pledge form.row(name='stop-pledge' action='/commit/stop-commitment' method='post') .col-xs-12.col-sm-6.col-sm-offset-3.text-center - button.btn.btn-sm.btn-danger(name='submit' type='submit') Stop my pledge + .button-spacer + button.btn.btn-block.btn-danger(name='submit' type='submit') Stop my current pledge else .row - h4.col-xs-12.col-sm-6.col-sm-offset-3.text-center - a(href='/') Maybe later - .spacer + .col-xs-12.col-sm-6.col-sm-offset-3.text-center + .button-spacer + a.btn.btn-block.btn-default(href='/') Maybe later + .spacer script. $(function() { $('#commit-btn-submit').click(function() {