Skip to content

Commit

Permalink
Cyberleague: [premieroctet#150] add statut enum field in company schema
Browse files Browse the repository at this point in the history
  • Loading branch information
Bastien-Wappizy committed Sep 24, 2024
1 parent 0ed65c0 commit b24fe41
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
11 changes: 11 additions & 0 deletions backend/web/server/plugins/cyberleague/consts.js
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,16 @@ const COIN_SOURCES = {
[COIN_SOURCE_EXPERT_DIAG] : `Faire un diagnostic niveau expert`
}

const STATUT_PARTNER = `STATUT_PARTNER`
const STATUT_SPONSOR = `STATUT_SPONSOR`
const STATUT_FOUNDER = `STATUT_FOUNDER`

const STATUTS = {
STATUT_PARTNER: `Partenaire`,
STATUT_SPONSOR: `Sponsor`,
STATUT_FOUNDER: `Fondateur`
}

module.exports = {
DISC_ADMIN, DISC_MEMBER, DISC_PARTNER, DISCRIMINATOR_KEY,
ROLES, ROLE_ADMIN, ROLE_MEMBER, ROLE_PARTNER,
Expand All @@ -266,4 +276,5 @@ module.exports = {
QUESTION_CATEGORY_ANTIVIRUS_PROTECTION, QUESTION_CATEGORY_ENDPOINT_SECURITY, QUESTION_CATEGORY_MONITORING_AND_UPDATE_MANAGEMENT, QUESTION_CATEGORY_BANK_TRANSACTION_SECURITY, QUESTION_CATEGORY_DEVICE_AND_FACTORY_NETWORK_SECURITY,
SCORE_LEVELS,SCORE_LEVEL_1, SCORE_LEVEL_2, SCORE_LEVEL_3,
COIN_SOURCES, COIN_SOURCE_WATCH, COIN_SOURCE_PARTICIPATE, COIN_SOURCE_TRAININGS, COIN_SOURCE_LIKE_SHARE_COMMENT, COIN_SOURCE_BEGINNER_DIAG, COIN_SOURCE_MEDIUM_DIAG, COIN_SOURCE_EXPERT_DIAG,
STATUTS,STATUT_PARTNER,STATUT_SPONSOR,STATUT_FOUNDER,
}
3 changes: 2 additions & 1 deletion backend/web/server/plugins/cyberleague/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const {
setPostPutData,
idEqual,
} = require('../../utils/database')
const { ROLES, SECTOR, EXPERTISE_CATEGORIES, CONTENT_TYPE, JOBS, COMPANY_SIZE, ROLE_PARTNER, ROLE_ADMIN, ROLE_MEMBER, ESTIMATED_DURATION_UNITS, LOOKING_FOR_MISSION, CONTENT_VISIBILITY, EVENT_VISIBILITY, ANSWERS, QUESTION_CATEGORIES, SCORE_LEVELS, COIN_SOURCES, SCORE_LEVEL_1, SCORE_LEVEL_3, SCORE_LEVEL_2 } = require('./consts')
const { ROLES, SECTOR, EXPERTISE_CATEGORIES, CONTENT_TYPE, JOBS, COMPANY_SIZE, ROLE_PARTNER, ROLE_ADMIN, ROLE_MEMBER, ESTIMATED_DURATION_UNITS, LOOKING_FOR_MISSION, CONTENT_VISIBILITY, EVENT_VISIBILITY, ANSWERS, QUESTION_CATEGORIES, SCORE_LEVELS, COIN_SOURCES, SCORE_LEVEL_1, SCORE_LEVEL_3, SCORE_LEVEL_2, STATUTS } = require('./consts')
const { PURCHASE_STATUS } = require('../../../utils/consts')
const Company = require('../../models/Company')
const { BadRequestError, ForbiddenError } = require('../../utils/errors')
Expand Down Expand Up @@ -174,6 +174,7 @@ declareEnumField( {model: 'company', field: 'sector', enumValues: SECTOR})
declareEnumField( {model: 'company', field: 'size', enumValues: COMPANY_SIZE})
declareEnumField( {model: 'company', field: 'targeted_markets', enumValues: SECTOR})
declareEnumField( {model: 'company', field: 'looking_for_mission', enumValues: LOOKING_FOR_MISSION})
declareEnumField( {model: 'company', field: 'statut', enumValues: STATUTS})
declareComputedField({model: 'company', field: 'pinned', getterFn: getterPinnedFn('company', 'pinned_by'), setterFn: setterPinnedFn('company', 'pinned_by'), requires:'pinned_by'})
declareComputedField({model: 'company', field: 'contents', requires:'users', getterFn: getContents})
declareComputedField({model: 'company', field: 'related_companies', requires:'expertise_set.expertises', getterFn: getRelated('company')})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const mongoose = require('mongoose')
const { schemaOptions } = require('../../../utils/schemas')
const siret = require('siret')
const { DUMMY_REF } = require('../../../utils/database')
const { SECTOR, COMPANY_SIZE, LOOKING_FOR_MISSION } = require('../consts')
const { SECTOR, COMPANY_SIZE, LOOKING_FOR_MISSION, STATUTS } = require('../consts')
const { isPhoneOk, isEmailOk } = require('../../../../utils/sms')
const AddressSchema = require('../../../models/AddressSchema')

Expand Down Expand Up @@ -140,7 +140,12 @@ const CompanySchema = new Schema(
type: Schema.Types.ObjectId,
ref: 'company'
}]
}
},
statut: {
type: String,
enum: Object.keys(STATUTS),
required: false
},
},
schemaOptions,
)
Expand Down

0 comments on commit b24fe41

Please sign in to comment.