add zipline and basejump to portfolio view, and bonfires with solutions(not yet writing name to bonfireCompletion record on user
This commit is contained in:
@ -113,7 +113,6 @@ exports.returnIndividualBonfire = function(req, res, next) {
|
|||||||
details: bonfire.description.slice(1),
|
details: bonfire.description.slice(1),
|
||||||
tests: bonfire.tests,
|
tests: bonfire.tests,
|
||||||
challengeSeed: bonfire.challengeSeed,
|
challengeSeed: bonfire.challengeSeed,
|
||||||
cc: !!req.user,
|
|
||||||
points: req.user ? req.user.points : undefined,
|
points: req.user ? req.user.points : undefined,
|
||||||
verb: resources.randomVerb(),
|
verb: resources.randomVerb(),
|
||||||
phrase: resources.randomPhrase(),
|
phrase: resources.randomPhrase(),
|
||||||
@ -252,6 +251,7 @@ exports.completedBonfire = function (req, res, next) {
|
|||||||
var isCompletedDate = Math.round(+new Date());
|
var isCompletedDate = Math.round(+new Date());
|
||||||
var bonfireHash = req.body.bonfireInfo.bonfireHash;
|
var bonfireHash = req.body.bonfireInfo.bonfireHash;
|
||||||
var isSolution = req.body.bonfireInfo.solution;
|
var isSolution = req.body.bonfireInfo.solution;
|
||||||
|
var bonfireName = req.body.bonfireInfo.bonfireName;
|
||||||
|
|
||||||
if (isCompletedWith) {
|
if (isCompletedWith) {
|
||||||
var paired = User.find({'profile.username': isCompletedWith
|
var paired = User.find({'profile.username': isCompletedWith
|
||||||
@ -276,6 +276,7 @@ exports.completedBonfire = function (req, res, next) {
|
|||||||
|
|
||||||
pairedWith.completedBonfires.push({
|
pairedWith.completedBonfires.push({
|
||||||
_id: bonfireHash,
|
_id: bonfireHash,
|
||||||
|
name: bonfireName,
|
||||||
completedWith: req.user._id,
|
completedWith: req.user._id,
|
||||||
completedDate: isCompletedDate,
|
completedDate: isCompletedDate,
|
||||||
solution: isSolution
|
solution: isSolution
|
||||||
@ -283,6 +284,7 @@ exports.completedBonfire = function (req, res, next) {
|
|||||||
|
|
||||||
req.user.completedBonfires.push({
|
req.user.completedBonfires.push({
|
||||||
_id: bonfireHash,
|
_id: bonfireHash,
|
||||||
|
name: bonfireName,
|
||||||
completedWith: pairedWith._id,
|
completedWith: pairedWith._id,
|
||||||
completedDate: isCompletedDate,
|
completedDate: isCompletedDate,
|
||||||
solution: isSolution
|
solution: isSolution
|
||||||
@ -304,8 +306,10 @@ exports.completedBonfire = function (req, res, next) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
console.log('look here!', bonfireName);
|
||||||
req.user.completedBonfires.push({
|
req.user.completedBonfires.push({
|
||||||
_id: bonfireHash,
|
_id: bonfireHash,
|
||||||
|
name: bonfireName,
|
||||||
completedWith: null,
|
completedWith: null,
|
||||||
completedDate: isCompletedDate,
|
completedDate: isCompletedDate,
|
||||||
solution: isSolution
|
solution: isSolution
|
||||||
|
@ -305,6 +305,7 @@ exports.completedZiplineOrBasejump = function (req, res, next) {
|
|||||||
|
|
||||||
req.user.completedCoursewares.push({
|
req.user.completedCoursewares.push({
|
||||||
_id: coursewareHash,
|
_id: coursewareHash,
|
||||||
|
name: req.body.coursewareInfo.coursewareName,
|
||||||
completedWith: pairedWith._id,
|
completedWith: pairedWith._id,
|
||||||
completedDate: isCompletedDate,
|
completedDate: isCompletedDate,
|
||||||
solution: solutionLink,
|
solution: solutionLink,
|
||||||
@ -332,6 +333,7 @@ exports.completedZiplineOrBasejump = function (req, res, next) {
|
|||||||
|
|
||||||
pairedWith.completedCoursewares.push({
|
pairedWith.completedCoursewares.push({
|
||||||
_id: coursewareHash,
|
_id: coursewareHash,
|
||||||
|
name: req.body.coursewareInfo.coursewareName,
|
||||||
completedWith: req.user._id,
|
completedWith: req.user._id,
|
||||||
completedDate: isCompletedDate,
|
completedDate: isCompletedDate,
|
||||||
solution: solutionLink,
|
solution: solutionLink,
|
||||||
@ -353,6 +355,7 @@ exports.completedZiplineOrBasejump = function (req, res, next) {
|
|||||||
|
|
||||||
req.user.completedCoursewares.push({
|
req.user.completedCoursewares.push({
|
||||||
_id: coursewareHash,
|
_id: coursewareHash,
|
||||||
|
name: req.body.coursewareInfo.coursewareName,
|
||||||
completedWith: null,
|
completedWith: null,
|
||||||
completedDate: isCompletedDate,
|
completedDate: isCompletedDate,
|
||||||
solution: solutionLink,
|
solution: solutionLink,
|
||||||
|
@ -304,7 +304,9 @@ exports.returnUser = function(req, res, next) {
|
|||||||
|
|
||||||
user.currentStreak = user.currentStreak || 1;
|
user.currentStreak = user.currentStreak || 1;
|
||||||
user.longestStreak = user.longestStreak || 1;
|
user.longestStreak = user.longestStreak || 1;
|
||||||
|
challenges = user.completedCoursewares.filter(function ( obj ) {
|
||||||
|
return !!obj.solution;
|
||||||
|
});
|
||||||
res.render('account/show', {
|
res.render('account/show', {
|
||||||
title: 'Camper ' + user.profile.username + '\'s portfolio',
|
title: 'Camper ' + user.profile.username + '\'s portfolio',
|
||||||
username: user.profile.username,
|
username: user.profile.username,
|
||||||
@ -327,7 +329,8 @@ exports.returnUser = function(req, res, next) {
|
|||||||
website3Link: user.portfolio.website3Link,
|
website3Link: user.portfolio.website3Link,
|
||||||
website3Title: user.portfolio.website3Title,
|
website3Title: user.portfolio.website3Title,
|
||||||
website3Image: user.portfolio.website3Image,
|
website3Image: user.portfolio.website3Image,
|
||||||
ch: user.challengesHash,
|
challenges: challenges,
|
||||||
|
bonfires: user.completedBonfires,
|
||||||
calender: data,
|
calender: data,
|
||||||
moment: moment,
|
moment: moment,
|
||||||
longestStreak: user.longestStreak + (user.longestStreak === 1 ? " day" : " days"),
|
longestStreak: user.longestStreak + (user.longestStreak === 1 ? " day" : " days"),
|
||||||
|
225
models/User.js
225
models/User.js
@ -19,231 +19,7 @@ var userSchema = new mongoose.Schema({
|
|||||||
github: String,
|
github: String,
|
||||||
linkedin: String,
|
linkedin: String,
|
||||||
tokens: Array,
|
tokens: Array,
|
||||||
points: {
|
|
||||||
type: Number,
|
|
||||||
default: 0
|
|
||||||
},
|
|
||||||
progressTimestamps: [],
|
progressTimestamps: [],
|
||||||
challengesCompleted: { type: Array, default: [] },
|
|
||||||
pointsNeedMigration: { type: Boolean, default: true },
|
|
||||||
challengesHash: {
|
|
||||||
0: {
|
|
||||||
type: Number,
|
|
||||||
default: 0
|
|
||||||
},
|
|
||||||
1: {
|
|
||||||
type: Number,
|
|
||||||
default: 0
|
|
||||||
},
|
|
||||||
2: {
|
|
||||||
type: Number,
|
|
||||||
default: 0
|
|
||||||
},
|
|
||||||
3: {
|
|
||||||
type: Number,
|
|
||||||
default: 0
|
|
||||||
},
|
|
||||||
4: {
|
|
||||||
type: Number,
|
|
||||||
default: 0
|
|
||||||
},
|
|
||||||
5: {
|
|
||||||
type: Number,
|
|
||||||
default: 0
|
|
||||||
},
|
|
||||||
6: {
|
|
||||||
type: Number,
|
|
||||||
default: 0
|
|
||||||
},
|
|
||||||
7: {
|
|
||||||
type: Number,
|
|
||||||
default: 0
|
|
||||||
},
|
|
||||||
8: {
|
|
||||||
type: Number,
|
|
||||||
default: 0
|
|
||||||
},
|
|
||||||
9: {
|
|
||||||
type: Number,
|
|
||||||
default: 0
|
|
||||||
},
|
|
||||||
10: {
|
|
||||||
type: Number,
|
|
||||||
default: 0
|
|
||||||
},
|
|
||||||
11: {
|
|
||||||
type: Number,
|
|
||||||
default: 0
|
|
||||||
},
|
|
||||||
12: {
|
|
||||||
type: Number,
|
|
||||||
default: 0
|
|
||||||
},
|
|
||||||
13: {
|
|
||||||
type: Number,
|
|
||||||
default: 0
|
|
||||||
},
|
|
||||||
14: {
|
|
||||||
type: Number,
|
|
||||||
default: 0
|
|
||||||
},
|
|
||||||
15: {
|
|
||||||
type: Number,
|
|
||||||
default: 0
|
|
||||||
},
|
|
||||||
16: {
|
|
||||||
type: Number,
|
|
||||||
default: 0
|
|
||||||
},
|
|
||||||
17: {
|
|
||||||
type: Number,
|
|
||||||
default: 0
|
|
||||||
},
|
|
||||||
18: {
|
|
||||||
type: Number,
|
|
||||||
default: 0
|
|
||||||
},
|
|
||||||
19: {
|
|
||||||
type: Number,
|
|
||||||
default: 0
|
|
||||||
},
|
|
||||||
20: {
|
|
||||||
type: Number,
|
|
||||||
default: 0
|
|
||||||
},
|
|
||||||
21: {
|
|
||||||
type: Number,
|
|
||||||
default: 0
|
|
||||||
},
|
|
||||||
22: {
|
|
||||||
type: Number,
|
|
||||||
default: 0
|
|
||||||
},
|
|
||||||
23: {
|
|
||||||
type: Number,
|
|
||||||
default: 0
|
|
||||||
},
|
|
||||||
24: {
|
|
||||||
type: Number,
|
|
||||||
default: 0
|
|
||||||
},
|
|
||||||
25: {
|
|
||||||
type: Number,
|
|
||||||
default: 0
|
|
||||||
},
|
|
||||||
26: {
|
|
||||||
type: Number,
|
|
||||||
default: 0
|
|
||||||
},
|
|
||||||
27: {
|
|
||||||
type: Number,
|
|
||||||
default: 0
|
|
||||||
},
|
|
||||||
28: {
|
|
||||||
type: Number,
|
|
||||||
default: 0
|
|
||||||
},
|
|
||||||
29: {
|
|
||||||
type: Number,
|
|
||||||
default: 0
|
|
||||||
},
|
|
||||||
30: {
|
|
||||||
type: Number,
|
|
||||||
default: 0
|
|
||||||
},
|
|
||||||
31: {
|
|
||||||
type: Number,
|
|
||||||
default: 0
|
|
||||||
},
|
|
||||||
32: {
|
|
||||||
type: Number,
|
|
||||||
default: 0
|
|
||||||
},
|
|
||||||
33: {
|
|
||||||
type: Number,
|
|
||||||
default: 0
|
|
||||||
},
|
|
||||||
34: {
|
|
||||||
type: Number,
|
|
||||||
default: 0
|
|
||||||
},
|
|
||||||
35: {
|
|
||||||
type: Number,
|
|
||||||
default: 0
|
|
||||||
},
|
|
||||||
36: {
|
|
||||||
type: Number,
|
|
||||||
default: 0
|
|
||||||
},
|
|
||||||
37: {
|
|
||||||
type: Number,
|
|
||||||
default: 0
|
|
||||||
},
|
|
||||||
38: {
|
|
||||||
type: Number,
|
|
||||||
default: 0
|
|
||||||
},
|
|
||||||
39: {
|
|
||||||
type: Number,
|
|
||||||
default: 0
|
|
||||||
},
|
|
||||||
40: {
|
|
||||||
type: Number,
|
|
||||||
default: 0
|
|
||||||
},
|
|
||||||
41: {
|
|
||||||
type: Number,
|
|
||||||
default: 0
|
|
||||||
},
|
|
||||||
42: {
|
|
||||||
type: Number,
|
|
||||||
default: 0
|
|
||||||
},
|
|
||||||
43: {
|
|
||||||
type: Number,
|
|
||||||
default: 0
|
|
||||||
},
|
|
||||||
44: {
|
|
||||||
type: Number,
|
|
||||||
default: 0
|
|
||||||
},
|
|
||||||
45: {
|
|
||||||
type: Number,
|
|
||||||
default: 0
|
|
||||||
},
|
|
||||||
46: {
|
|
||||||
type: Number,
|
|
||||||
default: 0
|
|
||||||
},
|
|
||||||
47: {
|
|
||||||
type: Number,
|
|
||||||
default: 0
|
|
||||||
},
|
|
||||||
48: {
|
|
||||||
type: Number,
|
|
||||||
default: 0
|
|
||||||
},
|
|
||||||
49: {
|
|
||||||
type: Number,
|
|
||||||
default: 0
|
|
||||||
},
|
|
||||||
50: {
|
|
||||||
type: Number,
|
|
||||||
default: 0
|
|
||||||
},
|
|
||||||
51: {
|
|
||||||
type: Number,
|
|
||||||
default: 0
|
|
||||||
},
|
|
||||||
52: {
|
|
||||||
type: Number,
|
|
||||||
default: 0
|
|
||||||
},
|
|
||||||
53: {
|
|
||||||
type: Number,
|
|
||||||
default: 0
|
|
||||||
}
|
|
||||||
},
|
|
||||||
profile: {
|
profile: {
|
||||||
username: {
|
username: {
|
||||||
type: String,
|
type: String,
|
||||||
@ -333,6 +109,7 @@ var userSchema = new mongoose.Schema({
|
|||||||
completedBonfires: [
|
completedBonfires: [
|
||||||
{
|
{
|
||||||
_id: String,
|
_id: String,
|
||||||
|
name: String,
|
||||||
completedWith: String,
|
completedWith: String,
|
||||||
completedDate: Long,
|
completedDate: Long,
|
||||||
solution: String
|
solution: String
|
||||||
|
@ -30,31 +30,16 @@ $(document).ready(function() {
|
|||||||
.addClass('animated fadeInDown');
|
.addClass('animated fadeInDown');
|
||||||
});
|
});
|
||||||
|
|
||||||
//$('.completed-challenge').on('click', function() {
|
|
||||||
// $('#complete-challenge-dialog').modal('show');
|
|
||||||
// // Only post to server if there is an authenticated user
|
|
||||||
// if ($('.signup-btn-nav').length < 1) {
|
|
||||||
// l = location.pathname.split('/');
|
|
||||||
// cn = l[l.length - 1];
|
|
||||||
// $.ajax({
|
|
||||||
// type: 'POST',
|
|
||||||
// data: {challengeNumber: cn},
|
|
||||||
// url: '/completed-challenge/'
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
//});
|
|
||||||
|
|
||||||
|
|
||||||
function completedBonfire(didCompleteWith, bonfireSolution, thisBonfireHash) {
|
function completedBonfire(didCompleteWith, bonfireSolution, thisBonfireHash) {
|
||||||
$('#complete-bonfire-dialog').modal('show');
|
$('#complete-bonfire-dialog').modal('show');
|
||||||
// Only post to server if there is an authenticated user
|
// Only post to server if there is an authenticated user
|
||||||
if ($('.signup-btn-nav').length < 1) {
|
if ($('.signup-btn-nav').length < 1) {
|
||||||
|
|
||||||
$.post(
|
$.post(
|
||||||
'/completed-bonfire',
|
'/completed-bonfire',
|
||||||
{
|
{
|
||||||
bonfireInfo: {
|
bonfireInfo: {
|
||||||
completedWith : didCompleteWith,
|
bonfireName: title,
|
||||||
|
completedWith: didCompleteWith,
|
||||||
solution: bonfireSolution,
|
solution: bonfireSolution,
|
||||||
bonfireHash: thisBonfireHash
|
bonfireHash: thisBonfireHash
|
||||||
}
|
}
|
||||||
@ -70,8 +55,9 @@ $(document).ready(function() {
|
|||||||
$('.next-bonfire-button').on('click', function() {
|
$('.next-bonfire-button').on('click', function() {
|
||||||
var bonfireSolution = myCodeMirror.getValue();
|
var bonfireSolution = myCodeMirror.getValue();
|
||||||
var thisBonfireHash = passedBonfireHash || null;
|
var thisBonfireHash = passedBonfireHash || null;
|
||||||
|
var bonfireName = title;
|
||||||
var didCompleteWith = $('#completed-with').val() || null;
|
var didCompleteWith = $('#completed-with').val() || null;
|
||||||
completedBonfire(didCompleteWith, bonfireSolution, thisBonfireHash);
|
completedBonfire(didCompleteWith, bonfireName, bonfireSolution, thisBonfireHash);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -125,3 +125,34 @@ block content
|
|||||||
.row.text-primary
|
.row.text-primary
|
||||||
h4.col-sm-6.text-right Longest Streak: #{longestStreak}
|
h4.col-sm-6.text-right Longest Streak: #{longestStreak}
|
||||||
h4.col-sm-6.text-left Current Streak: #{currentStreak}
|
h4.col-sm-6.text-left Current Streak: #{currentStreak}
|
||||||
|
|
||||||
|
- if (challenges.length > 0)
|
||||||
|
.col-sm-12
|
||||||
|
table.table.table-striped
|
||||||
|
thead
|
||||||
|
tr
|
||||||
|
th Challenge
|
||||||
|
th Date Completed
|
||||||
|
th Link
|
||||||
|
for challenge in challenges
|
||||||
|
tr
|
||||||
|
td= challenge.name
|
||||||
|
td= moment(challenge.completedDate, 'x').format("MMM DD, YYYY")
|
||||||
|
td
|
||||||
|
a(href=challenge.solution) View my solution
|
||||||
|
|
||||||
|
br
|
||||||
|
- if (bonfires.length > 0)
|
||||||
|
.col-sm-12
|
||||||
|
table.table.table-striped
|
||||||
|
thead
|
||||||
|
tr
|
||||||
|
th Bonfire
|
||||||
|
th Date Completed
|
||||||
|
th Link
|
||||||
|
for bonfire in bonfires
|
||||||
|
tr
|
||||||
|
td= bonfire.name
|
||||||
|
td= moment(bonfire.completedDate, 'x').format("MMM DD, YYYY")
|
||||||
|
td= bonfire.solution
|
||||||
|
br
|
||||||
|
Reference in New Issue
Block a user