Remove some debug/console.log statements.
Fix allFieldGuideIds method in resources.js to return an array of _ids, not an array of objects. Field guide controller now correctly completes field guides. Closes #367.
This commit is contained in:
1
app.js
1
app.js
@ -81,7 +81,6 @@ app.set('port', process.env.PORT || 3000);
|
||||
app.set('views', path.join(__dirname, 'views'));
|
||||
app.set('view engine', 'jade');
|
||||
|
||||
console.log(process.env.NODE_ENV);
|
||||
|
||||
if (process.env.NODE_ENV === 'production') {
|
||||
app.all(/.*/, function (req, res, next) {
|
||||
|
@ -326,7 +326,6 @@ exports.completedBonfire = function (req, res, next) {
|
||||
return next(err);
|
||||
}
|
||||
if (user) {
|
||||
debug('Saving user');
|
||||
res.send(true);
|
||||
}
|
||||
});
|
||||
|
@ -22,7 +22,7 @@ exports.returnIndividualFieldGuide = function(req, res, next) {
|
||||
return res.redirect('/field-guide');
|
||||
}
|
||||
|
||||
var fieldGuide = fieldGuideFromMongo.pop();
|
||||
var fieldGuide = R.head(fieldGuideFromMongo);
|
||||
var dashedNameFull = fieldGuide.name.toLowerCase().replace(/\s/g, '-').replace(/\?/g, '');
|
||||
if (dashedNameFull !== dashedName) {
|
||||
return res.redirect('../field-guide/' + dashedNameFull);
|
||||
@ -54,20 +54,20 @@ exports.returnNextFieldGuide = function(req, res, next) {
|
||||
|
||||
var completed = req.user.completedFieldGuides;
|
||||
|
||||
req.user.uncompletedFieldGuides = resources.allFieldGuideIds().filter(function (elem) {
|
||||
var uncompletedFieldGuides = resources.allFieldGuideIds().filter(function (elem) {
|
||||
if (completed.indexOf(elem) === -1) {
|
||||
return elem;
|
||||
}
|
||||
});
|
||||
req.user.uncompletedFieldGuides = uncompletedFieldGuides;
|
||||
req.user.save();
|
||||
|
||||
var uncompletedFieldGuides = req.user.uncompletedFieldGuides;
|
||||
|
||||
var displayedFieldGuides = FieldGuide.find({'_id': uncompletedFieldGuides[0]});
|
||||
displayedFieldGuides.exec(function(err, fieldGuide) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
fieldGuide, fieldGuide[0]);
|
||||
fieldGuide = fieldGuide.pop();
|
||||
if (typeof fieldGuide === 'undefined') {
|
||||
req.flash('success', {
|
||||
@ -81,14 +81,13 @@ exports.returnNextFieldGuide = function(req, res, next) {
|
||||
};
|
||||
|
||||
exports.completedFieldGuide = function (req, res, next) {
|
||||
debug('params in completedFieldGuide', req.params);
|
||||
var fieldGuideId = req.body.fieldGuideInfo.fieldGuideId;
|
||||
|
||||
req.user.completedFieldGuides.push(fieldGuideId);
|
||||
|
||||
var index = req.user.uncompletedFieldGuides.indexOf(fieldGuideId);
|
||||
if (index > -1) {
|
||||
req.user.progressTimestamps.push(Date.now() || 0);
|
||||
req.user.progressTimestamps.push(Date.now());
|
||||
req.user.uncompletedFieldGuides.splice(index, 1);
|
||||
}
|
||||
|
||||
|
@ -132,7 +132,6 @@ exports.returnIndividualNonprofit = function(req, res, next) {
|
||||
var hasShownInterest = nonprofit.interestedCampers.filter(function ( obj ) {
|
||||
return obj.username === req.user.profile.username;
|
||||
});
|
||||
console.log(hasShownInterest);
|
||||
if (hasShownInterest.length === 0) {
|
||||
buttonActive = true;
|
||||
}
|
||||
|
@ -261,9 +261,7 @@ module.exports = {
|
||||
} else {
|
||||
allFieldGuideIds = fieldGuides.
|
||||
map(function (elem) {
|
||||
return {
|
||||
_id: elem._id
|
||||
};
|
||||
return elem._id;
|
||||
});
|
||||
return allFieldGuideIds;
|
||||
}
|
||||
|
@ -118,7 +118,7 @@ exports.preSubmit = function(req, res) {
|
||||
exports.returnIndividualStory = function(req, res, next) {
|
||||
var dashedName = req.params.storyName;
|
||||
|
||||
var storyName = dashedName.replace(/\-/g, ' ');
|
||||
var storyName = dashedName.replace(/\-/g, ' ').trim();
|
||||
|
||||
Story.find({'storyLink': storyName}, function(err, story) {
|
||||
if (err) {
|
||||
@ -321,9 +321,10 @@ exports.storySubmission = function(req, res, next) {
|
||||
.replace(/\'/g, '')
|
||||
.replace(/\"/g, '')
|
||||
.replace(/,/g, '')
|
||||
.replace(/[^a-z0-9]/gi, ' ')
|
||||
.replace(/\s+/g, ' ')
|
||||
.toLowerCase();
|
||||
.replace(/[^a-z0-9\s]/gi, '')
|
||||
.toLowerCase()
|
||||
.trim();
|
||||
var link = data.link;
|
||||
if (link.search(/^https?:\/\//g) === -1) {
|
||||
link = 'http://' + link;
|
||||
@ -334,7 +335,7 @@ exports.storySubmission = function(req, res, next) {
|
||||
}
|
||||
|
||||
// if duplicate storyLink add unique number
|
||||
storyLink = (storyCount == 0) ? storyLink : storyLink + ' ' + storyCount;
|
||||
storyLink = (storyCount === 0) ? storyLink : storyLink + ' ' + storyCount;
|
||||
|
||||
var link = data.link;
|
||||
if (link.search(/^https?:\/\//g) === -1) {
|
||||
|
@ -100,7 +100,6 @@ $(document).ready(function() {
|
||||
});
|
||||
|
||||
$('.next-field-guide-button').on('click', function() {
|
||||
console.log('click');
|
||||
var fieldGuideId = $('#fieldGuideId').text();
|
||||
completedFieldGuide(fieldGuideId);
|
||||
});
|
||||
@ -126,7 +125,6 @@ $(document).ready(function() {
|
||||
});
|
||||
|
||||
$('#next-courseware-button').on('click', function() {
|
||||
console.log(passedCoursewareHash);
|
||||
if ($('.signup-btn-nav').length < 1) {
|
||||
switch (challengeType) {
|
||||
case 0:
|
||||
|
Reference in New Issue
Block a user