-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
46 changed files
with
254 additions
and
153 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
(function() { | ||
|
||
'use strict'; | ||
|
||
const knex = require('./connection'); | ||
|
||
function dropTables() { | ||
return Promise.all([ | ||
knex('chapters').del(), | ||
knex('lessons').del(), | ||
knex('users').del(), | ||
knex('messages').del(), | ||
knex('suggestions').del(), | ||
knex('codes').del() | ||
]); | ||
} | ||
|
||
function insertUsers() { | ||
return knex('users') | ||
.insert({ | ||
github_username: 'Michael', | ||
github_id: 987, | ||
github_display_name: 'Michael Johnson', | ||
github_access_token: '798', | ||
github_avatar: 'https://avatars.io/static/default_128.jpg', | ||
email: 'michael@johnson.com', | ||
verified: false, | ||
admin: false | ||
}); | ||
} | ||
|
||
function insertChapters() { | ||
return Promise.all([ | ||
knex('chapters').insert({ | ||
order_number: 1, | ||
name: 'Functions and Loops' | ||
}), | ||
knex('chapters').insert({ | ||
order_number: 2, | ||
name: 'Conditional logic' | ||
}), | ||
knex('chapters').insert({ | ||
order_number: 3, | ||
name: 'Lists and Dictionaries' | ||
}), | ||
knex('chapters').insert({ | ||
order_number: 4, | ||
name: 'Inactive Chapter', | ||
active: false | ||
}) | ||
]); | ||
} | ||
|
||
function getChapters() { | ||
return knex('chapters') | ||
.select('*') | ||
.orderBy('order_number') | ||
.returning('*'); | ||
} | ||
|
||
module.exports = { | ||
dropTables, | ||
insertUsers, | ||
insertChapters, | ||
getChapters | ||
}; | ||
|
||
}()); |
2 changes: 1 addition & 1 deletion
2
src/server/db/queries.chapters.js → src/server/db/queries/chapters.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/server/db/queries.codes.js → src/server/db/queries/codes.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/server/db/queries.lessons.js → src/server/db/queries/lessons.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/server/db/queries.messages.js → src/server/db/queries/messages.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/server/db/queries.suggestions.js → src/server/db/queries/suggestions.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/server/db/queries.users.js → src/server/db/queries/users.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
src/server/db/queries.users_lessons.js → src/server/db/queries/users_lessons.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
exports.seed = (knex, Promise) => { | ||
return Promise.all([ | ||
knex('chapters').del(), | ||
knex('lessons').del(), | ||
knex('users').del(), | ||
knex('messages').del(), | ||
knex('suggestions').del(), | ||
knex('codes').del() | ||
]); | ||
// return Promise.all([ | ||
// knex('chapters').del(), | ||
// knex('lessons').del(), | ||
// knex('users').del(), | ||
// knex('messages').del(), | ||
// knex('suggestions').del(), | ||
// knex('codes').del() | ||
// ]); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
(function() { | ||
|
||
'use strict'; | ||
|
||
const helpers = require('../_seed_helpers'); | ||
|
||
exports.seed = (knex, Promise) => { | ||
return Promise.join( | ||
helpers.dropTables() | ||
) | ||
.then(() => { | ||
return Promise.all([ | ||
helpers.insertUsers(), | ||
helpers.insertChapters() | ||
]); | ||
}) | ||
.then(() => { | ||
return Promise.join( | ||
helpers.getChapters() | ||
); | ||
}) | ||
.then((chapters) => { | ||
// console.log(chapters); | ||
}); | ||
}; | ||
|
||
}()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
exports.seed = (knex, Promise) => { | ||
return knex('users') | ||
.insert({ | ||
github_username: 'Michael', | ||
github_id: 987, | ||
github_display_name: 'Michael Johnson', | ||
github_access_token: '798', | ||
github_avatar: 'https://avatars.io/static/default_128.jpg', | ||
email: 'michael@johnson.com', | ||
verified: false, | ||
admin: false | ||
}); | ||
// return knex('users') | ||
// .insert({ | ||
// github_username: 'Michael', | ||
// github_id: 987, | ||
// github_display_name: 'Michael Johnson', | ||
// github_access_token: '798', | ||
// github_avatar: 'https://avatars.io/static/default_128.jpg', | ||
// email: 'michael@johnson.com', | ||
// verified: false, | ||
// admin: false | ||
// }); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,21 @@ | ||
exports.seed = (knex, Promise) => { | ||
return Promise.join( | ||
knex('chapters').insert({ | ||
order_number: 1, | ||
name: 'Functions and Loops' | ||
}), | ||
knex('chapters').insert({ | ||
order_number: 2, | ||
name: 'Conditional logic' | ||
}), | ||
knex('chapters').insert({ | ||
order_number: 3, | ||
name: 'Lists and Dictionaries' | ||
}), | ||
knex('chapters').insert({ | ||
order_number: 4, | ||
name: 'Inactive Chapter', | ||
active: false | ||
}) | ||
); | ||
// return Promise.join( | ||
// knex('chapters').insert({ | ||
// order_number: 1, | ||
// name: 'Functions and Loops' | ||
// }), | ||
// knex('chapters').insert({ | ||
// order_number: 2, | ||
// name: 'Conditional logic' | ||
// }), | ||
// knex('chapters').insert({ | ||
// order_number: 3, | ||
// name: 'Lists and Dictionaries' | ||
// }), | ||
// knex('chapters').insert({ | ||
// order_number: 4, | ||
// name: 'Inactive Chapter', | ||
// active: false | ||
// }) | ||
// ); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,48 @@ | ||
const express = require('express'); | ||
const router = express.Router(); | ||
|
||
const authHelpers = require('../../auth/helpers'); | ||
const userQueries = require('../../db/queries.users'); | ||
|
||
// *** get verification status *** // | ||
router.get( | ||
'/verification', | ||
authHelpers.ensureAdmin, | ||
getVerificationStatus | ||
); | ||
|
||
// *** toggle verification status *** // | ||
router.get( | ||
'/verification/toggle', | ||
authHelpers.ensureAdmin, | ||
toggleVerificationStatus | ||
); | ||
|
||
function getVerificationStatus(req, res, next) { | ||
let status = false; | ||
// check status | ||
if (parseInt(process.env.CAN_VERIFY) === 1) status = true; | ||
return res.status(200).json({ | ||
status: 'success', | ||
verified: status | ||
}); | ||
} | ||
|
||
function toggleVerificationStatus(req, res, next) { | ||
process.env.CAN_VERIFY = 1; | ||
// check status | ||
if (parseInt(process.env.CAN_VERIFY) === 1) process.env.CAN_VERIFY = 0; | ||
req.flash('messages', { | ||
status: 'success', | ||
value: 'Verification status toggled.' | ||
}); | ||
return res.redirect('/'); | ||
} | ||
|
||
module.exports = router; | ||
(function() { | ||
|
||
'use strict'; | ||
|
||
const express = require('express'); | ||
const router = express.Router(); | ||
|
||
const authHelpers = require('../../auth/helpers'); | ||
const userQueries = require('../../db/queries/users'); | ||
|
||
// *** get verification status *** // | ||
router.get( | ||
'/verification', | ||
authHelpers.ensureAdmin, | ||
getVerificationStatus | ||
); | ||
|
||
// *** toggle verification status *** // | ||
router.get( | ||
'/verification/toggle', | ||
authHelpers.ensureAdmin, | ||
toggleVerificationStatus | ||
); | ||
|
||
function getVerificationStatus(req, res, next) { | ||
let status = false; | ||
// check status | ||
if (parseInt(process.env.CAN_VERIFY) === 1) status = true; | ||
return res.status(200).json({ | ||
status: 'success', | ||
verified: status | ||
}); | ||
} | ||
|
||
function toggleVerificationStatus(req, res, next) { | ||
process.env.CAN_VERIFY = 1; | ||
// check status | ||
if (parseInt(process.env.CAN_VERIFY) === 1) process.env.CAN_VERIFY = 0; | ||
req.flash('messages', { | ||
status: 'success', | ||
value: 'Verification status toggled.' | ||
}); | ||
return res.redirect('/'); | ||
} | ||
|
||
module.exports = router; | ||
|
||
}()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.