diff --git a/backend/web/server/plugins/entreprisedufutur/functions.js b/backend/web/server/plugins/entreprisedufutur/functions.js index d9251c6f6..1f550ba12 100644 --- a/backend/web/server/plugins/entreprisedufutur/functions.js +++ b/backend/web/server/plugins/entreprisedufutur/functions.js @@ -249,6 +249,7 @@ USER_MODELS.forEach(m => { declareComputedField({model: m, field: 'unseen_notifications_count', getterFn: getPendingNotificationsCount}) declareVirtualField({model: m, field: 'published_missions_count', instance: 'Number'}) declareVirtualField({model: m, field: 'published_public_missions_count', instance: 'Number'}) + declareEnumField({model: m, field:'is_allergic', enumValues: BOOLEAN_ENUM}) }) //Company declarations diff --git a/backend/web/server/plugins/entreprisedufutur/schemas/UserSchema.js b/backend/web/server/plugins/entreprisedufutur/schemas/UserSchema.js index 013e1e419..1fc24b8cf 100644 --- a/backend/web/server/plugins/entreprisedufutur/schemas/UserSchema.js +++ b/backend/web/server/plugins/entreprisedufutur/schemas/UserSchema.js @@ -4,7 +4,7 @@ const { isEmailOk, isPhoneOk } = require('../../../../utils/sms') const {schemaOptions} = require('../../../utils/schemas') const bcrypt = require('bcryptjs') const { DUMMY_REF, idEqual } = require('../../../utils/database') -const { ROLES , JOBS, DISCRIMINATOR_KEY, LEVEL_THRESHOLD_EXPLORER, USER_LEVEL_CURIOUS, LEVEL_THRESHOLD_AMBASSADOR, USER_LEVEL_AMBASSADOR, USER_LEVEL_EXPLORER, COMPLETED_YES, OPTIONAL_COMPLETION_FIELDS, REQUIRED_COMPLETION_FIELDS, ROLE_MEMBER } = require('../consts') +const { ROLES , JOBS, DISCRIMINATOR_KEY, LEVEL_THRESHOLD_EXPLORER, USER_LEVEL_CURIOUS, LEVEL_THRESHOLD_AMBASSADOR, USER_LEVEL_AMBASSADOR, USER_LEVEL_EXPLORER, COMPLETED_YES, OPTIONAL_COMPLETION_FIELDS, REQUIRED_COMPLETION_FIELDS, ROLE_MEMBER, BOOLEAN_ENUM_NO, BOOLEAN_ENUM } = require('../consts') const AddressSchema = require('../../../models/AddressSchema') const { CREATED_AT_ATTRIBUTE } = require('../../../../utils/consts') @@ -189,9 +189,10 @@ const UserSchema = new Schema({ type: Number }, is_allergic: { - type: Boolean, + type: String, + enum: Object.keys(BOOLEAN_ENUM), required: true, - default: false + default: BOOLEAN_ENUM_NO }, allergy: { type: String,