diff --git a/server/db/achievement.js b/server/db/achievement.js index 61ab8cc..80ad3fc 100644 --- a/server/db/achievement.js +++ b/server/db/achievement.js @@ -3,6 +3,7 @@ let mongoose = require('mongoose') let achievementSchema = mongoose.Schema({ id: { type: String, unique: true }, session: String, + company: String, name: String, description: String, instructions: String, diff --git a/server/resources/achievement.js b/server/resources/achievement.js index 53ab121..21d8be5 100644 --- a/server/resources/achievement.js +++ b/server/resources/achievement.js @@ -38,6 +38,7 @@ async function create(data) { name: data.name, event: data.event, session: data.session, + company: data.company, description: data.description, category: data.category, instructions: data.instructions, @@ -531,7 +532,7 @@ async function addUserToStandAchievement(companyId, userId) { const now = new Date() return Achievement.findOneAndUpdate({ - id: { $regex: `stand-${companyId}-` }, + 'company': companyId, 'kind': 'stand', 'validity.from': { $lte: now }, 'validity.to': { $gte: now } diff --git a/server/routes/achievement/handlers.js b/server/routes/achievement/handlers.js index d90db27..07be0ee 100644 --- a/server/routes/achievement/handlers.js +++ b/server/routes/achievement/handlers.js @@ -33,6 +33,7 @@ exports.create = { name: Joi.string().required().description('Name of the achievement'), event: Joi.string().default('22').description('Event the achievement is associated to'), session: Joi.string().description('Id of a session associated to this achievement'), + company: Joi.string().description('Company associated to this achievement'), img: Joi.any().meta({ swaggerType: 'file' }).description('Image of the achievement'), description: Joi.string().description('Description of the achievement'), category: Joi.string().description('Category of the achievement'), diff --git a/server/views/achievement.js b/server/views/achievement.js index 17a2866..5fb2994 100644 --- a/server/views/achievement.js +++ b/server/views/achievement.js @@ -11,6 +11,7 @@ function renderObject (model, wCode) { id: model.id, event: model.event, session: model.session, + company: model.company, unregisteredUsers: model.unregisteredUsers, name: model.name, description: model.description,