Add ability to edit commit
This commit is contained in:
@ -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.' },
|
||||
{
|
||||
title: 'Commit to a nonprofit. Commit to your goal.',
|
||||
pledge
|
||||
},
|
||||
nonprofit
|
||||
)
|
||||
);
|
||||
},
|
||||
next
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
function pledge(req, res, next) {
|
||||
@ -114,6 +142,5 @@ export default function commit(app) {
|
||||
},
|
||||
next
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -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"
|
||||
}
|
||||
]
|
||||
|
@ -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
|
||||
|
Reference in New Issue
Block a user