Add email functionality to done-with-first-100-hours page and refactor nonprofit link to be on same controller in same view folder
parent
89357f3d13
commit
13faedc86e
24
app.js
24
app.js
|
@ -197,8 +197,8 @@ app.use(
|
|||
/**
|
||||
* Main routes.
|
||||
*/
|
||||
app.get('/', homeController.index);
|
||||
|
||||
app.get('/', homeController.index);
|
||||
app.get(
|
||||
'/resources/interview-questions',
|
||||
resourcesController.interviewQuestions);
|
||||
|
@ -213,20 +213,14 @@ app.get('/gmail-shortcuts', resourcesController.gmailShortcuts);
|
|||
app.get('/control-shortcuts', resourcesController.controlShortcuts);
|
||||
app.get('/control-shortcuts', resourcesController.deployAWebsite);
|
||||
app.get('/stats', resourcesController.stats);
|
||||
|
||||
app.get(
|
||||
'/pair-program-with-team-viewer',
|
||||
resourcesController.pairProgramWithTeamViewer
|
||||
);
|
||||
app.get(
|
||||
'/done-with-first-100-hours',
|
||||
resourcesController.doneWithFirst100Hours
|
||||
);
|
||||
app.get(
|
||||
'/programmer-interview-questions-app',
|
||||
resourcesController.programmerInterviewQuestionsApp
|
||||
);
|
||||
|
||||
app.get('/about', resourcesController.about);
|
||||
app.get('/login', userController.getLogin);
|
||||
app.post('/login', userController.postLogin);
|
||||
|
@ -239,8 +233,16 @@ app.get('/email-signup', userController.getEmailSignup);
|
|||
app.get('/email-signin', userController.getEmailSignin);
|
||||
app.post('/email-signup', userController.postEmailSignup);
|
||||
app.post('/email-signin', userController.postLogin);
|
||||
app.get('/nonprofits', contactController.getContact);
|
||||
app.post('/nonprofits', contactController.postContact);
|
||||
app.get('/nonprofits', contactController.getNonprofitsForm);
|
||||
app.post('/nonprofits', contactController.postNonprofitsForm);
|
||||
app.get(
|
||||
'/done-with-first-100-hours',
|
||||
contactController.getDoneWithFirst100Hours
|
||||
);
|
||||
app.post(
|
||||
'/done-with-first-100-hours',
|
||||
contactController.postDoneWithFirst100Hours
|
||||
);
|
||||
|
||||
// # Protected routes, user must be logged in.
|
||||
app.post(
|
||||
|
@ -248,13 +250,13 @@ app.post(
|
|||
passportConf.isAuthenticated,
|
||||
userController.updateProgress
|
||||
);
|
||||
|
||||
app.get(
|
||||
'/challenges/:challengeNumber',
|
||||
challengesController.returnChallenge
|
||||
);
|
||||
app.all('/account', passportConf.isAuthenticated);
|
||||
app.get('/account/api', userController.getAccountAngular);
|
||||
|
||||
// Unique Check API route
|
||||
app.get('/api/checkUniqueUsername/:username', userController.checkUniqueUsername);
|
||||
app.get('/api/checkUniqueEmail/:email', userController.checkUniqueEmail);
|
||||
|
@ -264,8 +266,6 @@ app.post('/account/password', userController.postUpdatePassword);
|
|||
app.post('/account/delete', userController.postDeleteAccount);
|
||||
app.get('/account/unlink/:provider', userController.getOauthUnlink);
|
||||
|
||||
|
||||
|
||||
//put this route last
|
||||
app.get(
|
||||
'/:username',
|
||||
|
|
|
@ -10,46 +10,65 @@ var transporter = nodemailer.createTransport({
|
|||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* GET /contact
|
||||
* Contact form page.
|
||||
*/
|
||||
module.exports = {
|
||||
/**
|
||||
* GET /contact
|
||||
* Contact form page.
|
||||
*/
|
||||
|
||||
exports.getContact = function(req, res) {
|
||||
res.render('contact', {
|
||||
title: 'Free Code Work for Nonprofits Project Submission Page'
|
||||
});
|
||||
};
|
||||
getNonprofitsForm: function(req, res) {
|
||||
res.render('contact/nonprofits', {
|
||||
title: 'Free Code Work for Nonprofits Project Submission Page'
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* POST /contact
|
||||
* Send a contact form via Nodemailer.
|
||||
*/
|
||||
/**
|
||||
* POST /contact
|
||||
* Send a contact form via Nodemailer.
|
||||
*/
|
||||
|
||||
exports.postContact = function(req, res) {
|
||||
req.assert('name', 'Name cannot be blank').notEmpty();
|
||||
req.assert('email', 'Email is not valid').isEmail();
|
||||
req.assert('message', 'Message cannot be blank').notEmpty();
|
||||
postNonprofitsForm: function(req, res) {
|
||||
var mailOptions = {
|
||||
to: 'team@freecodecamp.com',
|
||||
name: req.body.name,
|
||||
from: req.body.email,
|
||||
subject: 'CodeNonprofit Project Idea from ' + req.body.name,
|
||||
text: req.body.message
|
||||
};
|
||||
|
||||
if (req.validationErrors()) {
|
||||
req.flash('errors', errors);
|
||||
return res.redirect('/nonprofits');
|
||||
transporter.sendMail(mailOptions, function (err) {
|
||||
if (err) {
|
||||
req.flash('errors', {msg: err.message});
|
||||
return res.redirect('/nonprofits');
|
||||
}
|
||||
req.flash('success', {msg: 'Email has been sent successfully!'});
|
||||
res.redirect('/nonprofits');
|
||||
});
|
||||
},
|
||||
|
||||
getDoneWithFirst100Hours: function(req, res) {
|
||||
res.render('contact/done-with-first-100-hours', {
|
||||
title:
|
||||
'Congratulations on finishing the first 100 hours of Free Code Camp!'
|
||||
});
|
||||
},
|
||||
|
||||
postDoneWithFirst100Hours: function(req, res) {
|
||||
var mailOptions = {
|
||||
to: 'team@freecodecamp.com',
|
||||
name: 'Completionist',
|
||||
from: req.body.email,
|
||||
subject: 'Code Camper at ' + req.body.email + ' has completed the first 100 hours',
|
||||
text: ''
|
||||
};
|
||||
|
||||
transporter.sendMail(mailOptions, function (err) {
|
||||
if (err) {
|
||||
req.flash('errors', {msg: err.message});
|
||||
return res.redirect('/done-with-first-100-hours');
|
||||
}
|
||||
req.flash('success', {msg: 'Email has been sent successfully!'});
|
||||
res.redirect('/');
|
||||
});
|
||||
}
|
||||
|
||||
var mailOptions = {
|
||||
to: 'team@freecodecamp.com',
|
||||
name: req.body.name,
|
||||
from: req.body.email,
|
||||
subject: 'CodeNonprofit Project Idea from ' + req.body.name,
|
||||
text: req.body.message
|
||||
};
|
||||
|
||||
transporter.sendMail(mailOptions, function(err) {
|
||||
if (err) {
|
||||
req.flash('errors', { msg: err.message });
|
||||
return res.redirect('/nonprofits');
|
||||
}
|
||||
req.flash('success', { msg: 'Email has been sent successfully!' });
|
||||
res.redirect('/nonprofits');
|
||||
});
|
||||
};
|
||||
|
|
|
@ -175,13 +175,6 @@ module.exports = {
|
|||
});
|
||||
},
|
||||
|
||||
doneWithFirst100Hours: function(req, res) {
|
||||
res.render('resources/done-with-first-100-hours', {
|
||||
title:
|
||||
'Congratulations on finishing the first 100 hours of Free Code Camp!'
|
||||
});
|
||||
},
|
||||
|
||||
interviewQuestions: function(req, res) {
|
||||
res.json(questions);
|
||||
}
|
||||
|
|
|
@ -194,6 +194,11 @@ ul {
|
|||
animation-delay: 2s;
|
||||
}
|
||||
|
||||
.delay-4 {
|
||||
-webkit-animation-delay: 4s;
|
||||
animation-delay: 4s;
|
||||
}
|
||||
|
||||
.delay-10 {
|
||||
-webkit-animation-delay: 10s;
|
||||
animation-delay: 10s;
|
||||
|
|
|
@ -74,6 +74,12 @@ profileValidation.controller('nonprofitFormController', ['$scope',
|
|||
}
|
||||
]);
|
||||
|
||||
profileValidation.controller('doneWithFirst100HoursFormController', ['$scope',
|
||||
function($scope) {
|
||||
|
||||
}
|
||||
]);
|
||||
|
||||
profileValidation.directive('uniqueUsername', function($http) {
|
||||
return {
|
||||
restrict: 'A',
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
extends ../layout
|
||||
block content
|
||||
.jumbotron.text-center
|
||||
h1.animated.lightSpeedIn Congratulations!
|
||||
.animated.fadeIn.delay-2
|
||||
h2 You've completed the first 100 hours of Free Code Camp!
|
||||
.animated.fadeIn.delay-4
|
||||
h3 Now you're ready to continue your learning by building solutions for nonprofits! If you've completed all the Free Code Camp challenges and the Easy and Medium CoderByte challenges, enter your email below. We'll send you an email with the next steps.
|
||||
br
|
||||
form.form-horizontal(role='form', action="/done-with-first-100-hours/", method='POST', novalidate='novalidate', name='doneWithFirst100HoursForm')
|
||||
input(type='hidden', name='_csrf', value=_csrf)
|
||||
.form-group
|
||||
label(class='col-sm-3 control-label', for='email') Your email *
|
||||
.col-sm-8
|
||||
input.form-control(type='text', name='email', id='email', autocomplete="off", ng-model='email', required='required', ng-keypress='')
|
||||
.col-sm-8.col-sm-offset-3(ng-show="doneWithFirst100HoursForm.$error.email && !doneWithFirst100HoursForm.email.$pristine")
|
||||
alert(type='danger')
|
||||
span.ion-close-circled
|
||||
| Please enter a valid email format.
|
||||
.col-sm-8.col-sm-offset-3(ng-show="doneWithFirst100HoursForm.email.$invalid && doneWithFirst100HoursForm.email.$error.required && !doneWithFirst100HoursForm.email.$pristine")
|
||||
alert(type='danger')
|
||||
span.ion-close-circled(id='#email-error').
|
||||
Your email is required.
|
||||
.form-group
|
||||
.col-sm-offset-2.col-sm-8
|
||||
button.btn.btn-primary(type='submit', ng-disabled='doneWithFirst100HoursForm.$invalid')
|
||||
span.ion-paper-airplane
|
||||
| Submit
|
|
@ -1,4 +1,4 @@
|
|||
extends layout
|
||||
extends ../layout
|
||||
|
||||
block content
|
||||
.jumbotron
|
|
@ -1,6 +0,0 @@
|
|||
extends ../layout
|
||||
block content
|
||||
.jumbotron.text-center
|
||||
h1.hug-top Congratulations on finishing the first 100 hours of Free Code Camp!
|
||||
h2 Now you're ready to continue your learning by building solutions for nonprofits!
|
||||
h3 Private message Quincy Larson in the Free Code Camp Chatroom and he'll help you get started on your first project.
|
Loading…
Reference in New Issue