Skip to content

Commit 84f3587

Browse files
Added check to prevent creating application after the deadline has pa… (#630)
* Added check to prevent creating application after the deadline has passed * Renamed constant * Fixed error message
1 parent 34e391e commit 84f3587

3 files changed

Lines changed: 11 additions & 5 deletions

File tree

.github/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111

1212
- Add email blast marketing email
1313
- Add 3 days left marketing email
14+
- Add check to ensure application creation deadline has not passed yet
1415

1516
### Fixed
1617

constants/general.constant.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ const HACKER_STATUSES = [
2525
HACKER_STATUS_CHECKED_IN,
2626
HACKER_STATUS_DECLINED
2727
];
28+
// This date is Jan 3, 2020 11:59:59PM EST
29+
const APPLICATION_CLOSE_TIME = 1578070799000;
2830

2931
const SAMPLE_DIET_RESTRICTIONS = [
3032
"None",
@@ -111,9 +113,7 @@ const MAX_TEAM_SIZE = 4;
111113
const WEEK_OF = "Week Of";
112114

113115
const EMAIL_SUBJECTS = {};
114-
EMAIL_SUBJECTS[
115-
HACKER_STATUS_NONE
116-
] = `Get started on your application!`;
116+
EMAIL_SUBJECTS[HACKER_STATUS_NONE] = `Get started on your application!`;
117117
EMAIL_SUBJECTS[
118118
HACKER_STATUS_APPLIED
119119
] = `Thanks for applying to ${HACKATHON_NAME}!`;
@@ -160,6 +160,7 @@ module.exports = {
160160
HACKER_STATUS_WITHDRAWN: HACKER_STATUS_WITHDRAWN,
161161
HACKER_STATUS_CHECKED_IN: HACKER_STATUS_CHECKED_IN,
162162
HACKER_STATUSES: HACKER_STATUSES,
163+
APPLICATION_CLOSE_TIME: APPLICATION_CLOSE_TIME,
163164
REQUEST_TYPES: REQUEST_TYPES,
164165
JOB_INTERESTS: JOB_INTERESTS,
165166
SHIRT_SIZES: SHIRT_SIZES,

services/hacker.service.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,13 @@ const QRCode = require("qrcode");
1717
function createHacker(hackerDetails) {
1818
const TAG = `[Hacker Service # createHacker]:`;
1919

20-
const hacker = new Hacker(hackerDetails);
20+
let hacker;
2121

22-
return hacker.save();
22+
if (Date.now() < Constants.APPLICATION_CLOSE_TIME) {
23+
hacker = new Hacker(hackerDetails);
24+
return hacker.save();
25+
}
26+
throw new Error("Sorry, the application deadline has passed!");
2327
}
2428

2529
/**

0 commit comments

Comments
 (0)