Merge pull request #403 from QuincyLarson/master

Unsubscribe mechanism for email campaigns
This commit is contained in:
Quincy Larson
2015-05-01 00:10:05 -07:00
7 changed files with 62 additions and 20 deletions

10
app.js
View File

@ -514,6 +514,16 @@ app.post(
storyController.upvote
);
app.get(
'/unsubscribe/:email',
resourcesController.unsubscribe
);
app.get(
'/unsubscribed',
resourcesController.unsubscribed
);
app.all('/account', passportConf.isAuthenticated);
app.get('/account/api', userController.getAccountAngular);

View File

@ -185,6 +185,31 @@ module.exports = {
});
},
unsubscribe: function unsubscribe(req, res) {
User.findOne({email: req.params.email}, function(err, user) {
if (user) {
if (err) {
return next(err);
}
user.sendMonthlyEmail = false;
user.save(function () {
if (err) {
return next(err);
}
res.redirect('/unsubscribed');
});
} else {
res.redirect('/unsubscribed');
}
});
},
unsubscribed: function unsubscribed(req, res) {
res.render('resources/unsubscribed', {
title: "You have been unsubscribed"
});
},
githubCalls: function(req, res) {
var githubHeaders = {headers: {'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1521.3 Safari/537.36'}, port:80 };
request('https://api.github.com/repos/freecodecamp/freecodecamp/pulls?client_id=' + secrets.github.clientID + '&client_secret=' + secrets.github.clientSecret, githubHeaders, function(err, status1, pulls) {

View File

@ -141,6 +141,7 @@ var userSchema = new mongoose.Schema({
},
needsMigration: { type: Boolean, default: true },
finishedWaypoints: { type: Boolean, default: false },
sendMonthlyEmail: { type: Boolean, default: true },
challengesHash: {}
});

View File

@ -260,7 +260,7 @@
},
{
"_id": "bd7159d9c442eddfaeb5bdef",
"name": "What does Register mean?",
"name": "Global Mac Keyboard Shortcuts",
"description": [
"<div class=\"col-xs-12 col-sm-10 col-sm-offset-1\">",
"<h2 class='text-center'></h2>",

View File

@ -112,21 +112,21 @@ block content
a(href="/nonprofits/directory") Browse our nonprofit projects
p * Complete all Waypoints, Bonfires, Ziplines and Basejumps to be assigned your first nonprofit project
//#announcementModal.modal(tabindex='-1')
// .modal-dialog
// .modal-content
// .modal-header.challenge-list-header We've updated our curriculum
// a.close.closing-x(href='#', data-dismiss='modal', aria-hidden='true') ×
// .modal-body
// h3.text-left We now have a 1,600 hour curriculum and tons of new challenges. Read more about it
// a(href='http://blog.freecodecamp.com', target='_blank') here
// | .
// a.btn.btn-lg.btn-info.btn-block(name='_csrf', value=_csrf, aria-hidden='true', href='http://blog.freecodecamp.com/', target='_blank') Take me to the blog post.
// a.btn.btn-lg.btn-primary.btn-block(href='#', data-dismiss='modal', aria-hidden='true') Thanks for the heads-up!
//script.
// $(document).ready(function () {
// if (!localStorage || !localStorage.newCurriculum) {
// $('#announcementModal').modal('show');
// localStorage.campWideMeeting = "true";
// }
// });
#announcementModal.modal(tabindex='-1')
.modal-dialog.animated.fadeInUp.fast-animation
.modal-content
.modal-header.challenge-list-header Join our Saturday Summit!
a.close.closing-x(href='#', data-dismiss='modal', aria-hidden='true') ×
.modal-body
h3.text-left Saturday at Noon EDT: We'll live-stream our Saturday Summit on Twitch.tv. Join us as our community turns 200 days old. We'll have Nonprofit Project demos from 6 of our campers. &thinsp;
a(href='http://www.freecodecamp.com/twitch', target='_blank') Add it to your calendar here
| .
a.btn.btn-lg.btn-info.btn-block(name='_csrf', value=_csrf, aria-hidden='true', href='http://twitch.tv/freecodecamp', target='_blank') Follow us on Twitch.tv
a.btn.btn-lg.btn-primary.btn-block(href='#', data-dismiss='modal', aria-hidden='true') Thanks for the heads-up!
script.
$(document).ready(function () {
if (!localStorage || !localStorage.day200) {
$('#announcementModal').modal('show');
localStorage.day200 = "true";
}
});

View File

@ -67,7 +67,7 @@ block content
$('#complete-courseware-dialog').bind('keypress', modalControlEnterHandler);
- if (user.progressTimestamps.length > 2)
a.animated.fadeIn.btn.btn-lg.btn-block.btn-twitter(href="https://twitter.com/intent/tweet?text=I%20just%20#{verb}%20%40FreeCodeCamp%20Bonfire:%20#{name}&url=http%3A%2F%2Ffreecodecamp.com/bonfires/#{dashedName}&hashtags=LearnToCode, JavaScript" target="_blank")
a.animated.fadeIn.btn.btn-lg.btn-block.btn-twitter(href="https://twitter.com/intent/tweet?text=I%20just%20#{verb}%20%40FreeCodeCamp%20Challenge:%20#{name}&url=http%3A%2F%2Ffreecodecamp.com/challenges/#{dashedName}&hashtags=LearnToCode, JavaScript" target="_blank")
i.fa.fa-twitter &thinsp;
= phrase
- else

View File

@ -0,0 +1,6 @@
extends ../layout
block content
.panel.panel-info
.panel-body.text-center
h1 You have successfully been unsubscribed.
h2 Whatever you do, keep coding! :)