diff --git a/controllers/account.controller.js b/controllers/account.controller.js index 2a58d364..0b891f46 100644 --- a/controllers/account.controller.js +++ b/controllers/account.controller.js @@ -25,7 +25,7 @@ function showAccount(req, res) { /** * @function addUser - * @param {{body: {accountDetails: {_id: ObjectId, firstName: string, lastName: string, email: string, password: string, dietaryRestrictions: string, shirtSize: string}}}} req + * @param {{body: {accountDetails: {_id: ObjectId, firstName: string, lastName: string, email: string, password: string}}}} req * @param {*} res * @return {JSON} Success or error status * @description Adds a user from information in req.body.accountDetails diff --git a/controllers/hacker.controller.js b/controllers/hacker.controller.js index b62224a1..bbcdd3bd 100644 --- a/controllers/hacker.controller.js +++ b/controllers/hacker.controller.js @@ -20,7 +20,7 @@ function showHacker(req, res) { /** * @function createdHacker - * @param {{body: {hacker: {_id: ObjectId, accountId: ObjectId, school: string, gender: string, needsBus: boolean, application: {Object}}}}} req + * @param {{body: {hacker: {_id: ObjectId, accountId: ObjectId, status: string, application: {Object}}}}} req * @param {*} res * @return {JSON} Success status * @description returns success message diff --git a/docs/api/api_data.json b/docs/api/api_data.json index a88593fc..a759f28e 100644 --- a/docs/api/api_data.json +++ b/docs/api/api_data.json @@ -1395,7 +1395,7 @@ "examples": [ { "title": "application: ", - "content": "{\n \"application\":{\n \"portfolioURL\":{\n \"resume\":\"resumes/1543458163426-5bff4d736f86be0a41badb91\",\n \"github\":\"https://github.com/abcd\",\n \"dropler\":\"https://dribbble.com/abcd\",\n \"personal\":\"https://www.hi.com/\",\n \"linkedIn\":\"https://linkedin.com/in/abcd\",\n \"other\":\"https://github.com/hackmcgill/hackerAPI/issues/168\"\n },\n \"jobInterest\":\"Internship\",\n \"skills\":[\"Javascript\",\"Typescript\"],\n \"comments\":\"hi!\",\n \"essay\":\"Pls accept me\"\n}", + "content": "{\n \"application\":{\n \"URL\":{\n \"resume\":\"resumes/1543458163426-5bff4d736f86be0a41badb91\",\n \"github\":\"https://github.com/abcd\",\n \"dropler\":\"https://dribbble.com/abcd\",\n \"personal\":\"https://www.hi.com/\",\n \"linkedIn\":\"https://linkedin.com/in/abcd\",\n \"other\":\"https://github.com/hackmcgill/hackerAPI/issues/168\"\n },\n \"jobInterest\":\"Internship\",\n \"skills\":[\"Javascript\",\"Typescript\"],\n \"comments\":\"hi!\",\n \"essay\":\"Pls accept me\"\n}", "type": "Json" } ] @@ -1422,7 +1422,7 @@ "examples": [ { "title": "Success-Response: ", - "content": "{\n \"message\": \"Hacker creation successful\", \n \"data\": {\n \"id\":\"5bff4d736f86be0a41badb91\",\n \"application\":{\n \"portfolioURL\":{\n \"resume\":\"resumes/1543458163426-5bff4d736f86be0a41badb91\",\n \"github\":\"https://github.com/abcd\",\n \"dropler\":\"https://dribbble.com/abcd\",\n \"personal\":\"https://www.hi.com/\",\n \"linkedIn\":\"https://linkedin.com/in/abcd\",\n \"other\":\"https://github.com/hackmcgill/hackerAPI/issues/168\"\n },\n \"jobInterest\":\"Internship\",\n \"skills\":[\"Javascript\",\"Typescript\"],\n \"comments\":\"hi!\",\n \"essay\":\"Pls accept me\"\n },\n \"status\":\"Applied\",\n \"ethnicity\":[\"White or Caucasian\",\" Asian or Pacific Islander\"],\n \"accountId\":\"5bff2a35e533b0f6562b4998\",\n \"school\":\"McPherson College\",\n \"gender\":\"Female\",\n \"needsBus\":false,\n \"major\":\"Accounting\",\n \"graduationYear\":2019,\n \"codeOfConduct\":true,\n }\n}", + "content": "{\n \"message\": \"Hacker creation successful\", \n \"data\": {\n \"id\":\"5bff4d736f86be0a41badb91\",\n \"application\":{\n \"URL\":{\n \"resume\":\"resumes/1543458163426-5bff4d736f86be0a41badb91\",\n \"github\":\"https://github.com/abcd\",\n \"dropler\":\"https://dribbble.com/abcd\",\n \"personal\":\"https://www.hi.com/\",\n \"linkedIn\":\"https://linkedin.com/in/abcd\",\n \"other\":\"https://github.com/hackmcgill/hackerAPI/issues/168\"\n },\n \"jobInterest\":\"Internship\",\n \"skills\":[\"Javascript\",\"Typescript\"],\n \"comments\":\"hi!\",\n \"essay\":\"Pls accept me\"\n },\n \"status\":\"Applied\",\n \"ethnicity\":[\"White or Caucasian\",\" Asian or Pacific Islander\"],\n \"accountId\":\"5bff2a35e533b0f6562b4998\",\n \"school\":\"McPherson College\",\n \"gender\":\"Female\",\n \"needsBus\":false,\n \"major\":\"Accounting\",\n \"graduationYear\":2019,\n \"codeOfConduct\":true,\n }\n}", "type": "object" } ] @@ -1504,7 +1504,7 @@ "examples": [ { "title": "Success-Response: ", - "content": "{\n \"message\": \"Successfully retrieved hacker information\", \n \"data\": {\n \"id\":\"5bff4d736f86be0a41badb91\",\n \"application\":{\n \"portfolioURL\":{\n \"resume\":\"resumes/1543458163426-5bff4d736f86be0a41badb91\",\n \"github\":\"https://github.com/abcd\",\n \"dropler\":\"https://dribbble.com/abcd\",\n \"personal\":\"https://www.hi.com/\",\n \"linkedIn\":\"https://linkedin.com/in/abcd\",\n \"other\":\"https://github.com/hackmcgill/hackerAPI/issues/168\"\n },\n \"jobInterest\":\"Internship\",\n \"skills\":[\"Javascript\",\"Typescript\"],\n \"comments\":\"hi!\",\n \"essay\":\"Pls accept me\"\n },\n \"status\":\"Applied\",\n \"ethnicity\":[\"White or Caucasian\",\" Asian or Pacific Islander\"],\n \"accountId\":\"5bff2a35e533b0f6562b4998\",\n \"school\":\"McPherson College\",\n \"gender\":\"Female\",\n \"needsBus\":false,\n \"major\":\"Accounting\",\n \"graduationYear\":2019,\n \"codeOfConduct\":true,\n }\n }", + "content": "{\n \"message\": \"Successfully retrieved hacker information\", \n \"data\": {\n \"id\":\"5bff4d736f86be0a41badb91\",\n \"application\":{\n \"URL\":{\n \"resume\":\"resumes/1543458163426-5bff4d736f86be0a41badb91\",\n \"github\":\"https://github.com/abcd\",\n \"dropler\":\"https://dribbble.com/abcd\",\n \"personal\":\"https://www.hi.com/\",\n \"linkedIn\":\"https://linkedin.com/in/abcd\",\n \"other\":\"https://github.com/hackmcgill/hackerAPI/issues/168\"\n },\n \"jobInterest\":\"Internship\",\n \"skills\":[\"Javascript\",\"Typescript\"],\n \"comments\":\"hi!\",\n \"essay\":\"Pls accept me\"\n },\n \"status\":\"Applied\",\n \"ethnicity\":[\"White or Caucasian\",\" Asian or Pacific Islander\"],\n \"accountId\":\"5bff2a35e533b0f6562b4998\",\n \"school\":\"McPherson College\",\n \"gender\":\"Female\",\n \"needsBus\":false,\n \"major\":\"Accounting\",\n \"graduationYear\":2019,\n \"codeOfConduct\":true,\n }\n }", "type": "object" } ] @@ -1586,7 +1586,7 @@ "examples": [ { "title": "Success-Response: ", - "content": "{\n \"message\": \"Successfully retrieved hacker information\", \n \"data\": {\n \"id\":\"5bff4d736f86be0a41badb91\",\n \"application\":{\n \"portfolioURL\":{\n \"resume\":\"resumes/1543458163426-5bff4d736f86be0a41badb91\",\n \"github\":\"https://github.com/abcd\",\n \"dropler\":\"https://dribbble.com/abcd\",\n \"personal\":\"https://www.hi.com/\",\n \"linkedIn\":\"https://linkedin.com/in/abcd\",\n \"other\":\"https://github.com/hackmcgill/hackerAPI/issues/168\"\n },\n \"jobInterest\":\"Internship\",\n \"skills\":[\"Javascript\",\"Typescript\"],\n \"comments\":\"hi!\",\n \"essay\":\"Pls accept me\"\n },\n \"status\":\"Applied\",\n \"ethnicity\":[\"White or Caucasian\",\" Asian or Pacific Islander\"],\n \"accountId\":\"5bff2a35e533b0f6562b4998\",\n \"school\":\"McPherson College\",\n \"gender\":\"Female\",\n \"needsBus\":false,\n \"major\":\"Accounting\",\n \"graduationYear\":2019,\n \"codeOfConduct\":true,\n }\n }", + "content": "{\n \"message\": \"Successfully retrieved hacker information\", \n \"data\": {\n \"id\":\"5bff4d736f86be0a41badb91\",\n \"application\":{\n \"URL\":{\n \"resume\":\"resumes/1543458163426-5bff4d736f86be0a41badb91\",\n \"github\":\"https://github.com/abcd\",\n \"dropler\":\"https://dribbble.com/abcd\",\n \"personal\":\"https://www.hi.com/\",\n \"linkedIn\":\"https://linkedin.com/in/abcd\",\n \"other\":\"https://github.com/hackmcgill/hackerAPI/issues/168\"\n },\n \"jobInterest\":\"Internship\",\n \"skills\":[\"Javascript\",\"Typescript\"],\n \"comments\":\"hi!\",\n \"essay\":\"Pls accept me\"\n },\n \"status\":\"Applied\",\n \"ethnicity\":[\"White or Caucasian\",\" Asian or Pacific Islander\"],\n \"accountId\":\"5bff2a35e533b0f6562b4998\",\n \"school\":\"McPherson College\",\n \"gender\":\"Female\",\n \"needsBus\":false,\n \"major\":\"Accounting\",\n \"graduationYear\":2019,\n \"codeOfConduct\":true,\n }\n }", "type": "object" } ] @@ -1821,7 +1821,7 @@ "examples": [ { "title": "application: ", - "content": "{\n \"portfolioURL\":{\n \"resume\":\"resumes/1543458163426-5bff4d736f86be0a41badb91\",\n \"github\":\"https://github.com/abcd\",\n \"dropler\":\"https://dribbble.com/abcd\",\n \"personal\":\"https://www.hi.com/\",\n \"linkedIn\":\"https://linkedin.com/in/abcd\",\n \"other\":\"https://github.com/hackmcgill/hackerAPI/issues/168\"\n },\n \"jobInterest\":\"Internship\",\n \"skills\":[\"Javascript\",\"Typescript\"],\n \"comments\":\"hi!\",\n \"essay\":\"Pls accept me\"\n }", + "content": "{\n \"URL\":{\n \"resume\":\"resumes/1543458163426-5bff4d736f86be0a41badb91\",\n \"github\":\"https://github.com/abcd\",\n \"dropler\":\"https://dribbble.com/abcd\",\n \"personal\":\"https://www.hi.com/\",\n \"linkedIn\":\"https://linkedin.com/in/abcd\",\n \"other\":\"https://github.com/hackmcgill/hackerAPI/issues/168\"\n },\n \"jobInterest\":\"Internship\",\n \"skills\":[\"Javascript\",\"Typescript\"],\n \"comments\":\"hi!\",\n \"essay\":\"Pls accept me\"\n }", "type": "Json" } ] @@ -1848,7 +1848,7 @@ "examples": [ { "title": "Success-Response: ", - "content": "{\n \"message\": \"Changed hacker information\", \n \"data\": {\n \"id\":\"5bff4d736f86be0a41badb91\",\n \"application\":{\n \"portfolioURL\":{\n \"resume\":\"resumes/1543458163426-5bff4d736f86be0a41badb91\",\n \"github\":\"https://github.com/abcd\",\n \"dropler\":\"https://dribbble.com/abcd\",\n \"personal\":\"https://www.hi.com/\",\n \"linkedIn\":\"https://linkedin.com/in/abcd\",\n \"other\":\"https://github.com/hackmcgill/hackerAPI/issues/168\"\n },\n \"jobInterest\":\"Internship\",\n \"skills\":[\"Javascript\",\"Typescript\"],\n \"comments\":\"hi!\",\n \"essay\":\"Pls accept me\"\n },\n \"status\":\"Applied\",\n \"ethnicity\":[\"White or Caucasian\",\" Asian or Pacific Islander\"],\n \"accountId\":\"5bff2a35e533b0f6562b4998\",\n \"school\":\"McPherson College\",\n \"gender\":\"Female\",\n \"needsBus\":false,\n \"major\":\"Accounting\",\n \"graduationYear\":2019,\n \"codeOfConduct\":true,\n}", + "content": "{\n \"message\": \"Changed hacker information\", \n \"data\": {\n \"id\":\"5bff4d736f86be0a41badb91\",\n \"application\":{\n \"URL\":{\n \"resume\":\"resumes/1543458163426-5bff4d736f86be0a41badb91\",\n \"github\":\"https://github.com/abcd\",\n \"dropler\":\"https://dribbble.com/abcd\",\n \"personal\":\"https://www.hi.com/\",\n \"linkedIn\":\"https://linkedin.com/in/abcd\",\n \"other\":\"https://github.com/hackmcgill/hackerAPI/issues/168\"\n },\n \"jobInterest\":\"Internship\",\n \"skills\":[\"Javascript\",\"Typescript\"],\n \"comments\":\"hi!\",\n \"essay\":\"Pls accept me\"\n },\n \"status\":\"Applied\",\n \"ethnicity\":[\"White or Caucasian\",\" Asian or Pacific Islander\"],\n \"accountId\":\"5bff2a35e533b0f6562b4998\",\n \"school\":\"McPherson College\",\n \"gender\":\"Female\",\n \"needsBus\":false,\n \"major\":\"Accounting\",\n \"graduationYear\":2019,\n \"codeOfConduct\":true,\n}", "type": "object" } ] @@ -1903,7 +1903,7 @@ "type": "string", "optional": true, "field": "status", - "description": "

The new status of the hacker. "Accepted", "Confirmed", or "Withdrawn"

" + "description": "

The new status of the hacker. "Accepted", "Confirmed", or "Cancelled"

" } ] } @@ -2367,7 +2367,7 @@ "examples": [ { "title": "Success-Response: ", - "content": "{\n \"message\": \"Hacker found by logged in account id\", \n \"data\": {\n \"id\":\"5bff4d736f86be0a41badb91\",\n \"application\":{\n \"portfolioURL\":{\n \"resume\":\"resumes/1543458163426-5bff4d736f86be0a41badb91\",\n \"github\":\"https://github.com/abcd\",\n \"dropler\":\"https://dribbble.com/abcd\",\n \"personal\":\"https://www.hi.com/\",\n \"linkedIn\":\"https://linkedin.com/in/abcd\",\n \"other\":\"https://github.com/hackmcgill/hackerAPI/issues/168\"\n },\n \"jobInterest\":\"Internship\",\n \"skills\":[\"Javascript\",\"Typescript\"],\n \"comments\":\"hi!\",\n \"essay\":\"Pls accept me\"\n },\n \"status\":\"Applied\",\n \"ethnicity\":[\"White or Caucasian\",\" Asian or Pacific Islander\"],\n \"accountId\":\"5bff2a35e533b0f6562b4998\",\n \"school\":\"McPherson College\",\n \"gender\":\"Female\",\n \"needsBus\":false,\n \"major\":[\"Accounting\"],\n \"graduationYear\":2019,\n \"codeOfConduct\":true,\n } \n }", + "content": "{\n \"message\": \"Hacker found by logged in account id\", \n \"data\": {\n \"id\":\"5bff4d736f86be0a41badb91\",\n \"application\":{\n \"URL\":{\n \"resume\":\"resumes/1543458163426-5bff4d736f86be0a41badb91\",\n \"github\":\"https://github.com/abcd\",\n \"dropler\":\"https://dribbble.com/abcd\",\n \"personal\":\"https://www.hi.com/\",\n \"linkedIn\":\"https://linkedin.com/in/abcd\",\n \"other\":\"https://github.com/hackmcgill/hackerAPI/issues/168\"\n },\n \"jobInterest\":\"Internship\",\n \"skills\":[\"Javascript\",\"Typescript\"],\n \"comments\":\"hi!\",\n \"essay\":\"Pls accept me\"\n },\n \"status\":\"Applied\",\n \"ethnicity\":[\"White or Caucasian\",\" Asian or Pacific Islander\"],\n \"accountId\":\"5bff2a35e533b0f6562b4998\",\n \"school\":\"McPherson College\",\n \"gender\":\"Female\",\n \"needsBus\":false,\n \"major\":[\"Accounting\"],\n \"graduationYear\":2019,\n \"codeOfConduct\":true,\n } \n }", "type": "object" } ] diff --git a/docs/api/vendor/jquery.min.js b/docs/api/vendor/jquery.min.js index 41c6cfc9..fd1f8aec 100644 --- a/docs/api/vendor/jquery.min.js +++ b/docs/api/vendor/jquery.min.js @@ -1448,12 +1448,9 @@ i > 1 && sa(m), i > 1 && qa( - a - .slice(0, i - 1) - .concat({ - value: - " " === a[i - 2].type ? "*" : "" - }) + a.slice(0, i - 1).concat({ + value: " " === a[i - 2].type ? "*" : "" + }) ).replace(Q, "$1"), c, e > i && wa(a.slice(i, e)), diff --git a/middlewares/account.middleware.js b/middlewares/account.middleware.js index a89f215a..bea0e578 100644 --- a/middlewares/account.middleware.js +++ b/middlewares/account.middleware.js @@ -34,12 +34,12 @@ function parsePatch(req, res, next) { /** * @function parseAccount - * @param {{body: {firstName: string, lastName: string, email: string, password: string, dietaryRestrictions: string, shirtSize: string}}} req + * @param {{body: {firstName: string, lastName: string, email: string, password: string}}} req * @param {*} res * @param {(err?)=>void} next * @return {void} * @description - * Moves firstName, lastName, email, password, dietaryRestrictions, shirtSize from req.body to req.body.accountDetails. + * Moves firstName, lastName, email, password from req.body to req.body.accountDetails. * Hashes the password. * Adds _id to accountDetails. */ @@ -49,6 +49,7 @@ function parseAccount(req, res, next) { firstName: req.body.firstName, lastName: req.body.lastName, pronoun: req.body.pronoun, + gender: req.body.gender, email: req.body.email, password: Services.Account.hashPassword(req.body.password), dietaryRestrictions: req.body.dietaryRestrictions, @@ -60,6 +61,7 @@ function parseAccount(req, res, next) { delete req.body.firstName; delete req.body.lastName; delete req.body.pronoun; + delete req.body.gender; delete req.body.email; delete req.body.password; delete req.body.dietaryRestrictions; diff --git a/middlewares/auth.middleware.js b/middlewares/auth.middleware.js index 6b6866af..ca2c26e4 100644 --- a/middlewares/auth.middleware.js +++ b/middlewares/auth.middleware.js @@ -140,7 +140,7 @@ async function changePassword(req, res, next) { req.body.oldPassword ); // user's old password is correct - if (acc) { + if (!!acc) { req.body.account = await Services.Account.updatePassword( req.user.id, req.body.newPassword @@ -332,7 +332,7 @@ function parseResetToken(req, res, next) { * @param {(err?)=>void} next */ function parseAccountConfirmationToken(req, res, next) { - if (req.body.token) { + if (!!req.body.token) { jwt.verify(req.body.token, process.env.JWT_CONFIRM_ACC_SECRET, function( err, decoded @@ -432,7 +432,7 @@ async function validateConfirmationToken(req, res, next) { * @param {*} next */ async function validateConfirmationTokenWithoutAccount(req, res, next) { - if (req.body.decodedToken) { + if (!!req.body.decodedToken) { const confirmationObj = await Services.AccountConfirmation.findById( req.body.decodedToken.accountConfirmationId ); diff --git a/middlewares/hacker.middleware.js b/middlewares/hacker.middleware.js index 0c3cbc54..affede09 100644 --- a/middlewares/hacker.middleware.js +++ b/middlewares/hacker.middleware.js @@ -32,44 +32,25 @@ function parsePatch(req, res, next) { /** * @function parseHacker - * @param {{body: {accountId: ObjectId, school: string, degree: string, gender: string, needsBus: string, application: Object, authorization: string}}} req + * @param {{body: {accountId: ObjectId, application: Object, authorization: string}}} req * @param {*} res * @param {(err?)=>void} next * @return {void} * @description - * Moves accountId, school, degree, gender, needsBus, application from req.body to req.body.hackerDetails. + * Moves accountId, application from req.body to req.body.hackerDetails. * Adds _id to hackerDetails. */ function parseHacker(req, res, next) { const hackerDetails = { _id: mongoose.Types.ObjectId(), accountId: req.body.accountId, - school: req.body.school, - degree: req.body.degree, - gender: req.body.gender, - needsBus: req.body.needsBus, application: req.body.application, - - ethnicity: req.body.ethnicity, - major: req.body.major, - graduationYear: req.body.graduationYear, - codeOfConduct: req.body.codeOfConduct, - teamId: req.body.teamId }; req.body.token = req.body.authorization; delete req.body.accountId; - delete req.body.school; - delete req.body.degree; - delete req.body.gender; - delete req.body.needsBus; delete req.body.application; - delete req.body.authorization; - delete req.body.ethnicity; - delete req.body.major; - delete req.body.graduationYear; - delete req.body.codeOfConduct; delete req.body.teamId; req.body.hackerDetails = hackerDetails; @@ -280,7 +261,7 @@ async function uploadResume(req, res, next) { req.body.gcfilename = gcfilename; await Services.Hacker.updateOne(req.hacker.id, { $set: { - "application.portfolioURL.resume": gcfilename + "application.general.URL.resume": gcfilename } }); return next(); @@ -297,11 +278,12 @@ async function downloadResume(req, res, next) { if ( hacker && hacker.application && - hacker.application.portfolioURL && - hacker.application.portfolioURL.resume + hacker.application.general && + hacker.application.general.URL && + hacker.application.general.URL.resume ) { req.body.resume = await Services.Storage.download( - hacker.application.portfolioURL.resume + hacker.application.general.URL.resume ); } else { return next({ @@ -480,7 +462,7 @@ function checkStatus(statuses) { return Middleware.Util.asyncMiddleware(async (req, res, next) => { let hacker = await Services.Hacker.findById(req.params.id); - if (hacker) { + if (!!hacker) { const status = hacker.status; // makes sure the hacker's status is in the accepted statuses list if (statuses.indexOf(status) === -1) { @@ -578,10 +560,8 @@ async function createHacker(req, res, next) { } }); } - const hacker = await Services.Hacker.createHacker(hackerDetails); - - if (hacker) { + if (!!hacker) { req.body.hacker = hacker; return next(); } else { @@ -636,7 +616,7 @@ async function findSelf(req, res, next) { const hacker = await Services.Hacker.findByAccountId(req.user.id); - if (hacker) { + if (!!hacker) { req.body.hacker = hacker; return next(); } else { diff --git a/middlewares/validators/account.validator.js b/middlewares/validators/account.validator.js index afcc8271..b1f1fd15 100644 --- a/middlewares/validators/account.validator.js +++ b/middlewares/validators/account.validator.js @@ -7,6 +7,7 @@ module.exports = { VALIDATOR.stringValidator("body", "firstName", false), VALIDATOR.stringValidator("body", "lastName", false), VALIDATOR.stringValidator("body", "pronoun", false), + VALIDATOR.stringValidator("body", "gender", false), VALIDATOR.regexValidator("body", "email", false, Constants.EMAIL_REGEX), VALIDATOR.alphaArrayValidator("body", "dietaryRestrictions", false), VALIDATOR.stringValidator("body", "gender", false), @@ -24,6 +25,7 @@ module.exports = { VALIDATOR.stringValidator("body", "firstName", true), VALIDATOR.stringValidator("body", "lastName", true), VALIDATOR.stringValidator("body", "pronoun", true), + VALIDATOR.stringValidator("body", "gender", true), VALIDATOR.regexValidator("body", "email", true, Constants.EMAIL_REGEX), VALIDATOR.alphaArrayValidator("body", "dietaryRestrictions", true), VALIDATOR.stringValidator("body", "gender", true), diff --git a/middlewares/validators/hacker.validator.js b/middlewares/validators/hacker.validator.js index 985ec925..42504e4c 100644 --- a/middlewares/validators/hacker.validator.js +++ b/middlewares/validators/hacker.validator.js @@ -6,15 +6,120 @@ module.exports = { newHackerValidator: [ // status will be added automatically VALIDATOR.mongoIdValidator("body", "accountId", false), - VALIDATOR.stringValidator("body", "school", false), - VALIDATOR.stringValidator("body", "degree", false), - VALIDATOR.stringValidator("body", "gender", false), - VALIDATOR.booleanValidator("body", "needsBus", false), + // validate that application is a valid object VALIDATOR.applicationValidator("body", "application", false), - VALIDATOR.alphaArrayValidator("body", "ethnicity", false), - VALIDATOR.alphaArrayValidator("body", "major", false), - VALIDATOR.integerValidator("body", "graduationYear", false, 2019, 2030), - VALIDATOR.booleanValidator("body", "codeOfConduct", false, true), + VALIDATOR.stringValidator("body", "application.general.school", false), + VALIDATOR.stringValidator("body", "application.general.degree", false), + VALIDATOR.alphaArrayValidator( + "body", + "application.general.fieldOfStudy", + false + ), + VALIDATOR.integerValidator( + "body", + "application.general.graduationYear", + false, + 2019, + 2030 + ), + VALIDATOR.enumValidator( + "body", + "application.accommodation.shirtSize", + Constants.SHIRT_SIZES, + false + ), + VALIDATOR.stringValidator( + "body", + "application.accommodation.impairments", + true + ), + VALIDATOR.stringValidator( + "body", + "application.accommodation.barriers", + true + ), + VALIDATOR.stringValidator( + "body", + "application.general.URL.resume", + false + ), + VALIDATOR.stringValidator( + "body", + "application.general.URL.github", + true + ), + VALIDATOR.stringValidator( + "body", + "application.general.URL.dribbble", + true + ), + VALIDATOR.stringValidator( + "body", + "application.general.URL.linkedin", + true + ), + VALIDATOR.stringValidator( + "body", + "application.general.URL.other", + true + ), + VALIDATOR.stringValidator( + "body", + "application.general.URL.personal", + true + ), + VALIDATOR.enumValidator( + "body", + "application.general.jobInterest", + Constants.JOB_INTERESTS, + false + ), + VALIDATOR.alphaArrayValidator( + "body", + "application.shortAnswer.skills", + true + ), + VALIDATOR.stringValidator( + "body", + "application.shortAnswer.comments", + true + ), + VALIDATOR.stringValidator( + "body", + "application.shortAnswer.question1", + false + ), + VALIDATOR.stringValidator( + "body", + "application.shortAnswer.question2", + false + ), + + VALIDATOR.alphaArrayValidator( + "body", + "application.other.ethnicity", + false + ), + VALIDATOR.booleanValidator( + "body", + "application.other.privacyPolicy", + false, + true + ), + VALIDATOR.booleanValidator( + "body", + "application.other.codeOfConduct", + false, + true + ), + VALIDATOR.integerValidator( + "body", + "application.accommodation.travel", + true, + 0, + 100 + ), + VALIDATOR.mongoIdValidator("body", "application.team", true), VALIDATOR.mongoIdValidator("body", "teamId", true) ], @@ -23,14 +128,120 @@ module.exports = { ], updateHackerValidator: [ - VALIDATOR.stringValidator("body", "school", true), - VALIDATOR.stringValidator("body", "degree", true), - VALIDATOR.stringValidator("body", "gender", true), - VALIDATOR.booleanValidator("body", "needsBus", true), - VALIDATOR.applicationValidator("body", "application", true), - VALIDATOR.alphaArrayValidator("body", "ethnicity", true), - VALIDATOR.alphaArrayValidator("body", "major", true), - VALIDATOR.integerValidator("body", "graduationYear", true, 2019, 2030) + // validate that application is a valid object + VALIDATOR.applicationValidator("body", "application", false), + VALIDATOR.stringValidator("body", "application.general.school", false), + VALIDATOR.stringValidator("body", "application.general.degree", false), + VALIDATOR.alphaArrayValidator( + "body", + "application.general.fieldOfStudy", + false + ), + VALIDATOR.integerValidator( + "body", + "application.general.graduationYear", + false, + 2019, + 2030 + ), + VALIDATOR.enumValidator( + "body", + "application.accommodation.shirtSize", + Constants.SHIRT_SIZES, + false + ), + VALIDATOR.stringValidator( + "body", + "application.accommodation.impairments", + true + ), + VALIDATOR.stringValidator( + "body", + "application.accommodation.barriers", + true + ), + VALIDATOR.stringValidator( + "body", + "application.general.URL.resume", + false + ), + VALIDATOR.stringValidator( + "body", + "application.general.URL.github", + true + ), + VALIDATOR.stringValidator( + "body", + "application.general.URL.dribbble", + true + ), + VALIDATOR.stringValidator( + "body", + "application.general.URL.linkedin", + true + ), + VALIDATOR.stringValidator( + "body", + "application.general.URL.other", + true + ), + VALIDATOR.stringValidator( + "body", + "application.general.URL.personal", + true + ), + VALIDATOR.enumValidator( + "body", + "application.general.jobInterest", + Constants.JOB_INTERESTS, + false + ), + VALIDATOR.alphaArrayValidator( + "body", + "application.shortAnswer.skills", + true + ), + VALIDATOR.stringValidator( + "body", + "application.shortAnswer.comments", + true + ), + VALIDATOR.stringValidator( + "body", + "application.shortAnswer.question1", + false + ), + VALIDATOR.stringValidator( + "body", + "application.shortAnswer.question2", + false + ), + + VALIDATOR.alphaArrayValidator( + "body", + "application.other.ethnicity", + false + ), + VALIDATOR.booleanValidator( + "body", + "application.other.privacyPolicy", + false, + true + ), + VALIDATOR.booleanValidator( + "body", + "application.other.codeOfConduct", + false, + true + ), + VALIDATOR.booleanValidator( + "body", + "application.accommodation.travel", + true, + 0, + 100 + ), + VALIDATOR.mongoIdValidator("body", "application.team", true) ], updateStatusValidator: [ VALIDATOR.enumValidator( diff --git a/middlewares/validators/validator.helper.js b/middlewares/validators/validator.helper.js index 5638d8cb..961e2c53 100644 --- a/middlewares/validators/validator.helper.js +++ b/middlewares/validators/validator.helper.js @@ -27,7 +27,7 @@ function integerValidator( const value = setProperValidationChainBuilder( fieldLocation, fieldname, - "invalid integer" + "Invalid integer" ); if (optional) { @@ -68,7 +68,7 @@ function mongoIdValidator(fieldLocation, fieldname, optional = true) { const mongoId = setProperValidationChainBuilder( fieldLocation, fieldname, - "invalid mongoID" + "Invalid mongoID" ); if (optional) { @@ -96,7 +96,7 @@ function mongoIdArrayValidator(fieldLocation, fieldname, optional = true) { const arr = setProperValidationChainBuilder( fieldLocation, fieldname, - "invalid mongoID array" + "Invalid mongoID array" ); if (optional) { @@ -129,7 +129,7 @@ function booleanValidator( const booleanField = setProperValidationChainBuilder( fieldLocation, fieldname, - "invalid boolean" + "Invalid boolean" ); if (optional) { @@ -170,7 +170,7 @@ function asciiValidator(fieldLocation, fieldname, optional = true) { const name = setProperValidationChainBuilder( fieldLocation, fieldname, - "invalid name" + "Invalid name" ); if (optional) { return name @@ -198,8 +198,9 @@ function stringValidator(fieldLocation, fieldname, optional = true) { const name = setProperValidationChainBuilder( fieldLocation, fieldname, - "invalid string" + "Invalid String" ); + if (optional) { return name .optional({ @@ -233,7 +234,7 @@ function regexValidator( const match = setProperValidationChainBuilder( fieldLocation, fieldname, - "invalid name" + "Invalid name" ); if (optional) { @@ -262,7 +263,7 @@ function alphaValidator(fieldLocation, fieldname, optional = true) { const name = setProperValidationChainBuilder( fieldLocation, fieldname, - "invalid alpha string" + "Invalid alpha string" ); if (optional) { return name @@ -289,8 +290,9 @@ function alphaArrayValidator(fieldLocation, fieldname, optional = true) { const name = setProperValidationChainBuilder( fieldLocation, fieldname, - "invalid alpha array" + "Invalid alpha array" ); + if (optional) { return name .optional({ @@ -338,7 +340,7 @@ function passwordValidator(fieldLocation, fieldname, optional = true) { const password = setProperValidationChainBuilder( fieldLocation, fieldname, - "invalid password" + "Invalid password" ); if (optional) { return password @@ -370,63 +372,126 @@ function applicationValidator(fieldLocation, fieldname, optional = true) { const application = setProperValidationChainBuilder( fieldLocation, fieldname, - "invalid application" + "Invalid application" ); - - //helper object to iterate through the items in the application and track which items are not valid. + let valid = true; + //helper object to iterate through the items in the application and track which items are not present. const hasValid = { - github: false, - dropler: false, - personal: false, - linkedIn: false, - other: false, + general: false, + school: false, + degree: false, + graduationYear: false, + fieldOfStudy: false, jobInterest: false, - skills: false, - comments: false, - essay: false, - team: false + URL: false, + shortAnswer: false, + question1: false, + question2: false, + accommodation: false, + shirtSize: false, + other: false, + ethnicity: false, + codeOfConduct: false, + privacyPolicy: false }; + if (optional) { return application .optional({ checkFalsy: true }) .custom((app) => { - const jobInterests = Constants.JOB_INTERESTS; - hasValid.github = - !app.portfolioURL.github || - typeof app.portfolioURL.github === "string"; - hasValid.dropler = - !app.portfolioURL.dropler || - typeof app.portfolioURL.dropler === "string"; - hasValid.personal = - !app.portfolioURL.personal || - typeof app.portfolioURL.personal === "string"; - hasValid.linkedIn = - !app.portfolioURL.linkedIn || - typeof app.portfolioURL.linkedIn === "string"; - hasValid.other = - !app.portfolioURL.other || - typeof app.portfolioURL.other === "string"; - hasValid.jobInterest = - !app.jobInterest || jobInterests.includes(app.jobInterest); - hasValid.skills = - !app.skills || alphaArrayValidationHelper(app.skills); - hasValid.comments = - !app.comments || typeof app.comments === "string"; - hasValid.essay = !app.essay || typeof app.essay === "string"; - hasValid.team = - !app.team || mongoose.Types.ObjectId.isValid(app.team); + hasValid.general = app.hasOwnProperty("general"); + if (hasValid.general) { + hasValid.school = app.general.hasOwnProperty("school"); + hasValid.degree = app.general.hasOwnProperty("degree"); + hasValid.fieldOfStudy = app.general.hasOwnProperty( + "fieldOfStudy" + ); + hasValid.graduationYear = app.general.hasOwnProperty( + "graduationYear" + ); + hasValid.jobInterest = app.general.hasOwnProperty( + "jobInterest" + ); + hasValid.URL = app.general.hasOwnProperty("URL"); + } + + hasValid.shortAnswer = app.hasOwnProperty("shortAnswer"); + if (hasValid.shortAnswer) { + hasValid.question1 = app.shortAnswer.hasOwnProperty( + "question1" + ); + hasValid.question2 = app.shortAnswer.hasOwnProperty( + "question2" + ); + } + hasValid.accommodation = app.hasOwnProperty("accommodation"); + if (hasValid.accommodation) { + hasValid.shirtSize = app.accommodation.hasOwnProperty( + "shirtSize" + ); + } + hasValid.other = app.hasOwnProperty("other"); + if (hasValid.other) { + hasValid.ethnicity = app.other.hasOwnProperty("ethnicity"); + hasValid.codeOfConduct = app.other.hasOwnProperty( + "codeOfConduct" + ); + hasValid.privacyPolicy = app.other.hasOwnProperty( + "privacyPolicy" + ); + } + // hasValid.github = + // !app.general.URL.github || + // typeof app.general.URL.github === "string"; + // hasValid.dribbble = + // !app.general.URL.dribbble || + // typeof app.general.URL.dribbble === "string"; + // hasValid.personal = + // !app.general.URL.personal || + // typeof app.general.URL.personal === "string"; + // hasValid.linkedIn = + // !app.general.URL.linkedIn || + // typeof app.general.URL.linkedIn === "string"; + // hasValid.other = + // !app.general.URL.other || + // typeof app.general.URL.other === "string"; + // hasValid.jobInterest = + // !!app.general.jobInterest && + // jobInterests.includes(app.general.jobInterest); + // hasValid.skills = + // !app.shortAnswer.skills || + // alphaArrayValidationHelper(app.shortAnswer.skills); + // hasValid.comments = + // !app.shortAnswer.comments || + // typeof app.shortAnswer.comments === "string"; + // hasValid.question1 = + // !!app.shortAnswer.question1 && + // typeof app.shortAnswer.question1 === "string"; + // hasValid.question2 = + // !!app.shortAnswer.question2 && + // typeof app.shortAnswer.question2 === "string"; + // hasValid.team = + // !app.team || mongoose.Types.ObjectId.isValid(app.team); + return ( - hasValid.comments && - hasValid.github && - hasValid.dropler && - hasValid.personal && - hasValid.linkedIn && - hasValid.other && + hasValid.general && + hasValid.school && + hasValid.degree && + hasValid.graduationYear && + hasValid.fieldOfStudy && hasValid.jobInterest && - hasValid.skills && - hasValid.team + hasValid.URL && + hasValid.shortAnswer && + hasValid.question1 && + hasValid.question2 && + hasValid.accommodation && + hasValid.shirtSize && + hasValid.other && + hasValid.ethnicity && + hasValid.privacyPolicy && + hasValid.codeOfConduct ); }) .withMessage({ @@ -436,44 +501,101 @@ function applicationValidator(fieldLocation, fieldname, optional = true) { } else { return application .custom((app) => { - const jobInterests = Constants.JOB_INTERESTS; - hasValid.github = - !app.portfolioURL.github || - typeof app.portfolioURL.github === "string"; - hasValid.dropler = - !app.portfolioURL.dropler || - typeof app.portfolioURL.dropler === "string"; - hasValid.personal = - !app.portfolioURL.personal || - typeof app.portfolioURL.personal === "string"; - hasValid.linkedIn = - !app.portfolioURL.linkedIn || - typeof app.portfolioURL.linkedIn === "string"; - hasValid.other = - !app.portfolioURL.other || - typeof app.portfolioURL.other === "string"; - hasValid.jobInterest = jobInterests.includes(app.jobInterest); - hasValid.skills = - !app.skills || alphaArrayValidationHelper(app.skills); - hasValid.comments = - !app.comments || typeof app.comments === "string"; - hasValid.essay = !app.essay || typeof app.essay === "string"; - hasValid.team = - !app.team || mongoose.Types.ObjectId.isValid(app.team); + hasValid.general = app.hasOwnProperty("general"); + if (hasValid.general) { + hasValid.school = app.general.hasOwnProperty("school"); + hasValid.degree = app.general.hasOwnProperty("degree"); + hasValid.fieldOfStudy = app.general.hasOwnProperty( + "fieldOfStudy" + ); + hasValid.graduationYear = app.general.hasOwnProperty( + "graduationYear" + ); + hasValid.jobInterest = app.general.hasOwnProperty( + "jobInterest" + ); + hasValid.URL = app.general.hasOwnProperty("URL"); + } + + hasValid.shortAnswer = app.hasOwnProperty("shortAnswer"); + if (hasValid.shortAnswer) { + hasValid.question1 = app.shortAnswer.hasOwnProperty( + "question1" + ); + hasValid.question2 = app.shortAnswer.hasOwnProperty( + "question2" + ); + } + hasValid.accommodation = app.hasOwnProperty("accommodation"); + if (hasValid.accommodation) { + hasValid.shirtSize = app.accommodation.hasOwnProperty( + "shirtSize" + ); + } + hasValid.other = app.hasOwnProperty("other"); + if (hasValid.other) { + hasValid.ethnicity = app.other.hasOwnProperty("ethnicity"); + hasValid.codeOfConduct = app.other.hasOwnProperty( + "codeOfConduct" + ); + hasValid.privacyPolicy = app.other.hasOwnProperty( + "privacyPolicy" + ); + } + // hasValid.github = + // !app.general.URL.github || + // typeof app.general.URL.github === "string"; + // hasValid.dribbble = + // !app.general.URL.dribbble || + // typeof app.general.URL.dribbble === "string"; + // hasValid.personal = + // !app.general.URL.personal || + // typeof app.general.URL.personal === "string"; + // hasValid.linkedIn = + // !app.general.URL.linkedIn || + // typeof app.general.URL.linkedIn === "string"; + // hasValid.other = + // !app.general.URL.other || + // typeof app.general.URL.other === "string"; + // hasValid.jobInterest = + // !!app.general.jobInterest && + // jobInterests.includes(app.general.jobInterest); + // hasValid.skills = + // !app.shortAnswer.skills || + // alphaArrayValidationHelper(app.shortAnswer.skills); + // hasValid.comments = + // !app.shortAnswer.comments || + // typeof app.shortAnswer.comments === "string"; + // hasValid.question1 = + // !!app.shortAnswer.question1 && + // typeof app.shortAnswer.question1 === "string"; + // hasValid.question2 = + // !!app.shortAnswer.question2 && + // typeof app.shortAnswer.question2 === "string"; + // hasValid.team = + // !app.team || mongoose.Types.ObjectId.isValid(app.team); return ( - hasValid.comments && - hasValid.github && - hasValid.dropler && - hasValid.personal && - hasValid.linkedIn && - hasValid.other && + hasValid.general && + hasValid.school && + hasValid.degree && + hasValid.graduationYear && + hasValid.fieldOfStudy && hasValid.jobInterest && - hasValid.skills && - hasValid.team + hasValid.URL && + hasValid.shortAnswer && + hasValid.question1 && + hasValid.question2 && + hasValid.accommodation && + hasValid.shirtSize && + hasValid.other && + hasValid.ethnicity && + hasValid.privacyPolicy && + hasValid.codeOfConduct ); }) .withMessage({ - message: "Not all items of the application are valid", + message: + "Application does not have all of the required fields.", isValid: hasValid }); } @@ -655,7 +777,7 @@ function searchSortValidator(fieldLocation, fieldName) { } else { return false; } - if (model.searchableField(value)) { + if (!!model.searchableField(value)) { let sortOrder = param("sort", "Sorting order not found"); if (!sortOrder.equals("asc") || !sortOrder.equals("desc")) { return false; @@ -677,7 +799,7 @@ function dateValidator(fieldLocation, fieldname, optional = true) { const date = setProperValidationChainBuilder( fieldLocation, fieldname, - "invalid date" + "Invalid date" ); if (optional) { return date @@ -717,7 +839,7 @@ function phoneNumberValidator(fieldLocation, fieldname, optional = true) { const number = setProperValidationChainBuilder( fieldLocation, fieldname, - "invalid phone number" + "Invalid phone number" ); if (optional) { return number @@ -845,7 +967,7 @@ function checkEnum(value, enums) { * * @param {"query" | "body" | "header" | "param"} fieldLocation the location where the field should be found * @param {string} fieldname name of the field that needs to be validated. - * @param {*} errorString the string that is sent back to the user if the field is invalid + * @param {*} errorString the string that is sent back to the user if the field is Invalid */ function setProperValidationChainBuilder( fieldLocation, diff --git a/models/account.model.js b/models/account.model.js index 2e9f0c94..c5228f42 100644 --- a/models/account.model.js +++ b/models/account.model.js @@ -18,7 +18,7 @@ const AccountSchema = new mongoose.Schema({ }, gender: { type: String, - default: "Prefer not to say", + default: "Prefer not to say" }, email: { type: String, diff --git a/models/hacker.model.js b/models/hacker.model.js index 3c78b3c1..b370ebc0 100644 --- a/models/hacker.model.js +++ b/models/hacker.model.js @@ -1,5 +1,4 @@ "use strict"; - const Constants = require("../constants/general.constant"); const mongoose = require("mongoose"); //describes the data type @@ -16,91 +15,119 @@ const HackerSchema = new mongoose.Schema({ required: true, default: "None" }, - school: { - type: String, - required: true - }, - degree: { - type: String, - required: true - }, - //no enum for this - gender: { - type: String - }, - needsBus: Boolean, application: { - portfolioURL: { - //gcloud bucket link - resume: { + general: { + school: { type: String, - default: "" - }, - github: { - type: String + required: true }, - dropler: { - type: String + degree: { + type: String, + required: true }, - personal: { - type: String + fieldOfStudy: [ + { + type: String, + required: true + } + ], + graduationYear: { + type: Number, + required: true }, - linkedIn: { - type: String + jobInterest: { + type: String, + enum: Constants.JOB_INTERESTS, + required: true, + default: "None" }, - other: { - type: String + URL: { + //gcloud bucket link + resume: { + type: String, + default: "" + }, + github: { + type: String + }, + dribbble: { + type: String + }, + personal: { + type: String + }, + linkedIn: { + type: String + }, + other: { + type: String + } } }, - jobInterest: { - type: String, - enum: Constants.JOB_INTERESTS, - required: true, - default: "None" + shortAnswer: { + skills: [ + { + type: String + } + ], + //any miscelaneous comments that the user has + comments: { + type: String, + default: "" + }, + //"Why do you want to come to our hackathon?" + question1: { + type: String, + default: "", + required: true + }, + // "Some Q" + question2: { + type: String, + default: "", + required: true + } }, - skills: [ - { - type: String + other: { + ethnicity: { + type: [ + { + type: String, + required: true + } + ], + required: true + }, + privacyPolicy: { + type: Boolean, + required: true + }, + codeOfConduct: { + type: Boolean, + required: true } - ], - //any miscelaneous comments that the user has - comments: { - type: String, - default: "" }, - //"Why do you want to come to our hackathon?" - essay: { - type: String, - default: "" + accommodation: { + impairments: { + type: String, + default: "" + }, + barriers: { + type: String, + default: "" + }, + shirtSize: { + type: String, + enum: Constants.SHIRT_SIZES, + required: true + }, + travel: { type: Number, default: 0 } }, team: { type: mongoose.Schema.Types.ObjectId, ref: "Team" } }, - ethnicity: { - type: [ - { - type: String, - required: true - } - ], - required: true - }, - major: [ - { - type: String, - required: true - } - ], - graduationYear: { - type: Number, - required: true - }, - codeOfConduct: { - type: Boolean, - required: true - }, teamId: { type: mongoose.Schema.Types.ObjectId, ref: "Team" @@ -116,10 +143,11 @@ HackerSchema.methods.toJSON = function() { }; HackerSchema.methods.isApplicationComplete = function() { const hs = this.toObject(); - const portfolioDone = !!hs.application.portfolioURL.resume; - const jobInterestDone = !!hs.application.jobInterest; - const essayDone = !!hs.application.essay; - return portfolioDone && jobInterestDone && essayDone; + const portfolioDone = !!hs.application.general.URL.resume; + const jobInterestDone = !!hs.application.general.jobInterest; + const question1Done = !!hs.application.shortAnswer.question1; + const question2Done = !!hs.application.shortAnswer.question2; + return portfolioDone && jobInterestDone && question1Done && question2Done; }; /** diff --git a/package-lock.json b/package-lock.json index 87f7cac4..6b6ce283 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5438,9 +5438,9 @@ } }, "lodash": { - "version": "4.17.14", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.14.tgz", - "integrity": "sha512-mmKYbW3GLuJeX+iGP+Y7Gp1AiGHGbXHCOh/jZmrawMmsE7MS4znI3RL2FsjbqOyMayHInjOeykW7PEajUk1/xw==" + "version": "4.17.15", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz", + "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==" }, "lodash.at": { "version": "4.6.0", @@ -5457,6 +5457,11 @@ "resolved": "https://registry.npmjs.org/lodash.clone/-/lodash.clone-4.5.0.tgz", "integrity": "sha1-GVhwRQ9aExkkeN9Lw9I9LeoZB7Y=" }, + "lodash.clonedeep": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz", + "integrity": "sha1-4j8/nE+Pvd6HJSnBBxhXoIblzO8=" + }, "lodash.has": { "version": "4.5.2", "resolved": "https://registry.npmjs.org/lodash.has/-/lodash.has-4.5.2.tgz", @@ -6284,6 +6289,11 @@ "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=" }, + "nvm": { + "version": "0.0.4", + "resolved": "https://registry.npmjs.org/nvm/-/nvm-0.0.4.tgz", + "integrity": "sha1-OKF46dMbKDUIyS0VydqGHRqSELw=" + }, "oauth-sign": { "version": "0.9.0", "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.9.0.tgz", diff --git a/routes/api/account.js b/routes/api/account.js index 71c71b6c..dfa7c802 100644 --- a/routes/api/account.js +++ b/routes/api/account.js @@ -41,7 +41,6 @@ module.exports = { "lastName":"Klein", "pronoun":"he/him", "email":"theo@klein.com", - "dietaryRestrictions":["Halal"], "phoneNumber":1234567890, "gender":"Male", "birthDate":Date("10/30/1997") @@ -70,8 +69,8 @@ module.exports = { * @apiParam (body) {String} lastName Last name of the account creator. * @apiParam (body) {String} pronoun the pronoun of the account creator. * @apiParam (body) {String} email Email of the account. - * @apiParam (body) {String[]} dietaryRestrictions Any dietary restrictions for the user. 'None' if there are no restrictions * @apiParam (body) {String} gender Gender of the account creator. + * @apiParam (body) {String[]} dietaryRestrictions Any dietary restrictions for the user. 'None' if there are no restrictions * @apiParam (body) {String} password The password of the account. * @apiParam (body) {String} birthDate a Date parsable string. * @apiParam (body) {Number} phoneNumber the user's phone number, represented as a string. @@ -84,7 +83,6 @@ module.exports = { "pronoun":"he/him", "email":"theo@klein.com", "password":"hunter2", - "dietaryRestrictions":["Halal"], "phoneNumber":1234567890, "gender":"Male", "birthDate":"10/30/1997" @@ -101,7 +99,6 @@ module.exports = { "lastName":"Klein", "pronoun":"he/him", "email":"theo@klein.com", - "dietaryRestrictions":["Halal"], "phoneNumber":1234567890, "gender":"Male", "birthDate":Date("10/30/1997") @@ -214,11 +211,11 @@ module.exports = { * @apiParam (body) {String} [lastName] Last name of the account creator. * @apiParam (body) {String} [pronoun] The pronoun of the account creator. * @apiParam (body) {String} [email] Email of the account. - * @apiParam (body) {String[]} [dietaryRestrictions] Any dietary restrictions for the user. 'None' if there are no restrictions * @apiParam (body) {String} [gender] Gender of the account creator. * @apiParam (body) {String} [birthDate] A Date parsable string. * @apiParam (body) {Number} [phoneNumber] The user's phone number, represented as a string. - + * @apiParam (body) {String} [birthDate] a Date parsable string. + * @apiParam (body) {String[]} [dietaryRestrictions] Any dietary restrictions for the user. 'None' if there are no restrictions * @apiParamExample {json} Request-Example: * { "gender": "Male" } * @@ -234,7 +231,6 @@ module.exports = { "lastName":"Klein", "pronoun":"he/him", "email":"theo@klein.com", - "dietaryRestrictions":["Halal"], "phoneNumber":1234567890, "gender": "Male", "birthDate":Date("10/30/1997") @@ -282,7 +278,6 @@ module.exports = { "lastName":"Klein", "pronoun":"he/him", "email":"theo@klein.com", - "dietaryRestrictions":["Halal"], "phoneNumber":1234567890, "gender":"Male", "birthDate":Date("10/30/1997") diff --git a/routes/api/hacker.js b/routes/api/hacker.js index 23a4b6d0..c84bbe2a 100644 --- a/routes/api/hacker.js +++ b/routes/api/hacker.js @@ -40,7 +40,7 @@ module.exports = { "data": { "id":"5bff4d736f86be0a41badb91", "application":{ - "portfolioURL":{ + "URL":{ "resume":"resumes/1543458163426-5bff4d736f86be0a41badb91", "github":"https://github.com/abcd", "dropler":"https://dribbble.com/abcd", @@ -58,7 +58,7 @@ module.exports = { "accountId":"5bff2a35e533b0f6562b4998", "school":"McPherson College", "gender":"Female", - "needsBus":false, + "travel":0, "major":["Accounting"], "graduationYear":2019, "codeOfConduct":true, @@ -87,7 +87,7 @@ module.exports = { * @apiParam (body) {MongoID} accountId ObjectID of the respective account * @apiParam (body) {String} school Name of the school the hacker goes to * @apiParam (body) {String} gender Gender of the hacker - * @apiParam (body) {Boolean} needsBus Whether the hacker requires a bus for transportation + * @apiParam (body) {Number} travel Whether the hacker requires a bus for transportation * @apiParam (body) {String[]} ethnicity the ethnicities of the hacker * @apiParam (body) {String[]} major the major of the hacker * @apiParam (body) {Number} graduationYear the graduation year of the hacker @@ -96,7 +96,13 @@ module.exports = { * @apiParamExample {Json} application: * { "application":{ - "portfolioURL":{ + "general":{ + "school": "McGill University", + "degree": "Undergraduate", + "fieldOfStudy": "Computer Science", + "graduationYear": "2021", + "jobInterest":"Internship", + "URL":{ "resume":"resumes/1543458163426-5bff4d736f86be0a41badb91", "github":"https://github.com/abcd", "dropler":"https://dribbble.com/abcd", @@ -104,10 +110,24 @@ module.exports = { "linkedIn":"https://linkedin.com/in/abcd", "other":"https://github.com/hackmcgill/hackerAPI/issues/168" }, - "jobInterest":"Internship", + }, + "shortAnswer": { "skills":["Javascript","Typescript"], + "question1": "I love McHacks", + "question2":"Pls accept me", "comments":"hi!", - "essay":"Pls accept me" + }, + "other:" { + "gender": "male", + "ethnicity": "Asian or Pacific Islander", + "privacyPolicy": true, + "codeOfConduct": true, + } + "accomodation": { + "travel": 0 + }, + } + * } * * @apiSuccess {string} message Success message @@ -118,29 +138,37 @@ module.exports = { * "data": { "id":"5bff4d736f86be0a41badb91", "application":{ - "portfolioURL":{ - "resume":"resumes/1543458163426-5bff4d736f86be0a41badb91", - "github":"https://github.com/abcd", - "dropler":"https://dribbble.com/abcd", - "personal":"https://www.hi.com/", - "linkedIn":"https://linkedin.com/in/abcd", - "other":"https://github.com/hackmcgill/hackerAPI/issues/168" - }, + "general":{ + "school": "McGill University", + "degree": "Undergraduate", + "fieldOfStudy": "Computer Science", + "graduationYear": "2021", "jobInterest":"Internship", + "URL":{ + "resume":"resumes/1543458163426-5bff4d736f86be0a41badb91", + "github":"https://github.com/abcd", + "dropler":"https://dribbble.com/abcd", + "personal":"https://www.hi.com/", + "linkedIn":"https://linkedin.com/in/abcd", + "other":"https://github.com/hackmcgill/hackerAPI/issues/168" + }, + }, + "shortAnswer": { "skills":["Javascript","Typescript"], + "question1": "I love McHacks", + "question2":"Pls accept me", "comments":"hi!", - "essay":"Pls accept me" - }, - "status":"Applied", - "ethnicity":["White or Caucasian"," Asian or Pacific Islander"], - "accountId":"5bff2a35e533b0f6562b4998", - "school":"McPherson College", - "gender":"Female", - "needsBus":false, - "major":"Accounting", - "graduationYear":2019, - "codeOfConduct":true, - * } + }, + "other:" { + "gender": "male", + "ethnicity": "Asian or Pacific Islander", + "privacyPolicy": true, + "codeOfConduct": true, + } + "accomodation": { + "travel": 0 + }, + } * } * @apiError {string} message Error message @@ -151,7 +179,6 @@ module.exports = { hackerRouter.route("/").post( Middleware.Auth.ensureAuthenticated(), Middleware.Auth.ensureAuthorized(), - Middleware.Validator.Hacker.newHackerValidator, Middleware.parseBody.middleware, @@ -166,6 +193,7 @@ module.exports = { Middleware.Auth.createRoleBindings(CONSTANTS.HACKER), Middleware.Hacker.createHacker, Middleware.Hacker.sendAppliedStatusEmail, + Controllers.Hacker.createdHacker ); @@ -191,7 +219,7 @@ module.exports = { "school": { "McGill University": 3, "Harvard University": 7 }, degree: { "Undergraduate": 10 }, gender: { "Male": 1, "Female": 9 }, - needsBus: { "true": 7, "false": 3 }, + travel: { "true": 7, "false": 3 }, ethnicity: { "White": 10, }, jobInterest: { "Internship": 10 }, major: { "Computer Science": 10 }, @@ -267,17 +295,18 @@ module.exports = { * } * @apiPermission Administrator */ - hackerRouter.route("/accept/:id").patch( - Middleware.Validator.RouteParam.idValidator, - Middleware.Auth.ensureAuthenticated(), - Middleware.Auth.ensureAuthorized([Services.Hacker.findById]), - Middleware.Hacker.validateConfirmedStatusFromHackerId, - Middleware.Hacker.parseAccept, - Middleware.Hacker.updateHacker, - Middleware.Hacker.sendStatusUpdateEmail, - Controllers.Hacker.updatedHacker - ); - + hackerRouter + .route("/accept/:id") + .patch( + Middleware.Validator.RouteParam.idValidator, + Middleware.Auth.ensureAuthenticated(), + Middleware.Auth.ensureAuthorized([Services.Hacker.findById]), + Middleware.Hacker.validateConfirmedStatusFromHackerId, + Middleware.Hacker.parseAccept, + Middleware.Hacker.updateHacker, + Middleware.Hacker.sendStatusUpdateEmail, + Controllers.Hacker.updatedHacker + ); /** * @api {patch} /hacker/checkin/:id update a hacker's status to be 'Checked-in'. Note that the Hacker must eitehr be Accepted or Confirmed. @@ -325,25 +354,45 @@ module.exports = { * * @apiParam (body) {String} [school] Name of the school the hacker goes to * @apiParam (body) {String} [gender] Gender of the hacker - * @apiParam (body) {Boolean} [needsBus] Whether the hacker requires a bus for transportation + * @apiParam (body) {Number} [travel] How much the hacker requires a bus for transportation * @apiParam (body) {String[]} [ethnicity] the ethnicities of the hacker * @apiParam (body) {String[]} [major] the major of the hacker * @apiParam (body) {Number} [graduationYear] the graduation year of the hacker * @apiParam (body) {Json} [application] The hacker's application * @apiParamExample {Json} application: * { - "portfolioURL":{ + "application":{ + "general":{ + "school": "McGill University", + "degree": "Undergraduate", + "fieldOfStudy": "Computer Science", + "graduationYear": "2021", + "jobInterest":"Internship", + "URL":{ "resume":"resumes/1543458163426-5bff4d736f86be0a41badb91", "github":"https://github.com/abcd", "dropler":"https://dribbble.com/abcd", "personal":"https://www.hi.com/", "linkedIn":"https://linkedin.com/in/abcd", "other":"https://github.com/hackmcgill/hackerAPI/issues/168" + }, }, - "jobInterest":"Internship", - "skills":["Javascript","Typescript"], - "comments":"hi!", - "essay":"Pls accept me" + "shortAnswer": { + "skills":["Javascript","Typescript"], + "question1": "I love McHacks", + "question2":"Pls accept me", + "comments":"hi!", + }, + "other:" { + "gender": "male", + "ethnicity": "Asian or Pacific Islander", + "privacyPolicy": true, + "codeOfConduct": true, + } + "accomodation": { + "travel": 0 + }, + } } * * @apiSuccess {string} message Success message @@ -353,29 +402,40 @@ module.exports = { * "message": "Changed hacker information", * "data": { "id":"5bff4d736f86be0a41badb91", - "application":{ - "portfolioURL":{ - "resume":"resumes/1543458163426-5bff4d736f86be0a41badb91", - "github":"https://github.com/abcd", - "dropler":"https://dribbble.com/abcd", - "personal":"https://www.hi.com/", - "linkedIn":"https://linkedin.com/in/abcd", - "other":"https://github.com/hackmcgill/hackerAPI/issues/168" - }, + "status": "Applied", + "application":{ + "general":{ + "school": "McGill University", + "degree": "Undergraduate", + "fieldOfStudy": "Computer Science", + "graduationYear": "2021", "jobInterest":"Internship", + "URL":{ + "resume":"resumes/1543458163426-5bff4d736f86be0a41badb91", + "github":"https://github.com/abcd", + "dropler":"https://dribbble.com/abcd", + "personal":"https://www.hi.com/", + "linkedIn":"https://linkedin.com/in/abcd", + "other":"https://github.com/hackmcgill/hackerAPI/issues/168" + }, + }, + "shortAnswer": { "skills":["Javascript","Typescript"], + "question1": "I love McHacks", + "question2":"Pls accept me", "comments":"hi!", - "essay":"Pls accept me" - }, - "status":"Applied", - "ethnicity":["White or Caucasian"," Asian or Pacific Islander"], - "accountId":"5bff2a35e533b0f6562b4998", - "school":"McPherson College", - "gender":"Female", - "needsBus":false, - "major":"Accounting", - "graduationYear":2019, - "codeOfConduct":true, + }, + "other:" { + "gender": "male", + "ethnicity": "Asian or Pacific Islander", + "privacyPolicy": true, + "codeOfConduct": true, + } + "accomodation": { + "travel": 0 + }, + } + } * } * @apiError {string} message Error message * @apiError {object} data empty @@ -413,29 +473,39 @@ module.exports = { "message": "Successfully retrieved hacker information", "data": { "id":"5bff4d736f86be0a41badb91", + "status": "Applied", "application":{ - "portfolioURL":{ - "resume":"resumes/1543458163426-5bff4d736f86be0a41badb91", - "github":"https://github.com/abcd", - "dropler":"https://dribbble.com/abcd", - "personal":"https://www.hi.com/", - "linkedIn":"https://linkedin.com/in/abcd", - "other":"https://github.com/hackmcgill/hackerAPI/issues/168" - }, + "general":{ + "school": "McGill University", + "degree": "Undergraduate", + "fieldOfStudy": "Computer Science", + "graduationYear": "2021", "jobInterest":"Internship", + "URL":{ + "resume":"resumes/1543458163426-5bff4d736f86be0a41badb91", + "github":"https://github.com/abcd", + "dropler":"https://dribbble.com/abcd", + "personal":"https://www.hi.com/", + "linkedIn":"https://linkedin.com/in/abcd", + "other":"https://github.com/hackmcgill/hackerAPI/issues/168" + }, + }, + "shortAnswer": { "skills":["Javascript","Typescript"], + "question1": "I love McHacks", + "question2":"Pls accept me", "comments":"hi!", - "essay":"Pls accept me" - }, - "status":"Applied", - "ethnicity":["White or Caucasian"," Asian or Pacific Islander"], - "accountId":"5bff2a35e533b0f6562b4998", - "school":"McPherson College", - "gender":"Female", - "needsBus":false, - "major":"Accounting", - "graduationYear":2019, - "codeOfConduct":true, + }, + "other:" { + "gender": "male", + "ethnicity": "Asian or Pacific Islander", + "privacyPolicy": true, + "codeOfConduct": true, + } + "accomodation": { + "travel": 0 + }, + } } } @@ -470,29 +540,39 @@ module.exports = { "message": "Successfully retrieved hacker information", "data": { "id":"5bff4d736f86be0a41badb91", + "status": "Applied", "application":{ - "portfolioURL":{ - "resume":"resumes/1543458163426-5bff4d736f86be0a41badb91", - "github":"https://github.com/abcd", - "dropler":"https://dribbble.com/abcd", - "personal":"https://www.hi.com/", - "linkedIn":"https://linkedin.com/in/abcd", - "other":"https://github.com/hackmcgill/hackerAPI/issues/168" - }, + "general":{ + "school": "McGill University", + "degree": "Undergraduate", + "fieldOfStudy": "Computer Science", + "graduationYear": "2021", "jobInterest":"Internship", + "URL":{ + "resume":"resumes/1543458163426-5bff4d736f86be0a41badb91", + "github":"https://github.com/abcd", + "dropler":"https://dribbble.com/abcd", + "personal":"https://www.hi.com/", + "linkedIn":"https://linkedin.com/in/abcd", + "other":"https://github.com/hackmcgill/hackerAPI/issues/168" + }, + }, + "shortAnswer": { "skills":["Javascript","Typescript"], + "question1": "I love McHacks", + "question2":"Pls accept me", "comments":"hi!", - "essay":"Pls accept me" - }, - "status":"Applied", - "ethnicity":["White or Caucasian"," Asian or Pacific Islander"], - "accountId":"5bff2a35e533b0f6562b4998", - "school":"McPherson College", - "gender":"Female", - "needsBus":false, - "major":"Accounting", - "graduationYear":2019, - "codeOfConduct":true, + }, + "other:" { + "gender": "male", + "ethnicity": "Asian or Pacific Islander", + "privacyPolicy": true, + "codeOfConduct": true, + } + "accomodation": { + "travel": 0 + }, + } } } diff --git a/scripts/batch_scripts.py b/scripts/batch_scripts.py index a93dc290..387aa51b 100644 --- a/scripts/batch_scripts.py +++ b/scripts/batch_scripts.py @@ -393,12 +393,12 @@ def getHackers(): 'First Name': result['accountId']['firstName'], 'Last Name': result['accountId']['lastName'], 'Email': result['accountId']['email'], - 'School': result['school'], - 'Degree': result['degree'], - 'Graduation Year': result['graduationYear'], - 'Job Interest': result['application']['jobInterest'], - 'Github': result['application']['portfolioURL']['github'], - 'LinkedIn': result['application']['portfolioURL']['linkedIn'], + 'School': result['application']['general']['school'], + 'Degree': result['application']['general']['degree'], + 'Graduation Year': result['application']['general']['graduationYear'], + 'Job Interest': result['application']['general']['jobInterest'], + 'Github': result['application']['general']['URL']['github'], + 'LinkedIn': result['application']['general']['URL']['linkedIn'], }) diff --git a/services/account.service.js b/services/account.service.js index 0d633232..b11bd79f 100644 --- a/services/account.service.js +++ b/services/account.service.js @@ -14,7 +14,6 @@ function findById(id) { const query = { _id: id }; - return Account.findById( query, logger.queryCallbackFactory(TAG, "account", query) @@ -76,7 +75,7 @@ function findOne(query) { /** * @function addOneAccount - * @param {{_id: ObjectId, firstName: string, lastName: string, email: string, password: string, dietaryRestrictions: string, shirtSize: string}} accountDetails + * @param {{_id: ObjectId, firstName: string, lastName: string, email: string, password: string}} accountDetails * @return {Promise} The promise will resolve to the account object if save is successful. * @description Adds a new account to database. */ @@ -91,7 +90,7 @@ function addOneAccount(accountDetails) { /** * @function updateOne * @param {ObjectId} id - * @param {{_id?: ObjectId, firstName?: string, lastName?: string, email?: string, password?: string, dietaryRestrictions?: string, shirtSize?: string}} accountDetails + * @param {{_id?: ObjectId, firstName?: string, lastName?: string, email?: string, password?: string}} accountDetails * @return {DocumentQuery} The document query will resolve to either account or null. * @description Changes account information to the specified information in accountDetails. */ diff --git a/services/hacker.service.js b/services/hacker.service.js index 9fb2315d..8e0ea501 100644 --- a/services/hacker.service.js +++ b/services/hacker.service.js @@ -10,7 +10,7 @@ const QRCode = require("qrcode"); /** * @function createHacker - * @param {{_id: ObjectId, accountId: ObjectId, school: string, gender: string, needsBus: boolean, application: {Object}}} hackerDetails + * @param {{_id: ObjectId, accountId: ObjectId, application: {Object}}} hackerDetails * @return {Promise} The promise will resolve to a hacker object if save is successful. * @description Adds a new hacker to database. */ @@ -25,7 +25,7 @@ function createHacker(hackerDetails) { /** * @function updateOne * @param {ObjectId} id - * @param {{_id?: ObjectId, accountId?: ObjectId, school?: string, gender?: string, needsBus?: boolean, application?: {Object}, teamId?: ObjectId}} hackerDetails + * @param {{_id?: ObjectId, accountId?: ObjectId, application?: {Object}, teamId?: ObjectId}} hackerDetails * @return {DocumentQuery} The document query will resolve to hacker or null. * @description Update an account specified by its mongoId with information specified by hackerDetails. */ @@ -84,7 +84,6 @@ async function findIds(queries) { */ function findByAccountId(accountId) { const TAG = `[ Hacker Service # findByAccountId ]:`; - const query = { accountId: accountId }; @@ -138,10 +137,10 @@ function getStats(hackers) { school: {}, degree: {}, gender: {}, - needsBus: {}, + travel: {}, ethnicity: {}, jobInterest: {}, - major: {}, + fieldOfStudy: {}, graduationYear: {}, dietaryRestrictions: {}, shirtSize: {}, @@ -157,39 +156,46 @@ function getStats(hackers) { stats.status[hacker.status] = stats.status[hacker.status] ? stats.status[hacker.status] + 1 : 1; - stats.school[hacker.school] = stats.school[hacker.school] - ? stats.school[hacker.school] + 1 + stats.school[hacker.application.general.school] = stats.school[ + hacker.application.general.school + ] + ? stats.school[hacker.application.general.school] + 1 : 1; - stats.degree[hacker.degree] = stats.degree[hacker.degree] - ? stats.degree[hacker.degree] + 1 + stats.degree[hacker.application.general.degree] = stats.degree[ + hacker.application.general.degree + ] + ? stats.degree[hacker.application.general.degree] + 1 : 1; - stats.gender[hacker.gender] = stats.gender[hacker.gender] - ? stats.gender[hacker.gender] + 1 + stats.gender[hacker.accountId.gender] = stats.gender[ + hacker.accountId.gender + ] + ? stats.gender[hacker.accountId.gender] + 1 : 1; - stats.needsBus[hacker.needsBus] = stats.needsBus[hacker.needsBus] - ? stats.needsBus[hacker.needsBus] + 1 + stats.travel[hacker.application.accommodation.travel] = stats.travel[ + hacker.application.accommodation.travel + ] + ? stats.travel[hacker.application.accommodation.travel] + 1 : 1; - for (const ethnicity of hacker.ethnicity) { + for (const ethnicity of hacker.application.other.ethnicity) { stats.ethnicity[ethnicity] = stats.ethnicity[ethnicity] ? stats.ethnicity[ethnicity] + 1 : 1; } - stats.jobInterest[hacker.application.jobInterest] = stats.jobInterest[ - hacker.application.jobInterest - ] - ? stats.jobInterest[hacker.application.jobInterest] + 1 + stats.jobInterest[hacker.application.general.jobInterest] = stats + .jobInterest[hacker.application.general.jobInterest] + ? stats.jobInterest[hacker.application.general.jobInterest] + 1 : 1; - stats.major[hacker.major] = stats.major[hacker.major] - ? stats.major[hacker.major] + 1 + stats.fieldOfStudy[hacker.application.general.fieldOfStudy] = stats + .fieldOfStudy[hacker.application.general.fieldOfStudy] + ? stats.fieldOfStudy[hacker.application.general.fieldOfStudy] + 1 : 1; - stats.graduationYear[hacker.graduationYear] = stats.graduationYear[ - hacker.graduationYear - ] - ? stats.graduationYear[hacker.graduationYear] + 1 + stats.graduationYear[hacker.application.general.graduationYear] = stats + .graduationYear[hacker.application.general.graduationYear] + ? stats.graduationYear[hacker.application.general.graduationYear] + + 1 : 1; - for (const dietaryRestrictions of hacker.accountId .dietaryRestrictions) { stats.dietaryRestrictions[dietaryRestrictions] = stats @@ -197,10 +203,9 @@ function getStats(hackers) { ? stats.dietaryRestrictions[dietaryRestrictions] + 1 : 1; } - stats.shirtSize[hacker.accountId.shirtSize] = stats.shirtSize[ - hacker.accountId.shirtSize - ] - ? stats.shirtSize[hacker.accountId.shirtSize] + 1 + stats.shirtSize[hacker.application.accommodation.shirtSize] = stats + .shirtSize[hacker.application.accommodation.shirtSize] + ? stats.shirtSize[hacker.application.accommodation.shirtSize] + 1 : 1; const age = hacker.accountId.getAge(); stats.age[age] = stats.age[age] ? stats.age[age] + 1 : 1; diff --git a/tests/account.test.js b/tests/account.test.js index 6726b581..467f4101 100644 --- a/tests/account.test.js +++ b/tests/account.test.js @@ -364,7 +364,7 @@ describe("PATCH update account", function() { }); // fail due to lack of authorization - it("should Fail to update an account due to lack of authorization", function(done) { + it("should FAIL to update an account due to lack of authorization", function(done) { util.auth.login(agent, teamHackerAccount0, (error) => { if (error) { agent.close(); diff --git a/tests/hacker.test.js b/tests/hacker.test.js index e7ad8626..4ad47f27 100644 --- a/tests/hacker.test.js +++ b/tests/hacker.test.js @@ -29,7 +29,6 @@ const volunteerAccount0 = util.account.volunteerAccounts.stored[0]; const newHackerAccount0 = util.account.hackerAccounts.new[0]; const newHacker0 = util.hacker.newHacker0; const invalidHacker0 = util.hacker.invalidHacker0; - const newHacker1 = util.hacker.newHacker1; const noTeamHackerAccount0 = util.account.hackerAccounts.stored.noTeam[0]; @@ -377,6 +376,7 @@ describe("POST create hacker", function() { util.auth.login(agent, Admin0, (error) => { if (error) { agent.close(); + return done(error); } return agent @@ -401,7 +401,8 @@ describe("POST create hacker", function() { delete hacker.id; chai.assert.equal( JSON.stringify(res.body.data), - JSON.stringify(hacker) + JSON.stringify(hacker), + "objects do not match" ); done(); @@ -445,9 +446,9 @@ describe("POST create hacker", function() { }); }); - // should FAIL due to 'false' on code of conduct + // should fail due to 'false' on code of conduct it("should FAIL if the new hacker does not accept code of conduct", function(done) { - util.auth.login(agent, newHacker0, (error) => { + util.auth.login(agent, newHackerAccount0, (error) => { if (error) { agent.close(); return done(error); @@ -462,10 +463,18 @@ describe("POST create hacker", function() { res.body.should.have.property("message"); res.body.message.should.equal("Validation failed"); res.body.should.have.property("data"); - res.body.data.should.have.property("codeOfConduct"); - res.body.data.codeOfConduct.msg.should.equal( - "Must be equal to true" + res.body.data.should.have.property( + "application.other.privacyPolicy" ); + res.body.data[ + "application.other.privacyPolicy" + ].msg.should.equal("Must be equal to true"); + res.body.data.should.have.property( + "application.other.codeOfConduct" + ); + res.body.data[ + "application.other.codeOfConduct" + ].msg.should.equal("Must be equal to true"); done(); }); }); @@ -529,8 +538,37 @@ describe("POST create hacker", function() { .type("application/json") .send(invalidHacker1) .end(function(err, res) { - // replace with actual test comparisons after error handler is implemented res.should.have.status(422); + res.should.be.json; + res.body.should.have.property("message"); + res.body.message.should.equal("Validation failed"); + res.body.should.have.property("data"); + res.body.data.should.have.property("accountId"); + res.body.data.accountId.should.have.property("msg"); + res.body.data.accountId.msg.should.equal("Invalid mongoID"); + res.body.data.should.have.property( + "application.general.school" + ); + res.body.data[ + "application.general.school" + ].should.have.property("msg"); + res.body.data[ + "application.general.school" + ].msg.should.equal("name must exist"); + res.body.data.should.have.property( + "application.general.jobInterest" + ); + res.body.data[ + "application.general.jobInterest" + ].should.have.property("msg"); + + res.body.data[ + "application.general.jobInterest" + ].should.have.property("msg"); + res.body.data[ + "application.general.jobInterest" + ].msg.should.equal("The value must be part of the enum"); + done(); }); }); @@ -544,7 +582,7 @@ describe("PATCH update one hacker", function() { .patch(`/api/hacker/${TeamHacker0._id}`) .type("application/json") .send({ - gender: "Other" + application: TeamHacker0.application }) .end(function(err, res) { res.should.have.status(401); @@ -555,12 +593,12 @@ describe("PATCH update one hacker", function() { }); }); - it("should FAIL to accept a hacker on /api/hacker/accept/:id due to authentication", function (done) { + it("should FAIL to accept a hacker on /api/hacker/accept/:id due to authentication", function(done) { chai.request(server.app) .patch(`/api/hacker/accept/${TeamHacker0._id}`) .type("application/json") .send() - .end(function (err, res) { + .end(function(err, res) { res.should.have.status(401); res.should.be.json; res.body.should.have.property("message"); @@ -570,7 +608,7 @@ describe("PATCH update one hacker", function() { }); // should FAIL due to authorization - it("should FAIL to accept hacker info due to lack of authorization on /api/hacker/accept/:id", function (done) { + it("should FAIL to accept hacker info due to lack of authorization on /api/hacker/accept/:id", function(done) { util.auth.login(agent, noTeamHackerAccount0, (error) => { if (error) { agent.close(); @@ -580,11 +618,13 @@ describe("PATCH update one hacker", function() { .patch(`/api/hacker/accept/${TeamHacker0._id}`) .type("application/json") .send() - .end(function (err, res) { + .end(function(err, res) { res.should.have.status(403); res.should.be.json; res.body.should.have.property("message"); - res.body.message.should.equal(Constants.Error.AUTH_403_MESSAGE); + res.body.message.should.equal( + Constants.Error.AUTH_403_MESSAGE + ); res.body.should.have.property("data"); done(); @@ -592,7 +632,7 @@ describe("PATCH update one hacker", function() { }); }); - it("should FAIL to accept an invalid hacker's info on /api/hacker/accept/:id", function (done) { + it("should FAIL to accept an invalid hacker's info on /api/hacker/accept/:id", function(done) { util.auth.login(agent, Admin0, (error) => { if (error) { agent.close(); @@ -602,11 +642,13 @@ describe("PATCH update one hacker", function() { .patch(`/api/hacker/accept/${invalidHacker1._id}`) .type("application/json") .send() - .end(function (err, res) { + .end(function(err, res) { res.should.have.status(404); res.should.be.json; res.body.should.have.property("message"); - res.body.message.should.equal(Constants.Error.HACKER_404_MESSAGE); + res.body.message.should.equal( + Constants.Error.HACKER_404_MESSAGE + ); res.body.should.have.property("data"); done(); @@ -614,7 +656,7 @@ describe("PATCH update one hacker", function() { }); }); - it("should SUCCEED and accept a hacker on /api/hacker/accept/:id as an Admin", function (done) { + it("should SUCCEED and accept a hacker on /api/hacker/accept/:id as an Admin", function(done) { util.auth.login(agent, Admin0, (error) => { if (error) { agent.close(); @@ -624,15 +666,20 @@ describe("PATCH update one hacker", function() { .patch(`/api/hacker/accept/${TeamHacker0._id}`) .type("application/json") .send() - .end(function (err, res) { + .end(function(err, res) { res.should.have.status(200); res.should.be.json; res.body.should.have.property("message"); - res.body.message.should.equal(Constants.Success.HACKER_UPDATE); + res.body.message.should.equal( + Constants.Success.HACKER_UPDATE + ); res.body.should.have.property("data"); - chai.assert.equal(JSON.stringify(res.body.data), JSON.stringify({ - status: "Accepted" - })); + chai.assert.equal( + JSON.stringify(res.body.data), + JSON.stringify({ + status: "Accepted" + }) + ); done(); }); }); @@ -645,11 +692,23 @@ describe("PATCH update one hacker", function() { agent.close(); return done(error); } + let app = TeamHacker0.application; + app.accommodation.shirtSize = "M"; return agent .patch(`/api/hacker/${TeamHacker0._id}`) .type("application/json") .send({ - gender: "Other" + application: { + general: app.general, + shortAnswer: app.shortAnswer, + other: app.other, + accommodation: { + barriers: app.accommodation.barriers, + impairments: app.accommodation.impairments, + travel: app.accommodation.travel, + shirtSize: "M" + } + } }) .end(function(err, res) { res.should.have.status(200); @@ -659,11 +718,18 @@ describe("PATCH update one hacker", function() { Constants.Success.HACKER_UPDATE ); res.body.should.have.property("data"); + res.body.data.should.have.property("application"); + res.body.data.application.should.have.property( + "accommodation" + ); + res.body.data.application.accommodation.should.have.property( + "shirtSize" + ); chai.assert.equal( - JSON.stringify(res.body.data), - JSON.stringify({ - gender: "Other" - }) + JSON.stringify( + res.body.data.application.accommodation.shirtSize + ), + '"M"' ); done(); }); @@ -784,7 +850,7 @@ describe("PATCH update one hacker", function() { }); }); - // hacker should FAIL to checkin hacker + // hacker should fail to checkin hacker it("should FAIL to check in hacker as a hacker", function(done) { util.auth.login(agent, teamHackerAccount0, (error) => { if (error) { @@ -843,11 +909,22 @@ describe("PATCH update one hacker", function() { agent.close(); return done(error); } + let app = noTeamHacker0.application; return agent .patch(`/api/hacker/${noTeamHacker0._id}`) .type("application/json") .send({ - gender: "Other" + application: { + general: app.general, + shortAnswer: app.shortAnswer, + other: app.other, + accommodation: { + barriers: app.accommodation.barriers, + impairments: app.accommodation.impairments, + travel: app.accommodation.travel, + shirtSize: "M" + } + } }) .end(function(err, res) { res.should.have.status(200); @@ -857,11 +934,18 @@ describe("PATCH update one hacker", function() { Constants.Success.HACKER_UPDATE ); res.body.should.have.property("data"); + res.body.data.should.have.property("application"); + res.body.data.application.should.have.property( + "accommodation" + ); + res.body.data.application.accommodation.should.have.property( + "shirtSize" + ); chai.assert.equal( - JSON.stringify(res.body.data), - JSON.stringify({ - gender: "Other" - }) + JSON.stringify( + res.body.data.application.accommodation.shirtSize + ), + '"M"' ); done(); }); @@ -875,11 +959,22 @@ describe("PATCH update one hacker", function() { agent.close(); return done(error); } + let app = unconfirmedHacker1.application; return agent .patch(`/api/hacker/${unconfirmedHacker1._id}`) .type("application/json") .send({ - gender: "Other" + application: { + general: app.general, + shortAnswer: app.shortAnswer, + other: app.other, + accommodation: { + barriers: app.accommodation.barriers, + impairments: app.accommodation.impairments, + travel: app.accommodation.travel, + shirtSize: "M" + } + } }) .end(function(err, res) { res.should.have.status(403); @@ -894,18 +989,29 @@ describe("PATCH update one hacker", function() { }); }); - // should FAIL due to authorization + // should fail due to authorization it("should Fail to update hacker info due to lack of authorization", function(done) { util.auth.login(agent, noTeamHackerAccount0, (error) => { if (error) { agent.close(); return done(error); } + let app = TeamHacker0.application; return agent .patch(`/api/hacker/${TeamHacker0._id}`) .type("application/json") .send({ - gender: "Other" + application: { + general: app.general, + shortAnswer: app.shortAnswer, + other: app.other, + accommodation: { + barriers: app.accommodation.barriers, + impairments: app.accommodation.impairments, + travel: app.accommodation.travel, + shirtSize: "M" + } + } }) .end(function(err, res) { res.should.have.status(403); @@ -922,7 +1028,7 @@ describe("PATCH update one hacker", function() { }); // fail due to lack of hacker - it("should FAIL to change an invalid hacker's info", function(done) { + it("should fail to change an invalid hacker's info", function(done) { util.auth.login(agent, Admin0, (error) => { if (error) { agent.close(); @@ -1081,7 +1187,7 @@ describe("PATCH update one hacker", function() { }); // fail for a hacker that's not accepted - it("should FAIL for hacker trying to confirm someone else", function(done) { + it("should fail for hacker trying to confirm someone else", function(done) { util.auth.login(agent, util.account.waitlistedHacker0, (error) => { if (error) { agent.close(); @@ -1110,6 +1216,7 @@ describe("PATCH update one hacker", function() { }); }); }); + describe("POST add a hacker resume", function() { it("It should SUCCEED and upload a resume for a hacker", function(done) { //this takes a lot of time for some reason @@ -1196,10 +1303,10 @@ describe("GET Hacker stats", function() { res.body.data.stats.should.have.property("school"); res.body.data.stats.should.have.property("degree"); res.body.data.stats.should.have.property("gender"); - res.body.data.stats.should.have.property("needsBus"); + res.body.data.stats.should.have.property("travel"); res.body.data.stats.should.have.property("ethnicity"); res.body.data.stats.should.have.property("jobInterest"); - res.body.data.stats.should.have.property("major"); + res.body.data.stats.should.have.property("fieldOfStudy"); res.body.data.stats.should.have.property("graduationYear"); res.body.data.stats.should.have.property( "dietaryRestrictions" diff --git a/tests/search.service.spec.js b/tests/search.service.spec.js index 50a21494..0495c1a2 100644 --- a/tests/search.service.spec.js +++ b/tests/search.service.spec.js @@ -22,15 +22,15 @@ const util = { const queryToExecute = [ { - param: "gender", + param: "application.general.degree", operation: "equals", - value: "Female" + value: "Undergraduate" } ]; const query2 = [ { - param: "school", + param: "application.general.school", operation: "ne", value: "McGill" } @@ -64,7 +64,7 @@ describe("Searching for hackers", function() { return agent .get("/api/search") .query({ - model: "hacker", + model: "account", q: JSON.stringify(queryToExecute) }) .end(function(err, res) { @@ -88,7 +88,7 @@ describe("Searching for hackers", function() { return agent .get("/api/search") .query({ - model: "hacker", + model: "account", q: JSON.stringify(queryToExecute) }) .end(function(err, res) { @@ -101,7 +101,7 @@ describe("Searching for hackers", function() { }); }); }); - it("Should return all female hackers", function(done) { + it("Should return all undergraduate hackers", function(done) { util.auth.login(agent, Admin0, (error) => { if (error) { agent.close(); @@ -116,11 +116,12 @@ describe("Searching for hackers", function() { .end(function(err, res) { res.should.have.status(200); res.body.should.have.property("data"); - res.body.data.should.have.length(7); + res.body.data.should.have.length(2); done(); }); }); }); + it("Should return an error as hackers don't have password stored", function(done) { util.auth.login(agent, Admin0, (error) => { if (error) { @@ -303,7 +304,7 @@ describe("Searching for hackers", function() { .end(function(err, res) { res.should.have.status(200); res.body.should.have.property("data"); - res.body.data.should.have.length(7); + res.body.data.should.have.length(2); res.body.data[0].should.have.property("accountId"); res.body.data[0].accountId.should.have.property("email"); done(); diff --git a/tests/util/account.test.util.js b/tests/util/account.test.util.js index e1500b66..1b624821 100644 --- a/tests/util/account.test.util.js +++ b/tests/util/account.test.util.js @@ -51,6 +51,8 @@ function generateRandomValue(atr) { .toString(36) .replace(/[^a-z]+/g, "") .substr(0, Math.floor(Math.random() * 3 + 2)); + case "gender": + return "Female"; case "email": const email = `abc.def${counters.emailCounter}@blahblah.com`; return email; @@ -69,7 +71,10 @@ function generateRandomValue(atr) { ]; case "gender": // generate random string between length 2 and 10 - return Math.random().toString(36).replace(/[^a-z]+/g, "").substr(0, Math.floor(Math.random() * 9 + 2)); + return Math.random() + .toString(36) + .replace(/[^a-z]+/g, "") + .substr(0, Math.floor(Math.random() * 9 + 2)); case "confirmed": // return false, because if an account is confirmed there should be a document of that account type, // which this does not create @@ -87,7 +92,6 @@ function generateRandomValue(atr) { function createAccount(acc = {}) { incrementCounters(); - const extractedAcc = extractAccountInfo(acc); for (const atr in Account.schema.paths) { @@ -253,6 +257,7 @@ const waitlistedHacker0 = { firstName: "abcd", lastName: "defg3", pronoun: "They/Them", + gender: "Female", email: "waitlisted1@blahblah.com", password: "probsShouldBeHashed2", dietaryRestrictions: ["vegetarian"], @@ -269,6 +274,7 @@ const NonConfirmedAccount1 = { firstName: "LMAO", lastName: "ROFL", pronoun: "Ey/Em", + gender: "Female", email: "notconfirmed1@blahblah.com", password: "probsShouldBeHashed5", dietaryRestrictions: ["something1", "something2"], @@ -283,6 +289,7 @@ const NonConfirmedAccount2 = { _id: mongoose.Types.ObjectId(), firstName: "LMAO", lastName: "ROFL", + gender: "Female", email: "notconfirmed2@blahblah.com", password: "probsShouldBeHashed5", dietaryRestrictions: ["something1", "something2"], diff --git a/tests/util/hacker.test.util.js b/tests/util/hacker.test.util.js index 25ab2c27..3c786b63 100644 --- a/tests/util/hacker.test.util.js +++ b/tests/util/hacker.test.util.js @@ -14,27 +14,39 @@ const TeamHacker0 = { _id: Constants.MongoId.hackerAId, accountId: Util.Account.hackerAccounts.stored.team[0]._id, status: "Confirmed", - school: "University of Blah", - degree: "Masters", - gender: "Male", - needsBus: true, application: { - portfolioURL: { - //gcloud bucket link - resume: "www.gcloud.com/myResume100", - github: "www.github.com/Person1", - dropler: undefined, - personal: "www.person1.com", - linkedIn: "www.linkedin.com/in/Person1", - other: undefined - }, - jobInterest: "Full-time", - skills: ["CSS", "HTML", "JS"] + general: { + school: "University of Blah", + degree: "Masters", + fieldOfStudy: ["EE"], + graduationYear: 2019, + jobInterest: "Full-time", + URL: { + //gcloud bucket link + resume: "www.gcloud.com/myResume100", + github: "www.github.com/Person1", + dribbble: null, + personal: "www.person1.com", + linkedIn: "www.linkedin.com/in/Person1", + other: null + } + }, + shortAnswer: { + skills: ["CSS", "HTML", "JS"], + question1: "a", + question2: "a" + }, + other: { + ethnicity: ["Native American"], + codeOfConduct: true, + privacyPolicy: true + }, + accommodation: { + dietaryRestrictions: ["Gluten-Free"], + shirtSize: "L", + travel: 0 + } }, - ethnicity: ["Native American"], - major: ["EE"], - graduationYear: 2019, - codeOfConduct: true, teamId: Constants.MongoId.team1Id }; @@ -42,27 +54,39 @@ const TeamHacker1 = { _id: Constants.MongoId.hackerDId, accountId: Util.Account.hackerAccounts.stored.team[1]._id, status: "Checked-in", - school: "University of Blah1", - degree: "Masters", - gender: "Female", - needsBus: false, application: { - portfolioURL: { - //gcloud bucket link - resume: "www.gcloud.com/myResume2", - github: "www.github.com/Personasdf", - dropler: undefined, - personal: undefined, - linkedIn: undefined, - other: undefined - }, - jobInterest: "Internship", - skills: ["CSS", "HTML", "JS"] + general: { + school: "University of Blah", + degree: "Masters", + fieldOfStudy: ["EE"], + graduationYear: 2019, + jobInterest: "Internship", + URL: { + //gcloud bucket link + resume: "www.gcloud.com/myResume2", + github: "www.github.com/Personasdf", + dribbble: null, + personal: null, + linkedIn: null, + other: null + } + }, + shortAnswer: { + skills: ["CSS", "HTML", "JS"], + question1: "a", + question2: "a" + }, + other: { + ethnicity: ["European"], + codeOfConduct: true, + privacyPolicy: true + }, + accommodation: { + dietaryRestrictions: ["Gluten-Free"], + shirtSize: "L", + travel: 0 + } }, - ethnicity: ["European"], - major: ["EE"], - graduationYear: 2019, - codeOfConduct: true, teamId: Constants.MongoId.team3Id }; @@ -70,27 +94,39 @@ const TeamHacker2 = { _id: Constants.MongoId.hackerEId, accountId: Util.Account.hackerAccounts.stored.team[2]._id, status: "Waitlisted", - school: "University of Blah1", - degree: "Masters", - gender: "Female", - needsBus: false, application: { - portfolioURL: { - //gcloud bucket link - resume: "www.gcloud.com/myResume2", - github: "www.github.com/Personasdf", - dropler: undefined, - personal: undefined, - linkedIn: undefined, - other: undefined - }, - jobInterest: "Internship", - skills: ["CSS", "HTML", "JS"] + general: { + school: "University of Blah", + degree: "Masters", + fieldOfStudy: ["EE"], + graduationYear: 2019, + jobInterest: "Internship", + URL: { + //gcloud bucket link + resume: "www.gcloud.com/myResume2", + github: "www.github.com/Personasdf", + dribbble: null, + personal: null, + linkedIn: null, + other: null + } + }, + shortAnswer: { + skills: ["CSS", "HTML", "JS"], + question1: "a", + question2: "a" + }, + other: { + ethnicity: ["European"], + codeOfConduct: true, + privacyPolicy: true + }, + accommodation: { + dietaryRestrictions: ["Gluten-Free"], + shirtSize: "L", + travel: 0 + } }, - ethnicity: ["European"], - major: ["EE"], - graduationYear: 2019, - codeOfConduct: true, teamId: Constants.MongoId.team3Id }; @@ -98,27 +134,39 @@ const TeamHacker3 = { _id: Constants.MongoId.hackerFId, accountId: Util.Account.hackerAccounts.stored.team[3]._id, status: "Waitlisted", - school: "University of Blah1", - degree: "Masters", - gender: "Female", - needsBus: false, application: { - portfolioURL: { - //gcloud bucket link - resume: "www.gcloud.com/myResume2", - github: "www.github.com/Personasdf", - dropler: undefined, - personal: undefined, - linkedIn: undefined, - other: undefined - }, - jobInterest: "Internship", - skills: ["CSS", "HTML", "JS"] + general: { + school: "University of Blah", + degree: "Masters", + fieldOfStudy: ["EE"], + graduationYear: 2019, + jobInterest: "Internship", + URL: { + //gcloud bucket link + resume: "www.gcloud.com/myResume2", + github: "www.github.com/Personasdf", + dribbble: null, + personal: null, + linkedIn: null, + other: null + } + }, + shortAnswer: { + skills: ["CSS", "HTML", "JS"], + question1: "a", + question2: "a" + }, + other: { + ethnicity: ["European"], + codeOfConduct: true, + privacyPolicy: true + }, + accommodation: { + dietaryRestrictions: ["Gluten-Free"], + shirtSize: "L", + travel: 0 + } }, - ethnicity: ["European"], - major: ["EE"], - graduationYear: 2019, - codeOfConduct: true, teamId: Constants.MongoId.team3Id }; @@ -126,27 +174,39 @@ const TeamHacker4 = { _id: Constants.MongoId.hackerGId, accountId: Util.Account.hackerAccounts.stored.team[4]._id, status: "Waitlisted", - school: "University of Blah1", - degree: "Masters", - gender: "Female", - needsBus: false, application: { - portfolioURL: { - //gcloud bucket link - resume: "www.gcloud.com/myResume2", - github: "www.github.com/Personasdf", - dropler: undefined, - personal: undefined, - linkedIn: undefined, - other: undefined - }, - jobInterest: "Internship", - skills: ["CSS", "HTML", "JS"] + general: { + school: "University of Blah", + degree: "Masters", + fieldOfStudy: ["EE"], + graduationYear: 2019, + jobInterest: "Internship", + URL: { + //gcloud bucket link + resume: "www.gcloud.com/myResume2", + github: "www.github.com/Personasdf", + dribbble: null, + personal: null, + linkedIn: null, + other: null + } + }, + shortAnswer: { + skills: ["CSS", "HTML", "JS"], + question1: "a", + question2: "a" + }, + other: { + ethnicity: ["European"], + codeOfConduct: true, + privacyPolicy: true + }, + accommodation: { + dietaryRestrictions: ["Gluten-Free"], + shirtSize: "L", + travel: 0 + } }, - ethnicity: ["European"], - major: ["EE"], - graduationYear: 2019, - codeOfConduct: true, teamId: Constants.MongoId.team3Id }; @@ -154,177 +214,264 @@ const NoTeamHacker0 = { _id: Constants.MongoId.hackerBId, accountId: Util.Account.hackerAccounts.stored.noTeam[0]._id, status: "Accepted", - school: "University of Blah1", - degree: "Masters", - gender: "Female", - needsBus: false, application: { - portfolioURL: { - //gcloud bucket link - resume: "www.gcloud.com/myResume1", - github: "www.github.com/Person4", - dropler: undefined, - personal: undefined, - linkedIn: undefined, - other: undefined - }, - jobInterest: "Internship", - skills: ["CSS", "HTML", "JS"] - }, - ethnicity: ["European"], - major: ["EE"], - graduationYear: 2019, - codeOfConduct: true + general: { + school: "University of Blah", + degree: "Masters", + fieldOfStudy: ["EE"], + graduationYear: 2019, + jobInterest: "Internship", + URL: { + //gcloud bucket link + resume: "www.gcloud.com/myResume1", + github: "www.github.com/Person4", + dribbble: null, + personal: null, + linkedIn: null, + other: null + } + }, + shortAnswer: { + skills: ["CSS", "HTML", "JS"], + question1: "a", + question2: "a" + }, + other: { + ethnicity: ["European"], + codeOfConduct: true, + privacyPolicy: true + }, + accommodation: { + dietaryRestrictions: ["Gluten-Free"], + shirtSize: "L", + travel: 0 + } + } }; const newHacker0 = { accountId: Util.Account.hackerAccounts.new[0]._id, - school: "University of ASDF", - degree: "Masters", - gender: "Female", - needsBus: true, application: { - portfolioURL: { - //gcloud bucket link - resume: "www.gcloud.com/myResume100", - github: "www.github.com/Person1", - dropler: undefined, - personal: "www.person1.com", - linkedIn: "www.linkedin.com/in/Person1", - other: undefined - }, - jobInterest: "Full-time", - skills: ["CSS", "HTML", "JS"] - }, - ethnicity: ["Caucasian"], - major: ["EE"], - graduationYear: 2019, - codeOfConduct: true + general: { + school: "University of ASDF", + degree: "Masters", + fieldOfStudy: ["EE"], + graduationYear: 2019, + jobInterest: "Full-time", + URL: { + //gcloud bucket link + resume: "www.gcloud.com/myResume100", + github: "www.github.com/Person1", + dribbble: null, + personal: "www.person1.com", + linkedIn: "www.linkedin.com/in/Person1", + other: null + } + }, + shortAnswer: { + skills: ["CSS", "HTML", "JS"], + question1: "a", + question2: "a" + }, + other: { + ethnicity: ["Caucasian"], + codeOfConduct: true, + privacyPolicy: true + }, + accommodation: { + dietaryRestrictions: ["Gluten-Free"], + shirtSize: "L", + travel: 0 + } + } }; const newHacker1 = { accountId: Util.Account.hackerAccounts.new[1]._id, - school: "University of YIKES", - degree: "PhD", - gender: "Female", - needsBus: true, application: { - portfolioURL: { - //gcloud bucket link - resume: "www.gcloud.com/myResume100", - github: "www.github.com/Person1", - dropler: undefined, - personal: "www.person1.com", - linkedIn: "www.linkedin.com/in/Person1", - other: undefined - }, - jobInterest: "Full-time", - skills: ["CSS", "HTML", "JS"] - }, - ethnicity: ["African American"], - major: ["EE"], - graduationYear: 2019, - codeOfConduct: true + general: { + school: "University of YIKES", + degree: "PhD", + fieldOfStudy: ["EE"], + graduationYear: 2019, + jobInterest: "Full-time", + URL: { + //gcloud bucket link + resume: "www.gcloud.com/myResume100", + github: "www.github.com/Person1", + dribbble: null, + personal: "www.person1.com", + linkedIn: "www.linkedin.com/in/Person1", + other: null + } + }, + shortAnswer: { + skills: ["CSS", "HTML", "JS"], + question1: "a", + question2: "a" + }, + other: { + ethnicity: ["African American"], + codeOfConduct: true, + privacyPolicy: true + }, + accommodation: { + dietaryRestrictions: ["Gluten-Free"], + shirtSize: "L", + travel: 0 + } + } }; -// duplicate of newHack1, but with false for code of conduct +// duplicate of newHack0, but with false for code of conduct const invalidHacker0 = { - accountId: Util.Account.hackerAccounts.invalid[0]._id, - school: "University of ASDF", - degree: "Masters", - gender: "Female", - needsBus: true, + accountId: Util.Account.hackerAccounts.new[0]._id, application: { - portfolioURL: { - //gcloud bucket link - resume: "www.gcloud.com/myResume100", - github: "www.github.com/Person1", - dropler: undefined, - personal: "www.person1.com", - linkedIn: "www.linkedin.com/in/Person1", - other: undefined - }, - jobInterest: "Full-time", - skills: ["CSS", "HTML", "JS"] - }, - ethnicity: ["Caucasian"], - major: ["EE"], - graduationYear: 2019, - codeOfConduct: false + general: { + school: "University of ASDF", + degree: "Masters", + fieldOfStudy: ["EE"], + graduationYear: 2019, + jobInterest: "Full-time", + URL: { + //gcloud bucket link + resume: "www.gcloud.com/myResume100", + github: "www.github.com/Person1", + dribbble: null, + personal: "www.person1.com", + linkedIn: "www.linkedin.com/in/Person1", + other: null + } + }, + shortAnswer: { + skills: ["CSS", "HTML", "JS"], + question1: "a", + question2: "a" + }, + other: { + ethnicity: ["Caucasian"], + // must accept code of conduct to be valid + codeOfConduct: false, + privacyPolicy: false + }, + accommodation: { + dietaryRestrictions: ["Gluten-Free"], + shirtSize: "L", + travel: 0 + } + } }; const invalidHacker1 = { _id: mongoose.Types.ObjectId(), // invalid mongoID accountId: Util.Account.hackerAccounts.invalid[1]._invalidId, - // invalid missing school attribute - degree: "Undersaduate", - gender: "Female", - needsBus: true, application: { - // invalid portflio with no resume - portfolioURL: {}, - // invalid jobInterest - jobInterest: "ASDF" - }, - ethnicity: ["Asian", "Caucasian"], - major: ["CS"], - graduationYear: 2020, - codeOfConduct: true + general: { + // invalid missing school attribute + degree: "Undergraduate", + fieldOfStudy: ["EE"], + graduationYear: 2020, + // invalid job interest + jobInterest: "ASDF", + URL: { + // invalid URL links with no resume + } + }, + shortAnswer: { + skills: ["CSS", "HTML", "JS"], + question1: "a", + question2: "a" + }, + other: { + ethnicity: ["Caucasian"], + codeOfConduct: true, + privacyPolicy: true + }, + accommodation: { + dietaryRestrictions: ["Gluten-Free"], + shirtSize: "L", + travel: 0 + } + } }; const duplicateAccountLinkHacker0 = { _id: mongoose.Types.ObjectId(), accountId: Util.Account.hackerAccounts.stored.team[0]._id, status: "Applied", - school: "University of Blah", - degree: "Undergraduate", - gender: "Male", - needsBus: true, application: { - portfolioURL: { - //gcloud bucket link - resume: "www.gcloud.com/myResume100", - github: "www.github.com/Person1", - dropler: undefined, - personal: "www.person1.com", - linkedIn: "www.linkedin.com/in/Person1", - other: undefined - }, - jobInterest: "Full-time", - skills: ["CSS", "HTML", "JS"] - }, - ethnicity: ["Caucasian"], - major: ["CS"], - graduationYear: 2019, - codeOfConduct: true + general: { + school: "University of Blah", + degree: "Undergraduate", + fieldOfStudy: ["CS"], + graduationYear: 2019, + jobInterest: "Full-time", + URL: { + //gcloud bucket link + resume: "www.gcloud.com/myResume100", + github: "www.github.com/Person1", + dribbble: null, + personal: "www.person1.com", + linkedIn: "www.linkedin.com/in/Person1", + other: null + } + }, + shortAnswer: { + skills: ["CSS", "HTML", "JS"], + question1: "a", + question2: "a" + }, + other: { + ethnicity: ["Caucasian"], + codeOfConduct: true, + privacyPolicy: true + }, + accommodation: { + dietaryRestrictions: ["Gluten-Free"], + shirtSize: "L", + travel: 0 + } + } }; const waitlistedHacker0 = { _id: Constants.MongoId.hackerCId, accountId: Util.Account.waitlistedHacker0._id, status: "Waitlisted", - school: "University of Blah1", - degree: "Masters", - gender: "Female", - needsBus: false, application: { - portfolioURL: { - //gcloud bucket link - resume: "www.gcloud.com/myResume2", - github: "www.github.com/Personasdf", - dropler: undefined, - personal: undefined, - linkedIn: undefined, - other: undefined - }, - jobInterest: "Internship", - skills: ["CSS", "HTML", "JS"] + general: { + school: "University of Blah", + degree: "Masters", + fieldOfStudy: ["EE"], + graduationYear: 2019, + jobInterest: "Intership", + URL: { + //gcloud bucket link + resume: "www.gcloud.com/myResume2", + github: "www.github.com/Personasdf", + dribbble: null, + personal: null, + linkedIn: null, + other: null + } + }, + shortAnswer: { + skills: ["CSS", "HTML", "JS"], + question1: "a", + question2: "a" + }, + other: { + ethnicity: ["European"], + codeOfConduct: true, + privacyPolicy: true + }, + accommodation: { + dietaryRestrictions: ["Gluten-Free"], + shirtSize: "L", + travel: 0 + } }, - ethnicity: ["European"], - major: ["EE"], - graduationYear: 2019, - codeOfConduct: true, teamId: Constants.MongoId.team2Id }; @@ -332,54 +479,78 @@ const unconfirmedAccountHacker0 = { _id: Constants.MongoId.hackerCId, accountId: Util.Account.NonConfirmedAccount3._id, status: "Waitlisted", - school: "University of Blah1", - degree: "Masters", - gender: "Female", - needsBus: false, application: { - portfolioURL: { - //gcloud bucket link - resume: "www.gcloud.com/myResume123", - github: "www.github.com/Personasdf", - dropler: undefined, - personal: undefined, - linkedIn: undefined, - other: undefined - }, - jobInterest: "Internship", - skills: ["CSS", "HTML", "JS"] - }, - ethnicity: ["European"], - major: ["EE"], - graduationYear: 2019, - codeOfConduct: true + general: { + school: "University of Blah1", + degree: "Masters", + fieldOfStudy: ["EE"], + graduationYear: 2019, + jobInterest: "Internship", + URL: { + //gcloud bucket link + resume: "www.gcloud.com/myResume123", + github: "www.github.com/Personasdf", + dribbble: null, + personal: null, + linkedIn: null, + other: null + } + }, + shortAnswer: { + skills: ["CSS", "HTML", "JS"], + question1: "a", + question2: "a" + }, + other: { + ethnicity: ["European"], + codeOfConduct: true, + privacyPolicy: true + }, + accommodation: { + dietaryRestrictions: ["Gluten-Free"], + shirtSize: "L", + travel: 0 + } + } }; const unconfirmedAccountHacker1 = { _id: Constants.MongoId.hackerHId, accountId: Util.Account.hackerAccounts.stored.unconfirmed[0]._id, status: "Accepted", - school: "University of Blah2", - degree: "Underggraduate", - gender: "Female", - needsBus: false, application: { - portfolioURL: { - //gcloud bucket link - resume: "www.gcloud.com/myResume123", - github: "www.github.com/Personasdf", - dropler: undefined, - personal: undefined, - linkedIn: undefined, - other: undefined - }, - jobInterest: "Internship", - skills: ["CSS", "HTML", "JS"] - }, - ethnicity: ["European"], - major: ["EE"], - graduationYear: 2019, - codeOfConduct: true + general: { + school: "University of Blah2", + degree: "Undergraduate", + fieldOfStudy: ["EE"], + graduationYear: 2019, + jobInterest: "Internship", + URL: { + //gcloud bucket link + resume: "www.gcloud.com/myResume123", + github: "www.github.com/Personasdf", + dropler: null, + personal: null, + linkedIn: null, + other: null + } + }, + shortAnswer: { + skills: ["CSS", "HTML", "JS"], + question1: "a", + question2: "a" + }, + other: { + ethnicity: ["European"], + codeOfConduct: true, + privacyPolicy: true + }, + accommodation: { + dietaryRestrictions: ["Gluten-Free"], + shirtSize: "L", + travel: 0 + } + } }; const Hackers = [