Fix change challenge model to POJO

This commit is contained in:
Berkeley Martinez
2016-01-15 01:44:18 -08:00
parent 47c930d7f4
commit 50b1e61e70
3 changed files with 15 additions and 7 deletions

View File

@ -191,7 +191,7 @@ gulp.task('serve', ['build-manifest'], function(cb) {
ignore: paths.serverIgnore,
exec: path.join(__dirname, 'node_modules/.bin/babel-node'),
env: {
'NODE_ENV': 'development',
'NODE_ENV': process.env.NODE_ENV || 'development',
'DEBUG': process.env.DEBUG || 'freecc:*'
}
})

View File

@ -125,6 +125,7 @@ function getRenderData$(user, challenge$, origChallengeName, solution) {
debug('looking for %s', testChallengeName);
return challenge$
.map(challenge => challenge.toJSON())
.filter((challenge) => {
return testChallengeName.test(challenge.name) &&
shouldNotFilterComingSoon(challenge);
@ -164,7 +165,6 @@ function getRenderData$(user, challenge$, origChallengeName, solution) {
});
}
console.log(challenge.helpRoom);
// save user does nothing if user does not exist
return Observable.just({
data: {
@ -414,7 +414,11 @@ module.exports = function(app) {
app.use(router);
function redirectToCurrentChallenge(req, res, next) {
const challengeId = req.query.id || req.cookies.currentChallengeId;
let challengeId = req.query.id || req.cookies.currentChallengeId;
// prevent serialized null/undefined from breaking things
if (challengeId === 'undefined' || challengeId === 'null') {
challengeId = null;
}
getChallengeById$(challenge$, challengeId)
.doOnNext(({ dashedName })=> {
if (!dashedName) {
@ -430,7 +434,10 @@ module.exports = function(app) {
}
function redirectToNextChallenge(req, res, next) {
const challengeId = req.query.id || req.cookies.currentChallengeId;
let challengeId = req.query.id || req.cookies.currentChallengeId;
if (challengeId === 'undefined' || challengeId === 'null') {
challengeId = null;
}
Observable.combineLatest(
firstChallenge$,
@ -485,8 +492,9 @@ module.exports = function(app) {
return res.redirect(redirectUrl);
}
var view = challengeView[data.challengeType];
res.cookie('currentChallengeId', data.id);
console.log(data.helpRoom);
if (data.id) {
res.cookie('currentChallengeId', data.id);
}
res.render(view, data);
},
next,

View File

@ -29,7 +29,7 @@ export default function prodErrorHandler() {
msg: message
});
}
return res.redirect('/');
return res.redirect('/map');
// json
} else if (type === 'json') {
res.setHeader('Content-Type', 'application/json');