Change full stack to back end
This commit is contained in:
@ -5,8 +5,8 @@ import { Observable } from 'rx';
|
|||||||
import debugFactory from 'debug';
|
import debugFactory from 'debug';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
frontEndChallangeId,
|
frontEndChallengeId,
|
||||||
fullStackChallangeId
|
backEndChallengeId
|
||||||
} from '../utils/constantStrings.json';
|
} from '../utils/constantStrings.json';
|
||||||
import { ifNoUser401, ifNoUserRedirectTo } from '../utils/middleware';
|
import { ifNoUser401, ifNoUserRedirectTo } from '../utils/middleware';
|
||||||
import { observeQuery } from '../utils/rx';
|
import { observeQuery } from '../utils/rx';
|
||||||
@ -126,6 +126,11 @@ module.exports = function(app) {
|
|||||||
|
|
||||||
router.get(
|
router.get(
|
||||||
'/:username/full-stack-certification',
|
'/:username/full-stack-certification',
|
||||||
|
(req, res) => res.redirect(req.url.replace('full-stack', 'back-end'))
|
||||||
|
);
|
||||||
|
|
||||||
|
router.get(
|
||||||
|
'/:username/back-end-certification',
|
||||||
showCert
|
showCert
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -243,6 +248,7 @@ module.exports = function(app) {
|
|||||||
pledge: profileUser.pledge,
|
pledge: profileUser.pledge,
|
||||||
|
|
||||||
isFrontEndCert: profileUser.isFrontEndCert,
|
isFrontEndCert: profileUser.isFrontEndCert,
|
||||||
|
isBackEndCert: profileUser.isBackEndCert,
|
||||||
isFullStackCert: profileUser.isFullStackCert,
|
isFullStackCert: profileUser.isFullStackCert,
|
||||||
isHonest: profileUser.isHonest,
|
isHonest: profileUser.isHonest,
|
||||||
|
|
||||||
@ -275,7 +281,8 @@ module.exports = function(app) {
|
|||||||
function showCert(req, res, next) {
|
function showCert(req, res, next) {
|
||||||
const username = req.params.username.toLowerCase();
|
const username = req.params.username.toLowerCase();
|
||||||
const { user } = req;
|
const { user } = req;
|
||||||
const showFront = req.path.split('/').pop() === 'front-end-certification';
|
const whichCert = req.path.split('/').pop();
|
||||||
|
const showFront = whichCert === 'front-end-certification';
|
||||||
Observable.just(user)
|
Observable.just(user)
|
||||||
.flatMap(user => {
|
.flatMap(user => {
|
||||||
if (user && user.username === username) {
|
if (user && user.username === username) {
|
||||||
@ -285,6 +292,7 @@ module.exports = function(app) {
|
|||||||
isGithubCool: true,
|
isGithubCool: true,
|
||||||
isFrontEndCert: true,
|
isFrontEndCert: true,
|
||||||
isFullStackCert: true,
|
isFullStackCert: true,
|
||||||
|
isBackEndCert: true,
|
||||||
isHonest: true,
|
isHonest: true,
|
||||||
completedChallenges: true,
|
completedChallenges: true,
|
||||||
username: true,
|
username: true,
|
||||||
@ -329,19 +337,19 @@ module.exports = function(app) {
|
|||||||
|
|
||||||
if (
|
if (
|
||||||
showFront && user.isFrontEndCert ||
|
showFront && user.isFrontEndCert ||
|
||||||
!showFront && user.isFullStackCert
|
!showFront && user.isBackEndCert
|
||||||
) {
|
) {
|
||||||
var { completedDate = new Date() } =
|
var { completedDate = new Date() } =
|
||||||
_.find(user.completedChallenges, {
|
_.find(user.completedChallenges, {
|
||||||
id: showFront ?
|
id: showFront ?
|
||||||
frontEndChallangeId :
|
frontEndChallengeId :
|
||||||
fullStackChallangeId
|
backEndChallengeId
|
||||||
}) || {};
|
}) || {};
|
||||||
|
|
||||||
return res.render(
|
return res.render(
|
||||||
showFront ?
|
showFront ?
|
||||||
'certificate/front-end.jade' :
|
'certificate/front-end.jade' :
|
||||||
'certificate/full-stack.jade',
|
'certificate/back-end.jade',
|
||||||
{
|
{
|
||||||
username: user.username,
|
username: user.username,
|
||||||
date: moment(new Date(completedDate))
|
date: moment(new Date(completedDate))
|
||||||
@ -353,7 +361,7 @@ module.exports = function(app) {
|
|||||||
req.flash('errors', {
|
req.flash('errors', {
|
||||||
msg: showFront ?
|
msg: showFront ?
|
||||||
`Looks like user ${username} is not Front End certified` :
|
`Looks like user ${username} is not Front End certified` :
|
||||||
`Looks like user ${username} is not Full Stack certified`
|
`Looks like user ${username} is not Back End certified`
|
||||||
});
|
});
|
||||||
res.redirect('back');
|
res.redirect('back');
|
||||||
},
|
},
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"gitHubUserAgent": "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",
|
"gitHubUserAgent": "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",
|
||||||
"frontEndChallangeId": "561add10cb82ac38a17513be",
|
"frontEndChallengeId": "561add10cb82ac38a17513be",
|
||||||
"fullStackChallangeId": "660add10cb82ac38a17513be"
|
"backEndChallengeId": "660add10cb82ac38a17513be"
|
||||||
}
|
}
|
||||||
|
@ -67,9 +67,9 @@ block content
|
|||||||
.spacer
|
.spacer
|
||||||
if isFrontEndCert
|
if isFrontEndCert
|
||||||
a.btn.btn-primary(href='/' + username + '/front-end-certification') View My Front End Development Certification
|
a.btn.btn-primary(href='/' + username + '/front-end-certification') View My Front End Development Certification
|
||||||
if isFullStackCert
|
if isBackEndCert
|
||||||
.button-spacer
|
.button-spacer
|
||||||
a.btn.btn-success(href='/' + username + '/full-stack-certification') View My Full Stack Development Certification
|
a.btn.btn-success(href='/' + username + '/back-end-certification') View My Back End Development Certification
|
||||||
//if (user && user.username !== username)
|
//if (user && user.username !== username)
|
||||||
// a.btn.btn-lg.btn-block.btn-twitter.btn-link-social(href='/leaderboard/add?username=#{username}')
|
// a.btn.btn-lg.btn-block.btn-twitter.btn-link-social(href='/leaderboard/add?username=#{username}')
|
||||||
// i.fa.fa-plus-square
|
// i.fa.fa-plus-square
|
||||||
|
6
server/views/certificate/back-end.jade
Normal file
6
server/views/certificate/back-end.jade
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
include font
|
||||||
|
#name.cert-name= name
|
||||||
|
img#cert.img-abs(src='http://i.imgur.com/yBKoMVP.jpg')
|
||||||
|
.cert-date= date
|
||||||
|
.cert-link verify this certification at: http://freecodecamp.com/#{username}/back-end-certification
|
||||||
|
include script
|
Reference in New Issue
Block a user