Skip to content

Commit

Permalink
Merge branch 'pre-STAG' into fix/partner-registrations-and-participan…
Browse files Browse the repository at this point in the history
…t-filters-save
  • Loading branch information
wickathou authored Oct 15, 2024
2 parents f03fae2 + a8d9a00 commit 84b26a2
Show file tree
Hide file tree
Showing 111 changed files with 2,135 additions and 4,627 deletions.
7 changes: 4 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ docker-compose.yml
*.env.example
azure-pipelines-1.yml
azure-pipelines.yml
azure-pipelines-africa.yml
azure-pipelines-asia.yml
azure-pipelines-eu.yml
.env dev frontend
.env dev backend
.env stag frontend
.env stag backend
425 changes: 206 additions & 219 deletions License.md

Large diffs are not rendered by default.

65 changes: 55 additions & 10 deletions backend/common/utils/userProfileUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,13 @@

const userProfileUtils = {
publicProfileBuilder: profileData => {
//Do not include any sensitive information (email, nationality, gender, date of birth) in the public profile
return {
userId: profileData.userId,
profile: {
firstName: profileData.firstName,
lastName: profileData.lastName,
// email: profileData.email,
// gender: profileData.gender,
// nationality: profileData.nationality,
// countryOfResidence: profileData.countryOfResidence,
// dateOfBirth: profileData.dateOfBirth,
spokenLanguages: profileData.spokenLanguages,
// TODO remove profilePicture and replace with avatar property
// profilePicture: profileData.avatar || null,
avatar: profileData.avatar || null,
headline: profileData.headline,
biography: profileData.biography,
Expand All @@ -32,10 +26,61 @@ const userProfileUtils = {
},
}
},
recruitmentProfileBuilder: function (profileData) {
recruitmentProfileBuilder: (registrationData, profileData) => {
//This combines the registration data with the profile data
//Don't include personal information like gender, nationality or date of birth
return {
...this.publicProfileBuilder(profileData),
recruitmentOptions: profileData.recruitmentOptions,
userId: profileData.userId,
profile: {
firstName: profileData.firstName,
lastName: profileData.lastName,
email: profileData.email,
countryOfResidence: registrationData.answers.countryOfResidence
? registrationData.answers.countryOfResidence
: profileData.countryOfResidence,
spokenLanguages: registrationData.answers.spokenLanguages
? registrationData.answers.spokenLanguages
: profileData.spokenLanguages,
avatar: profileData.avatar || null,
headline: registrationData.answers.headline
? registrationData.answers.headline
: profileData.headline,
biography: registrationData.answers.biography
? registrationData.answers.biography
: profileData.biography,
},
skills: registrationData.answers.skills
? registrationData.answers.skills
: profileData.skills,
roles: registrationData.answers.roles
? registrationData.answers.roles
: profileData.roles,
industriesOfInterest: registrationData.answers.industriesOfInterest
? registrationData.answers.industriesOfInterest
: profileData.industriesOfInterest,
themesOfInterest: registrationData.answers.themesOfInterest
? registrationData.answers.themesOfInterest
: profileData.themesOfInterest,
education: registrationData.answers.education
? registrationData.answers.education
: profileData.education,
social: {
github: registrationData.answers.github
? registrationData.answers.github
: profileData.github,
linkedin: registrationData.answers.linkedin
? registrationData.answers.linkedin
: profileData.linkedin,
portfolio: registrationData.answers.portfolio
? registrationData.answers.portfolio
: profileData.portfolio,
curriculumVitae: registrationData.answers.curriculumVitae
? registrationData.answers.curriculumVitae
: profileData.curriculumVitae,
},
recruitmentOptions: registrationData.answers.recruitmentOptions
? registrationData.answers.recruitmentOptions
: profileData.recruitmentOptions,
registrations: profileData.registrations,
}
},
Expand Down
200 changes: 113 additions & 87 deletions backend/modules/devtools/routes.js
Original file line number Diff line number Diff line change
@@ -1,112 +1,138 @@
const express = require('express')
const _ = require('lodash')
const {
hasPermission,
hasRole,
} = require('../../common/middleware/permissions')
const { hasToken } = require('../../common/middleware/token')
const asyncHandler = require('express-async-handler')
const { Auth } = require('@hackjunction/shared')

const router = express.Router()
const Registration = require('../registration/model')
const { UserProfile } = require('../user-profile/model')
const DiscordService = require('../../common/services/discord')

router.route('/').get((req, res) => {
return res.status(200).send('DEVTOOLS HERE')
})

router.route('/anonymize-db').get(async (req, res) => {
const registrations = await Registration.find({})

const updates = registrations.map(registration => {
return {
updateOne: {
filter: {
_id: registration._id,
},
update: {
$set: {
'answers.email': `juuso.lappalainen+${Math.floor(
Math.random() * 1000000
)}@hackjunction.com`,
router.route('/').get(
hasToken,
hasRole(Auth.Roles.SUPER_ADMIN),
asyncHandler(async (req, res) => {
return res.status(200).send('DEVTOOLS ENABLED')
}),
)

router.route('/anonymize-db').get(
hasToken,
hasRole(Auth.Roles.SUPER_ADMIN),
asyncHandler(async (req, res) => {
const registrations = await Registration.find({})
let anonymizeResults = []
let errors = []
const updates = registrations.map(registration => {
return {
updateOne: {
filter: {
_id: registration._id,
},
},
},
}
})

await Registration.bulkWrite(updates)

const userProfiles = await UserProfile.find({})

const userUpdates = userProfiles.map(userProfile => {
return {
updateOne: {
filter: {
_id: userProfile._id,
},
update: {
$set: {
email: `juuso.lappalainen+${Math.floor(
Math.random() * 1000000
)}@hackjunction.com`,
update: {
$set: {
'answers.email': `anon+${Math.floor(
Math.random() * 1000000,
)}@hackjunction.com`,
},
},
},
},
}
})

await UserProfile.bulkWrite(userUpdates)

return res.status(200).send('OK')
})

// This isn't in use at the moment
router.route('/test-discord').get(async (req, res) => {
await DiscordService.initialize()
res.status(200).send('Initialized')
})

router.route('/sync-user-profiles').get(async (req, res) => {
const registrations = await Registration.find({})
const userProfiles = await UserProfile.find({})

const updates = []
}
})
await Registration.bulkWrite(updates)
.then(result => {
anonymizeResults.push(result)
})
.catch(err => {
errors.push(err)
})

userProfiles.forEach(user => {
const registration = _.find(
registrations,
reg => reg.user === user.userId
)
const userProfiles = await UserProfile.find({})

if (registration && registration.answers) {
updates.push({
const userUpdates = userProfiles.map(userProfile => {
return {
updateOne: {
filter: {
userId: user.userId,
_id: userProfile._id,
},
update: {
$set: {
roles: registration.answers.roles,
skills: registration.answers.skills,
recruitmentOptions:
registration.answers.recruitmentOptions,
},
$addToSet: {
registrations: {
registration: registration._id,
status: registration.status,
event: registration.event,
},
email: `anon+${Math.floor(
Math.random() * 1000000,
)}@hackjunction.com`,
},
},
},
}
})

await UserProfile.bulkWrite(userUpdates)
.then(result => {
anonymizeResults.push(result)
})
.catch(err => {
errors.push(err)
})
}
})

return UserProfile.bulkWrite(updates)
.then(result => {
return res.status(200).json(result)
})
.catch(err => {
return res.status(500).json(err)
if (errors.length > 0) {
return res.status(500).json(errors)
}
return res.status(200).json(anonymizeResults)
}),
)

router.route('/sync-user-profiles').get(
hasToken,
hasRole(Auth.Roles.SUPER_ADMIN),
asyncHandler(async (req, res) => {
const registrations = await Registration.find({})
const userProfiles = await UserProfile.find({})

const updates = []

userProfiles.forEach(user => {
const registration = _.find(
registrations,
reg => reg.user === user.userId,
)

if (registration && registration.answers) {
updates.push({
updateOne: {
filter: {
userId: user.userId,
},
update: {
$set: {
roles: registration.answers.roles,
skills: registration.answers.skills,
recruitmentOptions:
registration.answers.recruitmentOptions,
},
$addToSet: {
registrations: {
registration: registration._id,
status: registration.status,
event: registration.event,
},
},
},
},
})
}
})
})
return UserProfile.bulkWrite(updates)
.then(result => {
return res.status(200).json(result)
})
.catch(err => {
return res.status(500).json(err)
})
}),
)

module.exports = router
2 changes: 1 addition & 1 deletion backend/modules/project/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ controller.getFinalists = async event => {

controller.getDataForPartnerReviewing = async (event, user) => {
const data = {}
const teams = await TeamController.getAllTeamsForEvent(event._id)
const teams = await TeamController.getAllTeamsForEventAsPartner(event._id)
const projects = await controller.getProjectPreviewsByEvent(event._id)
const projectsWithExistingTeamsAndFinal = _.filter(projects, project => {
if (project.status === 'final') {
Expand Down
1 change: 1 addition & 0 deletions backend/modules/project/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ const ProjectSchema = new mongoose.Schema({
images: {
type: [CloudinaryImageSchema.mongoose],
},
//TODO modify challenges to only allow one challenge
challenges: {
type: [String],
},
Expand Down
Loading

0 comments on commit 84b26a2

Please sign in to comment.