From b24fe41d13b12462ab0a04f76d683be1c683fa7d Mon Sep 17 00:00:00 2001 From: Bastien Seree Date: Tue, 24 Sep 2024 10:21:54 +0200 Subject: [PATCH] Cyberleague: [#150] add statut enum field in company schema --- backend/web/server/plugins/cyberleague/consts.js | 11 +++++++++++ backend/web/server/plugins/cyberleague/functions.js | 3 ++- .../plugins/cyberleague/schemas/CompanySchema.js | 9 +++++++-- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/backend/web/server/plugins/cyberleague/consts.js b/backend/web/server/plugins/cyberleague/consts.js index 867257726d..2a3b028cb1 100644 --- a/backend/web/server/plugins/cyberleague/consts.js +++ b/backend/web/server/plugins/cyberleague/consts.js @@ -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, @@ -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, } \ No newline at end of file diff --git a/backend/web/server/plugins/cyberleague/functions.js b/backend/web/server/plugins/cyberleague/functions.js index 0e076806d3..0e41f635d1 100644 --- a/backend/web/server/plugins/cyberleague/functions.js +++ b/backend/web/server/plugins/cyberleague/functions.js @@ -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') @@ -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')}) diff --git a/backend/web/server/plugins/cyberleague/schemas/CompanySchema.js b/backend/web/server/plugins/cyberleague/schemas/CompanySchema.js index ad25aaca4c..ba2c532853 100644 --- a/backend/web/server/plugins/cyberleague/schemas/CompanySchema.js +++ b/backend/web/server/plugins/cyberleague/schemas/CompanySchema.js @@ -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') @@ -140,7 +140,12 @@ const CompanySchema = new Schema( type: Schema.Types.ObjectId, ref: 'company' }] - } + }, + statut: { + type: String, + enum: Object.keys(STATUTS), + required: false + }, }, schemaOptions, )