Skip to content

Commit 61266c2

Browse files
Tony9984logan-r
andauthored
feat: add previous hackathons field to application (#670)
* feat: add previous hackathons field to model, update tests * fix: restore pushed package.json changes * Fix package.json Co-authored-by: Logan Ralston <logan.ralston@mail.mcgill.ca>
1 parent e4523fc commit 61266c2

File tree

8 files changed

+4221
-24
lines changed

8 files changed

+4221
-24
lines changed

constants/general.constant.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ const SPONSOR_T5 = "SponsorT5";
7676
// Enums (must match with frontend)
7777
const JOB_INTERESTS = ["Internship", "Full Time", "None"];
7878
const SHIRT_SIZES = ["XS", "S", "M", "L", "XL", "XXL"];
79+
const HACKATHONS_COUNT = ["0", "1", "2", "3", "4", "5+"];
7980

8081
const ROLE_CATEGORIES = {
8182
SELF: ":self",
@@ -189,6 +190,7 @@ module.exports = {
189190
REQUEST_TYPES: REQUEST_TYPES,
190191
JOB_INTERESTS: JOB_INTERESTS,
191192
SHIRT_SIZES: SHIRT_SIZES,
193+
HACKATHONS_COUNT: HACKATHONS_COUNT,
192194
USER_TYPES: USER_TYPES,
193195
SPONSOR_TIERS: SPONSOR_TIERS,
194196
EXTENDED_USER_TYPES: EXTENDED_USER_TYPES,

docs/api/api_data.js

Lines changed: 6 additions & 6 deletions
Large diffs are not rendered by default.

docs/api/api_data.json

Lines changed: 4143 additions & 1 deletion
Large diffs are not rendered by default.

middlewares/validators/hacker.validator.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,12 @@ module.exports = {
9494
"application.shortAnswer.question2",
9595
false
9696
),
97+
VALIDATOR.enumValidator(
98+
"body",
99+
"application.shortAnswer.previousHackathons",
100+
Constants.HACKATHONS_COUNT,
101+
false
102+
),
97103

98104
VALIDATOR.alphaArrayValidator(
99105
"body",
@@ -216,6 +222,12 @@ module.exports = {
216222
"application.shortAnswer.question2",
217223
false
218224
),
225+
VALIDATOR.enumValidator(
226+
"body",
227+
"application.shortAnswer.previousHackathons",
228+
Constants.HACKATHONS_COUNT,
229+
false
230+
),
219231

220232
VALIDATOR.alphaArrayValidator(
221233
"body",

middlewares/validators/validator.helper.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,7 @@ function applicationValidator(fieldLocation, fieldname, optional = true) {
387387
shortAnswer: false,
388388
question1: false,
389389
question2: false,
390+
previousHackathons: false,
390391
accommodation: false,
391392
shirtSize: false,
392393
other: false,
@@ -425,6 +426,9 @@ function applicationValidator(fieldLocation, fieldname, optional = true) {
425426
hasValid.question2 = app.shortAnswer.hasOwnProperty(
426427
"question2"
427428
);
429+
hasValid.previousHackathons = app.shortAnswer.hasOwnProperty(
430+
"previousHackathons"
431+
);
428432
}
429433
hasValid.accommodation = app.hasOwnProperty("accommodation");
430434
if (hasValid.accommodation) {
@@ -472,6 +476,9 @@ function applicationValidator(fieldLocation, fieldname, optional = true) {
472476
// hasValid.question2 =
473477
// !!app.shortAnswer.question2 &&
474478
// typeof app.shortAnswer.question2 === "string";
479+
// hasValid.previousHackathons =
480+
// !!app.shortAnswer.previousHackathons &&
481+
// typeof app.shortAnswer.previousHackathons === "string";
475482
// hasValid.team =
476483
// !app.team || mongoose.Types.ObjectId.isValid(app.team);
477484

@@ -525,6 +532,9 @@ function applicationValidator(fieldLocation, fieldname, optional = true) {
525532
hasValid.question2 = app.shortAnswer.hasOwnProperty(
526533
"question2"
527534
);
535+
hasValid.previousHackathons = app.shortAnswer.hasOwnProperty(
536+
"previousHackathons"
537+
);
528538
}
529539
hasValid.accommodation = app.hasOwnProperty("accommodation");
530540
if (hasValid.accommodation) {
@@ -572,6 +582,9 @@ function applicationValidator(fieldLocation, fieldname, optional = true) {
572582
// hasValid.question2 =
573583
// !!app.shortAnswer.question2 &&
574584
// typeof app.shortAnswer.question2 === "string";
585+
// hasValid.previousHackathons =
586+
// !!app.shortAnswer.previousHackathons &&
587+
// typeof app.shortAnswer.previousHackathons === "string";
575588
// hasValid.team =
576589
// !app.team || mongoose.Types.ObjectId.isValid(app.team);
577590
return (
@@ -585,6 +598,7 @@ function applicationValidator(fieldLocation, fieldname, optional = true) {
585598
hasValid.shortAnswer &&
586599
hasValid.question1 &&
587600
hasValid.question2 &&
601+
hasValid.previousHackathons &&
588602
hasValid.accommodation &&
589603
hasValid.shirtSize &&
590604
hasValid.other &&
@@ -777,7 +791,7 @@ function searchSortValidator(fieldLocation, fieldName) {
777791
} else {
778792
return false;
779793
}
780-
if (!!model.searchableField(value)) {
794+
if (model.searchableField(value)) {
781795
let sortOrder = param("sort", "Sorting order not found");
782796
if (!sortOrder.equals("asc") || !sortOrder.equals("desc")) {
783797
return false;

models/hacker.model.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,11 @@ const HackerSchema = new mongoose.Schema({
8686
type: String,
8787
default: "",
8888
required: true
89+
},
90+
previousHackathons: {
91+
type: String,
92+
enum: Constants.HACKATHONS_COUNT,
93+
required: true
8994
}
9095
},
9196
other: {
@@ -147,7 +152,8 @@ HackerSchema.methods.isApplicationComplete = function() {
147152
const jobInterestDone = !!hs.application.general.jobInterest;
148153
const question1Done = !!hs.application.shortAnswer.question1;
149154
const question2Done = !!hs.application.shortAnswer.question2;
150-
return portfolioDone && jobInterestDone && question1Done && question2Done;
155+
const previousHackathonsDone = !!hs.application.shortAnswer.previousHackathons;
156+
return portfolioDone && jobInterestDone && question1Done && question2Done && previousHackathonsDone;
151157
};
152158

153159
/**

routes/api/hacker.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ module.exports = {
116116
"skills":["Javascript","Typescript"],
117117
"question1": "I love McHacks",
118118
"question2":"Pls accept me",
119+
"previousHackathons": "5+",
119120
"comments":"hi!",
120121
},
121122
"other:" {
@@ -158,6 +159,7 @@ module.exports = {
158159
"skills":["Javascript","Typescript"],
159160
"question1": "I love McHacks",
160161
"question2":"Pls accept me",
162+
"previousHackathons": "5+",
161163
"comments":"hi!",
162164
},
163165
"other:" {
@@ -447,6 +449,7 @@ module.exports = {
447449
"skills":["Javascript","Typescript"],
448450
"question1": "I love McHacks",
449451
"question2":"Pls accept me",
452+
"previousHackathons": "5+",
450453
"comments":"hi!",
451454
},
452455
"other:" {
@@ -489,6 +492,7 @@ module.exports = {
489492
"skills":["Javascript","Typescript"],
490493
"question1": "I love McHacks",
491494
"question2":"Pls accept me",
495+
"previousHackathons": "5+",
492496
"comments":"hi!",
493497
},
494498
"other:" {
@@ -560,6 +564,7 @@ module.exports = {
560564
"skills":["Javascript","Typescript"],
561565
"question1": "I love McHacks",
562566
"question2":"Pls accept me",
567+
"previousHackathons": "5+",
563568
"comments":"hi!",
564569
},
565570
"other:" {
@@ -627,6 +632,7 @@ module.exports = {
627632
"skills":["Javascript","Typescript"],
628633
"question1": "I love McHacks",
629634
"question2":"Pls accept me",
635+
"previousHackathons": "5+",
630636
"comments":"hi!",
631637
},
632638
"other:" {

tests/util/hacker.test.util.js

Lines changed: 30 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ const TeamHacker0 = {
3434
shortAnswer: {
3535
skills: ["CSS", "HTML", "JS"],
3636
question1: "a",
37-
question2: "a"
37+
question2: "a",
38+
previousHackathons: "1"
3839
},
3940
other: {
4041
ethnicity: ["Native American"],
@@ -74,7 +75,8 @@ const TeamHacker1 = {
7475
shortAnswer: {
7576
skills: ["CSS", "HTML", "JS"],
7677
question1: "a",
77-
question2: "a"
78+
question2: "a",
79+
previousHackathons: "2"
7880
},
7981
other: {
8082
ethnicity: ["European"],
@@ -114,7 +116,8 @@ const TeamHacker2 = {
114116
shortAnswer: {
115117
skills: ["CSS", "HTML", "JS"],
116118
question1: "a",
117-
question2: "a"
119+
question2: "a",
120+
previousHackathons: "3"
118121
},
119122
other: {
120123
ethnicity: ["European"],
@@ -154,7 +157,8 @@ const TeamHacker3 = {
154157
shortAnswer: {
155158
skills: ["CSS", "HTML", "JS"],
156159
question1: "a",
157-
question2: "a"
160+
question2: "a",
161+
previousHackathons: "4"
158162
},
159163
other: {
160164
ethnicity: ["European"],
@@ -194,7 +198,8 @@ const TeamHacker4 = {
194198
shortAnswer: {
195199
skills: ["CSS", "HTML", "JS"],
196200
question1: "a",
197-
question2: "a"
201+
question2: "a",
202+
previousHackathons: "5+"
198203
},
199204
other: {
200205
ethnicity: ["European"],
@@ -234,7 +239,8 @@ const NoTeamHacker0 = {
234239
shortAnswer: {
235240
skills: ["CSS", "HTML", "JS"],
236241
question1: "a",
237-
question2: "a"
242+
question2: "a",
243+
previousHackathons: "1"
238244
},
239245
other: {
240246
ethnicity: ["European"],
@@ -271,7 +277,8 @@ const newHacker0 = {
271277
shortAnswer: {
272278
skills: ["CSS", "HTML", "JS"],
273279
question1: "a",
274-
question2: "a"
280+
question2: "a",
281+
previousHackathons: "2"
275282
},
276283
other: {
277284
ethnicity: ["Caucasian"],
@@ -308,7 +315,8 @@ const newHacker1 = {
308315
shortAnswer: {
309316
skills: ["CSS", "HTML", "JS"],
310317
question1: "a",
311-
question2: "a"
318+
question2: "a",
319+
previousHackathons: "3"
312320
},
313321
other: {
314322
ethnicity: ["African American"],
@@ -346,7 +354,8 @@ const invalidHacker0 = {
346354
shortAnswer: {
347355
skills: ["CSS", "HTML", "JS"],
348356
question1: "a",
349-
question2: "a"
357+
question2: "a",
358+
previousHackathons: "4"
350359
},
351360
other: {
352361
ethnicity: ["Caucasian"],
@@ -381,7 +390,8 @@ const invalidHacker1 = {
381390
shortAnswer: {
382391
skills: ["CSS", "HTML", "JS"],
383392
question1: "a",
384-
question2: "a"
393+
question2: "a",
394+
previousHackathons: "5+"
385395
},
386396
other: {
387397
ethnicity: ["Caucasian"],
@@ -419,7 +429,8 @@ const invalidHacker2 = {
419429
shortAnswer: {
420430
skills: ["CSS", "HTML", "JS"],
421431
question1: "a",
422-
question2: "a"
432+
question2: "a",
433+
previousHackathons: "1"
423434
},
424435
other: {
425436
ethnicity: ["Caucasian"],
@@ -459,7 +470,8 @@ const duplicateAccountLinkHacker0 = {
459470
shortAnswer: {
460471
skills: ["CSS", "HTML", "JS"],
461472
question1: "a",
462-
question2: "a"
473+
question2: "a",
474+
previousHackathons: "2"
463475
},
464476
other: {
465477
ethnicity: ["Caucasian"],
@@ -498,7 +510,8 @@ const waitlistedHacker0 = {
498510
shortAnswer: {
499511
skills: ["CSS", "HTML", "JS"],
500512
question1: "a",
501-
question2: "a"
513+
question2: "a",
514+
previousHackathons: "3"
502515
},
503516
other: {
504517
ethnicity: ["European"],
@@ -538,7 +551,8 @@ const unconfirmedAccountHacker0 = {
538551
shortAnswer: {
539552
skills: ["CSS", "HTML", "JS"],
540553
question1: "a",
541-
question2: "a"
554+
question2: "a",
555+
previousHackathons: "4"
542556
},
543557
other: {
544558
ethnicity: ["European"],
@@ -577,7 +591,8 @@ const unconfirmedAccountHacker1 = {
577591
shortAnswer: {
578592
skills: ["CSS", "HTML", "JS"],
579593
question1: "a",
580-
question2: "a"
594+
question2: "a",
595+
previousHackathons: "5+"
581596
},
582597
other: {
583598
ethnicity: ["European"],

0 commit comments

Comments
 (0)