From 2c8aa9e590bfc5c1363559b3db3fb12aeb2ee272 Mon Sep 17 00:00:00 2001 From: David Arranz Date: Thu, 29 Aug 2024 13:00:32 +0200 Subject: [PATCH] . --- core/controllers/index.js | 1 - modules/events/event.controller.js | 11 +++++++++++ modules/events/event.routes.v4.js | 6 +++++- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/core/controllers/index.js b/core/controllers/index.js index 06e1933..6f42166 100644 --- a/core/controllers/index.js +++ b/core/controllers/index.js @@ -74,7 +74,6 @@ const generateControllers = (service, extraControllers = {}, options = {}) => { //Tratamos resultado, si hay que remover campos para API4 web if (res.locals.v4){ const arrayFieldsremove = res.locals.v4.removeFields; - console.log('>>>>>>>>>>>>>>>>>>>>>>', result); arrayFieldsremove.forEach(campo => { if (campo in result) { delete result[campo]; diff --git a/modules/events/event.controller.js b/modules/events/event.controller.js index 5d0edf2..c7f35b9 100644 --- a/modules/events/event.controller.js +++ b/modules/events/event.controller.js @@ -104,6 +104,17 @@ const extraControllers = { }); } + //MAPEO SALIDA API4 + //Tratamos resultado, si hay que remover campos para API4 web + if (res.locals.v4){ + const arrayFieldsremove = res.locals.v4.removeFields; + arrayFieldsremove.forEach(campo => { + if (campo in result) { + delete result[campo]; + } + }); + }; + return handleResultResponse(result, null, params, res, result === null ? httpStatus.NOT_FOUND : httpStatus.OK); } catch (error) { return handleErrorResponse(MODULE_NAME, "allowCapacity", error, res); diff --git a/modules/events/event.routes.v4.js b/modules/events/event.routes.v4.js index 5160809..e85c71a 100644 --- a/modules/events/event.routes.v4.js +++ b/modules/events/event.routes.v4.js @@ -208,7 +208,11 @@ routes.get("/web/events/:id/check_capacity", FieldMiddleware.middleware({ invalidFields: generalInvalidFields, }), - eventController.checkCapacity); + (req, res, next) => { + res.locals.v4 = {removeFields : ["assistans", "confirmed", "sold_out", "assistans_overflow", "confirmed_overflow", "sold_out_overflou"]}; + return eventController.checkCapacity(req, res, next); + } +); /** * @api {get} /api/v4/web/events/:eventId/reservations/:encodedCode Verificar Código de Invitación