Skip to content

Commit

Permalink
chore: dev to master (#923)
Browse files Browse the repository at this point in the history
* feat(hacker.js,hacker.middleware.js): add ability for discord verification. (#795)

* feat(hacker.js,hacker.middleware.js): add ability for discord verification..

* fix(hacker.js): typo in middleware function call.

* add postDiscord role/route

* Fix hacker discord route

Co-authored-by: meldunn <dmelissa216@gmail.com>

* change invite to disc (#799)

* change invite to disc

* remove fb group

* fix/update emails (#882)

* feat(hacker.js,hacker.middleware.js): add ability for discord verification..

* fix(hacker.js): typo in middleware function call.

* add postDiscord role/route

* fix: update applied email

Co-authored-by: meldunn <dmelissa216@gmail.com>

* Jacky/email (#900)

* fix: change to mchacks 10 in email templates

* fix: dates

* fix: move confirmation date +1 day

Co-authored-by: Jacky Zhang <jackyyzhang@gmail.com>

* Fix/check in discord (#905)

* fix: change to mchacks 10 in email templates

* fix: dates

* fix: move confirmation date +1 day

* Fix: check in discord

---------

* feat: add field for reimbursement reason (#922)

* feat: set cookie SameSite using env variable

---------

Co-authored-by: Anmol Brar <83686967+brarsanmol@users.noreply.github.com>
Co-authored-by: meldunn <dmelissa216@gmail.com>
Co-authored-by: Yun Kai Peng <45922265+pengyk@users.noreply.github.com>
  • Loading branch information
4 people authored Nov 15, 2023
1 parent 42c5c48 commit 227d3f0
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 31 deletions.
6 changes: 4 additions & 2 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@ app.use(
name: "session",
keys: [process.env.COOKIE_SECRET],
// Cookie Options
maxAge: 48 * 60 * 60 * 1000 //Logged in for 48 hours
maxAge: 48 * 60 * 60 * 1000, //Logged in for 48 hours
sameSite: process.env.COOKIE_SAME_SITE,
secureProxy: true
})
);
app.use(passport.initialize());
Expand All @@ -89,7 +91,7 @@ Services.log.info("Hacker router activated");
teamRouter.activate(apiRouter);
Services.log.info("Team router activated");
travelRouter.activate(apiRouter);
Services.log.info("Travel router activated")
Services.log.info("Travel router activated");
sponsorRouter.activate(apiRouter);
Services.log.info("Sponsor router activated");
volunteerRouter.activate(apiRouter);
Expand Down
10 changes: 6 additions & 4 deletions middlewares/travel.middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const mongoose = require("mongoose");
const Services = {
Travel: require("../services/travel.service"),
Hacker: require("../services/hacker.service"),
Account: require("../services/account.service"),
Account: require("../services/account.service")
};
const Middleware = {
Util: require("./util.middleware")
Expand All @@ -28,7 +28,6 @@ function parsePatch(req, res, next) {
return next();
}


/**
* @function parseTravel
* @param {{body: {accountId: ObjectId, hackerId: ObjectId, authorization: string}}} req
Expand Down Expand Up @@ -57,7 +56,7 @@ function parseTravel(req, res, next) {

/**
* @function addRequestFromHacker
* @param {{body: {travelDetails: {request: Number}}}} req
* @param {{body: {travelDetails: {request: {amount: number, reason: string}}}}} req
* @param {JSON} res
* @param {(err?)=>void} next
* @return {void}
Expand All @@ -66,7 +65,9 @@ function parseTravel(req, res, next) {
* req.body.travelDetails
*/
async function addRequestFromHacker(req, res, next) {
const hacker = await Services.Hacker.findById(req.body.travelDetails.accountId);
const hacker = await Services.Hacker.findById(
req.body.travelDetails.accountId
);
if (!hacker) {
return next({
status: 500,
Expand All @@ -77,6 +78,7 @@ async function addRequestFromHacker(req, res, next) {
}
});
}
// eslint-disable-next-line require-atomic-updates
req.body.travelDetails.request = hacker.application.accommodation.travel;
return next();
}
Expand Down
36 changes: 26 additions & 10 deletions middlewares/validators/hacker.validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,16 +126,24 @@ module.exports = {
),
VALIDATOR.integerValidator(
"body",
"application.accommodation.travel",
"application.accommodation.travel.amount",
true,
0,
100
0
),
VALIDATOR.stringValidator(
"body",
"application.accommodation.travel.reason",
true
),
VALIDATOR.mongoIdValidator("body", "application.team", true),
VALIDATOR.stringValidator("body", "application.location.timeZone", true),
VALIDATOR.stringValidator(
"body",
"application.location.timeZone",
true
),
VALIDATOR.stringValidator("body", "application.location.country", true),
VALIDATOR.stringValidator("body", "application.location.city", true),
VALIDATOR.mongoIdValidator("body", "teamId", true),
VALIDATOR.mongoIdValidator("body", "teamId", true)
],

updateConfirmationValidator: [
Expand Down Expand Up @@ -257,15 +265,23 @@ module.exports = {
),
VALIDATOR.integerValidator(
"body",
"application.accommodation.travel",
"application.accommodation.travel.amount",
true,
0,
100
0
),
VALIDATOR.stringValidator(
"body",
"application.accommodation.travel.reason",
true
),
VALIDATOR.mongoIdValidator("body", "application.team", true),
VALIDATOR.stringValidator("body", "application.location.timeZone", true),
VALIDATOR.stringValidator(
"body",
"application.location.timeZone",
true
),
VALIDATOR.stringValidator("body", "application.location.country", true),
VALIDATOR.stringValidator("body", "application.location.city", true),
VALIDATOR.stringValidator("body", "application.location.city", true)
],
updateStatusValidator: [
VALIDATOR.enumValidator(
Expand Down
28 changes: 23 additions & 5 deletions models/hacker.model.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,16 @@ const HackerSchema = new mongoose.Schema({
enum: Constants.SHIRT_SIZES,
required: true
},
travel: { type: Number, default: 0 },
travel: {
amount: {
type: Number,
default: 0
},
reason: {
type: String,
default: ""
}
},
attendancePreference: {
type: String,
enum: Constants.ATTENDANCE_PREFERENCES,
Expand Down Expand Up @@ -155,7 +164,7 @@ const HackerSchema = new mongoose.Schema({
teamId: {
type: mongoose.Schema.Types.ObjectId,
ref: "Team"
},
}
});

HackerSchema.methods.toJSON = function() {
Expand All @@ -171,9 +180,18 @@ HackerSchema.methods.isApplicationComplete = function() {
const jobInterestDone = !!hs.application.general.jobInterest;
const question1Done = !!hs.application.shortAnswer.question1;
const question2Done = !!hs.application.shortAnswer.question2;
const previousHackathonsDone = !!hs.application.shortAnswer.previousHackathons;
const attendancePreferenceDone = !!hs.application.accommodation.attendancePreference;
return portfolioDone && jobInterestDone && question1Done && question2Done && previousHackathonsDone && attendancePreferenceDone;
const previousHackathonsDone = !!hs.application.shortAnswer
.previousHackathons;
const attendancePreferenceDone = !!hs.application.accommodation
.attendancePreference;
return (
portfolioDone &&
jobInterestDone &&
question1Done &&
question2Done &&
previousHackathonsDone &&
attendancePreferenceDone
);
};

/**
Expand Down
28 changes: 20 additions & 8 deletions models/travel.model.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,45 @@ const Constants = require("../constants/general.constant");
const mongoose = require("mongoose");
//describes the data type
const TravelSchema = new mongoose.Schema({
accountId: { // The account this travel data is associated with
accountId: {
// The account this travel data is associated with
type: mongoose.Schema.Types.ObjectId,
ref: "Account",
required: true
},
hackerId: { // The hacker this travel data is associated with
hackerId: {
// The hacker this travel data is associated with
type: mongoose.Schema.Types.ObjectId,
ref: "Hacker",
required: true
},
status: { // Has this hacker been approved for funds, etc.
status: {
// Has this hacker been approved for funds, etc.
type: String,
enum: Constants.TRAVEL_STATUSES,
required: true,
default: "None"
},
request: { // Amount of money hacker has requested for travel
type: Number,
required: true
request: {
// Amount of money hacker has requested for travel
amount: {
type: Number,
required: true
},
reason: {
type: String,
required: true,
default: ""
}
},
offer: { // Amount of money we have offered hacker for travel
offer: {
// Amount of money we have offered hacker for travel
type: Number,
default: 0
}
});

TravelSchema.methods.toJSON = function () {
TravelSchema.methods.toJSON = function() {
const hs = this.toObject();
delete hs.__v;
hs.id = hs._id;
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"version": "3.1.4",
"private": true,
"scripts": {
"start": "DEBUG=hackboard:* NODE_ENV=test nodemon --ignore gcp_creds.json ./bin/www.js",
"start-windows": "set DEBUG=hackboard:* && set NODE_ENV=test && nodemon --ignore gcp_creds.json ./bin/www.js",
"start": "DEBUG=hackboard:* NODE_ENV=development nodemon --ignore gcp_creds.json ./bin/www.js",
"start-windows": "set DEBUG=hackboard:* && set NODE_ENV=development && nodemon --ignore gcp_creds.json ./bin/www.js",
"deploy": "NODE_ENV=deployment node ./bin/www.js",
"debug": "DEBUG=hackboard:* NODE_ENV=test nodemon --ignore gcp_creds.json ./bin/www.js",
"test": "DEBUG=hackboard:* NODE_ENV=test mocha -r dotenv/config --reporter spec tests/**.js --exit",
Expand Down

0 comments on commit 227d3f0

Please sign in to comment.