aa
This commit is contained in:
parent
1b50515227
commit
221f31af01
@ -18,79 +18,7 @@ const MODULE_NAME = '[event.controller]';
|
|||||||
|
|
||||||
const controllerOptions = { MODULE_NAME };
|
const controllerOptions = { MODULE_NAME };
|
||||||
const extraControllers = {
|
const extraControllers = {
|
||||||
/*
|
|
||||||
findNext: (config) => {
|
|
||||||
config = config || {
|
|
||||||
scopes: [],
|
|
||||||
}
|
|
||||||
|
|
||||||
return async function (req, res, next) {
|
|
||||||
const params = extractParamsFromRequest(req, res, { includeAll: false });
|
|
||||||
try {
|
|
||||||
const result = await eventService.fetch(params, {
|
|
||||||
user: req.user,
|
|
||||||
scopes: config.scopes,
|
|
||||||
lapse: 'next'
|
|
||||||
});
|
|
||||||
console.log('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa');
|
|
||||||
// Joi validation options
|
|
||||||
const _validationOptions = {
|
|
||||||
abortEarly: false, // abort after the last validation error
|
|
||||||
allowUnknown: true, // allow unknown keys that will be ignored
|
|
||||||
stripUnknown: true // remove unknown keys from the validated data
|
|
||||||
};
|
|
||||||
console.log('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa222');
|
|
||||||
const data = Joi.validate(result.dataValues, eventValidation.EventsListOutputType, _validationOptions);
|
|
||||||
console.log('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa333');
|
|
||||||
|
|
||||||
|
|
||||||
console.log(data);
|
|
||||||
return handleResultResponse(result, result.count, params, res);
|
|
||||||
} catch (error) {
|
|
||||||
handleErrorResponse(MODULE_NAME, 'findNext', error, res);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
findCurrent: async (req, res, next) => {
|
|
||||||
const params = extractParamsFromRequest(req, res, {});
|
|
||||||
try {
|
|
||||||
const result = await eventService.fetch(params, { user: req.user, lapse: 'current' });
|
|
||||||
return handleResultResponse(result, result.count, params, res);
|
|
||||||
} catch (error) {
|
|
||||||
handleErrorResponse(MODULE_NAME, 'findNext', error, res);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
|
|
||||||
if (invitationCode) {
|
|
||||||
_getLevelAndPartner()---------------------
|
|
||||||
.then(_getOrCreateUser)-------------
|
|
||||||
.then(_existsInscription)----------------
|
|
||||||
.then(_getInscriptionCount)---------
|
|
||||||
.then(_updateLevel)--------------
|
|
||||||
.then(_createInscription)--
|
|
||||||
.then(_addMember)
|
|
||||||
.then(_updateInscription)
|
|
||||||
.then(_getConference)
|
|
||||||
.then(_sendConfirmMail)
|
|
||||||
.then(_handleResponse)
|
|
||||||
.catch(_handleError);
|
|
||||||
} else {
|
|
||||||
_existsInscription()-------------
|
|
||||||
.then(_getInscriptionCount)-----------
|
|
||||||
.then(_getConference)------
|
|
||||||
.then(_updateConference)----
|
|
||||||
.then(_createInscription)--
|
|
||||||
.then(_addMember)
|
|
||||||
.then(_updateInscription)
|
|
||||||
.then(_handleResponse)
|
|
||||||
.catch(_handleError);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
*/
|
|
||||||
checkReservationCode: async (req, res, next) => {
|
checkReservationCode: async (req, res, next) => {
|
||||||
const params = extractParamsFromRequest(req, res, {});
|
const params = extractParamsFromRequest(req, res, {});
|
||||||
|
|
||||||
@ -107,6 +35,19 @@ const extraControllers = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
getInscription: async (req, res, next) => {
|
||||||
|
const params = extractParamsFromRequest(req, res, {});
|
||||||
|
const eventId = params.params.id;
|
||||||
|
const userId = req.user.id;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const result = await eventInscriptionService._getInscription(eventId, userId);
|
||||||
|
handleResultResponse(result, null, params, res, (result === null) ? httpStatus.NOT_FOUND : httpStatus.OK);
|
||||||
|
} catch (error) {
|
||||||
|
handleErrorResponse(MODULE_NAME, 'getInscription', error, res)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
createInscription: async(req, res, next) => {
|
createInscription: async(req, res, next) => {
|
||||||
const params = extractParamsFromRequest(req, res, {});
|
const params = extractParamsFromRequest(req, res, {});
|
||||||
|
|||||||
@ -13,7 +13,8 @@ const eventValidation = require('./event.validations');
|
|||||||
|
|
||||||
const generalInvalidFields = [
|
const generalInvalidFields = [
|
||||||
'userId', 'createdAt', 'updatedAt',
|
'userId', 'createdAt', 'updatedAt',
|
||||||
'assistants', 'confirmed', 'allow_multiple',
|
'assistants', 'confirmed', 'allow_multiple', 'overflow_eventId',
|
||||||
|
'state', 'confirmed',
|
||||||
'multiple_limit', 'allow_overflow', 'marketing_list',
|
'multiple_limit', 'allow_overflow', 'marketing_list',
|
||||||
];
|
];
|
||||||
|
|
||||||
@ -103,11 +104,10 @@ routes.get('/events/:id/multimedias',
|
|||||||
|
|
||||||
|
|
||||||
// Inscripciones
|
// Inscripciones
|
||||||
|
// Esto da las inscripciones (1) de un usuario pero si el usuario fuera el administrador podría todas las inscripciones de un evento
|
||||||
routes.get('/events/:id/inscriptions',
|
routes.get('/events/:id/inscriptions',
|
||||||
// Esto da las inscripciones (1) de un usuario pero si el usuario fuera el administrador podría todas las inscripciones de un evento
|
|
||||||
isLoggedUser,
|
isLoggedUser,
|
||||||
//eventController.findComments
|
eventController.getInscription,
|
||||||
);
|
);
|
||||||
|
|
||||||
// Hacer una inscripción
|
// Hacer una inscripción
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user