Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions constants/general.constant.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ const SPONSOR_T5 = "SponsorT5";
// Enums (must match with frontend)
const JOB_INTERESTS = ["Internship", "Full Time", "None"];
const SHIRT_SIZES = ["XS", "S", "M", "L", "XL", "XXL"];
const HACKATHONS_COUNT = ["0", "1", "2", "3", "4", "5+"];

const ROLE_CATEGORIES = {
SELF: ":self",
Expand Down Expand Up @@ -189,6 +190,7 @@ module.exports = {
REQUEST_TYPES: REQUEST_TYPES,
JOB_INTERESTS: JOB_INTERESTS,
SHIRT_SIZES: SHIRT_SIZES,
HACKATHONS_COUNT: HACKATHONS_COUNT,
USER_TYPES: USER_TYPES,
SPONSOR_TIERS: SPONSOR_TIERS,
EXTENDED_USER_TYPES: EXTENDED_USER_TYPES,
Expand Down
12 changes: 6 additions & 6 deletions docs/api/api_data.js

Large diffs are not rendered by default.

4,144 changes: 4,143 additions & 1 deletion docs/api/api_data.json

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions middlewares/validators/hacker.validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,12 @@ module.exports = {
"application.shortAnswer.question2",
false
),
VALIDATOR.enumValidator(
"body",
"application.shortAnswer.previousHackathons",
Constants.HACKATHONS_COUNT,
false
),

VALIDATOR.alphaArrayValidator(
"body",
Expand Down Expand Up @@ -216,6 +222,12 @@ module.exports = {
"application.shortAnswer.question2",
false
),
VALIDATOR.enumValidator(
"body",
"application.shortAnswer.previousHackathons",
Constants.HACKATHONS_COUNT,
false
),

VALIDATOR.alphaArrayValidator(
"body",
Expand Down
16 changes: 15 additions & 1 deletion middlewares/validators/validator.helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,7 @@ function applicationValidator(fieldLocation, fieldname, optional = true) {
shortAnswer: false,
question1: false,
question2: false,
previousHackathons: false,
accommodation: false,
shirtSize: false,
other: false,
Expand Down Expand Up @@ -425,6 +426,9 @@ function applicationValidator(fieldLocation, fieldname, optional = true) {
hasValid.question2 = app.shortAnswer.hasOwnProperty(
"question2"
);
hasValid.previousHackathons = app.shortAnswer.hasOwnProperty(
"previousHackathons"
);
}
hasValid.accommodation = app.hasOwnProperty("accommodation");
if (hasValid.accommodation) {
Expand Down Expand Up @@ -472,6 +476,9 @@ function applicationValidator(fieldLocation, fieldname, optional = true) {
// hasValid.question2 =
// !!app.shortAnswer.question2 &&
// typeof app.shortAnswer.question2 === "string";
// hasValid.previousHackathons =
// !!app.shortAnswer.previousHackathons &&
// typeof app.shortAnswer.previousHackathons === "string";
// hasValid.team =
// !app.team || mongoose.Types.ObjectId.isValid(app.team);

Expand Down Expand Up @@ -525,6 +532,9 @@ function applicationValidator(fieldLocation, fieldname, optional = true) {
hasValid.question2 = app.shortAnswer.hasOwnProperty(
"question2"
);
hasValid.previousHackathons = app.shortAnswer.hasOwnProperty(
"previousHackathons"
);
}
hasValid.accommodation = app.hasOwnProperty("accommodation");
if (hasValid.accommodation) {
Expand Down Expand Up @@ -572,6 +582,9 @@ function applicationValidator(fieldLocation, fieldname, optional = true) {
// hasValid.question2 =
// !!app.shortAnswer.question2 &&
// typeof app.shortAnswer.question2 === "string";
// hasValid.previousHackathons =
// !!app.shortAnswer.previousHackathons &&
// typeof app.shortAnswer.previousHackathons === "string";
// hasValid.team =
// !app.team || mongoose.Types.ObjectId.isValid(app.team);
return (
Expand All @@ -585,6 +598,7 @@ function applicationValidator(fieldLocation, fieldname, optional = true) {
hasValid.shortAnswer &&
hasValid.question1 &&
hasValid.question2 &&
hasValid.previousHackathons &&
hasValid.accommodation &&
hasValid.shirtSize &&
hasValid.other &&
Expand Down Expand Up @@ -777,7 +791,7 @@ function searchSortValidator(fieldLocation, fieldName) {
} else {
return false;
}
if (!!model.searchableField(value)) {
if (model.searchableField(value)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this a boolean cast? !! is odd in an if, should be casting already, just want to make sure we don't break anything here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure, i think the lint took it off by itself, should i restore it to !!?

let sortOrder = param("sort", "Sorting order not found");
if (!sortOrder.equals("asc") || !sortOrder.equals("desc")) {
return false;
Expand Down
8 changes: 7 additions & 1 deletion models/hacker.model.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@ const HackerSchema = new mongoose.Schema({
type: String,
default: "",
required: true
},
previousHackathons: {
type: String,
enum: Constants.HACKATHONS_COUNT,
required: true
}
},
other: {
Expand Down Expand Up @@ -147,7 +152,8 @@ HackerSchema.methods.isApplicationComplete = function() {
const jobInterestDone = !!hs.application.general.jobInterest;
const question1Done = !!hs.application.shortAnswer.question1;
const question2Done = !!hs.application.shortAnswer.question2;
return portfolioDone && jobInterestDone && question1Done && question2Done;
const previousHackathonsDone = !!hs.application.shortAnswer.previousHackathons;
return portfolioDone && jobInterestDone && question1Done && question2Done && previousHackathonsDone;
};

/**
Expand Down
6 changes: 6 additions & 0 deletions routes/api/hacker.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ module.exports = {
"skills":["Javascript","Typescript"],
"question1": "I love McHacks",
"question2":"Pls accept me",
"previousHackathons": "5+",
"comments":"hi!",
},
"other:" {
Expand Down Expand Up @@ -158,6 +159,7 @@ module.exports = {
"skills":["Javascript","Typescript"],
"question1": "I love McHacks",
"question2":"Pls accept me",
"previousHackathons": "5+",
"comments":"hi!",
},
"other:" {
Expand Down Expand Up @@ -447,6 +449,7 @@ module.exports = {
"skills":["Javascript","Typescript"],
"question1": "I love McHacks",
"question2":"Pls accept me",
"previousHackathons": "5+",
"comments":"hi!",
},
"other:" {
Expand Down Expand Up @@ -489,6 +492,7 @@ module.exports = {
"skills":["Javascript","Typescript"],
"question1": "I love McHacks",
"question2":"Pls accept me",
"previousHackathons": "5+",
"comments":"hi!",
},
"other:" {
Expand Down Expand Up @@ -560,6 +564,7 @@ module.exports = {
"skills":["Javascript","Typescript"],
"question1": "I love McHacks",
"question2":"Pls accept me",
"previousHackathons": "5+",
"comments":"hi!",
},
"other:" {
Expand Down Expand Up @@ -627,6 +632,7 @@ module.exports = {
"skills":["Javascript","Typescript"],
"question1": "I love McHacks",
"question2":"Pls accept me",
"previousHackathons": "5+",
"comments":"hi!",
},
"other:" {
Expand Down
45 changes: 30 additions & 15 deletions tests/util/hacker.test.util.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ const TeamHacker0 = {
shortAnswer: {
skills: ["CSS", "HTML", "JS"],
question1: "a",
question2: "a"
question2: "a",
previousHackathons: "1"
},
other: {
ethnicity: ["Native American"],
Expand Down Expand Up @@ -74,7 +75,8 @@ const TeamHacker1 = {
shortAnswer: {
skills: ["CSS", "HTML", "JS"],
question1: "a",
question2: "a"
question2: "a",
previousHackathons: "2"
},
other: {
ethnicity: ["European"],
Expand Down Expand Up @@ -114,7 +116,8 @@ const TeamHacker2 = {
shortAnswer: {
skills: ["CSS", "HTML", "JS"],
question1: "a",
question2: "a"
question2: "a",
previousHackathons: "3"
},
other: {
ethnicity: ["European"],
Expand Down Expand Up @@ -154,7 +157,8 @@ const TeamHacker3 = {
shortAnswer: {
skills: ["CSS", "HTML", "JS"],
question1: "a",
question2: "a"
question2: "a",
previousHackathons: "4"
},
other: {
ethnicity: ["European"],
Expand Down Expand Up @@ -194,7 +198,8 @@ const TeamHacker4 = {
shortAnswer: {
skills: ["CSS", "HTML", "JS"],
question1: "a",
question2: "a"
question2: "a",
previousHackathons: "5+"
},
other: {
ethnicity: ["European"],
Expand Down Expand Up @@ -234,7 +239,8 @@ const NoTeamHacker0 = {
shortAnswer: {
skills: ["CSS", "HTML", "JS"],
question1: "a",
question2: "a"
question2: "a",
previousHackathons: "1"
},
other: {
ethnicity: ["European"],
Expand Down Expand Up @@ -271,7 +277,8 @@ const newHacker0 = {
shortAnswer: {
skills: ["CSS", "HTML", "JS"],
question1: "a",
question2: "a"
question2: "a",
previousHackathons: "2"
},
other: {
ethnicity: ["Caucasian"],
Expand Down Expand Up @@ -308,7 +315,8 @@ const newHacker1 = {
shortAnswer: {
skills: ["CSS", "HTML", "JS"],
question1: "a",
question2: "a"
question2: "a",
previousHackathons: "3"
},
other: {
ethnicity: ["African American"],
Expand Down Expand Up @@ -346,7 +354,8 @@ const invalidHacker0 = {
shortAnswer: {
skills: ["CSS", "HTML", "JS"],
question1: "a",
question2: "a"
question2: "a",
previousHackathons: "4"
},
other: {
ethnicity: ["Caucasian"],
Expand Down Expand Up @@ -381,7 +390,8 @@ const invalidHacker1 = {
shortAnswer: {
skills: ["CSS", "HTML", "JS"],
question1: "a",
question2: "a"
question2: "a",
previousHackathons: "5+"
},
other: {
ethnicity: ["Caucasian"],
Expand Down Expand Up @@ -419,7 +429,8 @@ const invalidHacker2 = {
shortAnswer: {
skills: ["CSS", "HTML", "JS"],
question1: "a",
question2: "a"
question2: "a",
previousHackathons: "1"
},
other: {
ethnicity: ["Caucasian"],
Expand Down Expand Up @@ -459,7 +470,8 @@ const duplicateAccountLinkHacker0 = {
shortAnswer: {
skills: ["CSS", "HTML", "JS"],
question1: "a",
question2: "a"
question2: "a",
previousHackathons: "2"
},
other: {
ethnicity: ["Caucasian"],
Expand Down Expand Up @@ -498,7 +510,8 @@ const waitlistedHacker0 = {
shortAnswer: {
skills: ["CSS", "HTML", "JS"],
question1: "a",
question2: "a"
question2: "a",
previousHackathons: "3"
},
other: {
ethnicity: ["European"],
Expand Down Expand Up @@ -538,7 +551,8 @@ const unconfirmedAccountHacker0 = {
shortAnswer: {
skills: ["CSS", "HTML", "JS"],
question1: "a",
question2: "a"
question2: "a",
previousHackathons: "4"
},
other: {
ethnicity: ["European"],
Expand Down Expand Up @@ -577,7 +591,8 @@ const unconfirmedAccountHacker1 = {
shortAnswer: {
skills: ["CSS", "HTML", "JS"],
question1: "a",
question2: "a"
question2: "a",
previousHackathons: "5+"
},
other: {
ethnicity: ["European"],
Expand Down