a
This commit is contained in:
parent
5974576d28
commit
5b20d94823
@ -89,6 +89,9 @@ const generateControllers = (service, extraControllers = {}, options = {}) => {
|
|||||||
return async (req, res, next) => {
|
return async (req, res, next) => {
|
||||||
try {
|
try {
|
||||||
const params = extractParamsFromRequest(req, res, _options.params.update);
|
const params = extractParamsFromRequest(req, res, _options.params.update);
|
||||||
|
console.log('paraaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaams');
|
||||||
|
console.log(req.body);
|
||||||
|
|
||||||
const response = await service.update(params, req.body, buildContext(req, config));
|
const response = await service.update(params, req.body, buildContext(req, config));
|
||||||
// https://sequelize.org/master/class/lib/model.js~Model.html#static-method-update
|
// https://sequelize.org/master/class/lib/model.js~Model.html#static-method-update
|
||||||
// Update devuelve un array de un elemento con el número de filas afectadas
|
// Update devuelve un array de un elemento con el número de filas afectadas
|
||||||
|
|||||||
@ -10,6 +10,7 @@ const SortMiddleware = require('../../middlewares/sort');
|
|||||||
|
|
||||||
//const entityValidation = require('./entity.validations');
|
//const entityValidation = require('./entity.validations');
|
||||||
const eventController = require('./event.controller');
|
const eventController = require('./event.controller');
|
||||||
|
const eventInscriptionController = require('./events_inscriptions.controller');
|
||||||
const eventReservationController = require('./events_reservations.controller');
|
const eventReservationController = require('./events_reservations.controller');
|
||||||
const eventValidation = require('./event.validations');
|
const eventValidation = require('./event.validations');
|
||||||
|
|
||||||
@ -331,17 +332,35 @@ routes.post('/admin/reservations',
|
|||||||
routes.get('/admin/reservations/:id',
|
routes.get('/admin/reservations/:id',
|
||||||
// isAdministratorUser,
|
// isAdministratorUser,
|
||||||
//SchemaValidator(eventValidation.ReservationInputType, true),
|
//SchemaValidator(eventValidation.ReservationInputType, true),
|
||||||
eventReservationController.findOne(),
|
(req, res, next) => {
|
||||||
|
return eventReservationController.findOne({
|
||||||
|
scopes: ['includeEvent', 'includeInscriptions']
|
||||||
|
})(req, res, next)
|
||||||
|
},
|
||||||
|
|
||||||
);
|
);
|
||||||
|
|
||||||
/*// Un ponente
|
routes.put('/admin/reservations/:id',
|
||||||
routes.get('/admin/speakers/:id',
|
// isAdministratorUser,
|
||||||
isAdministratorUser,
|
//SchemaValidator(eventValidation.ReservationInputType, true),
|
||||||
eventController.findOne({
|
eventReservationController.update(),
|
||||||
scopes: ['defaultScope', 'includeValues', 'includeMultimedias']
|
);
|
||||||
})
|
|
||||||
);*/
|
|
||||||
|
|
||||||
|
// Borrar ponente
|
||||||
|
routes.delete('/admin/reservations/:id',
|
||||||
|
// isAdministratorUser,
|
||||||
|
eventReservationController.delete()
|
||||||
|
);
|
||||||
|
|
||||||
|
routes.get('/inscriptions',
|
||||||
|
// isAdministratorUser,
|
||||||
|
//SchemaValidator(eventValidation.ReservationInputType, true),
|
||||||
|
(req, res, next) => {
|
||||||
|
return eventInscriptionController.find({
|
||||||
|
scopes: ['defaultScope']
|
||||||
|
})(req, res, next)
|
||||||
|
},
|
||||||
|
|
||||||
|
);
|
||||||
|
|
||||||
module.exports = routes;
|
module.exports = routes;
|
||||||
14
modules/events/events_inscriptions.controller.js
Normal file
14
modules/events/events_inscriptions.controller.js
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
const generateControllers = require('../../core/controllers');
|
||||||
|
const eventInscriptionService = require('./events_inscriptions.service');
|
||||||
|
|
||||||
|
|
||||||
|
// Module Name
|
||||||
|
const MODULE_NAME = '[eventInscription.controller]';
|
||||||
|
|
||||||
|
const controllerOptions = { MODULE_NAME };
|
||||||
|
const extraControllers = {};
|
||||||
|
|
||||||
|
module.exports = generateControllers(eventInscriptionService, extraControllers, controllerOptions);
|
||||||
|
|
||||||
@ -64,7 +64,8 @@ module.exports = function (sequelize, DataTypes) {
|
|||||||
defaultScope: {
|
defaultScope: {
|
||||||
order: [
|
order: [
|
||||||
['date', 'DESC']
|
['date', 'DESC']
|
||||||
]
|
],
|
||||||
|
include: [{ model: sequelize.models.User, as: 'user' }],
|
||||||
},
|
},
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
@ -101,8 +101,24 @@ module.exports = function (sequelize, DataTypes) {
|
|||||||
foreignKey: 'overflow_reservationId' });
|
foreignKey: 'overflow_reservationId' });
|
||||||
EventReservation.Entity = EventReservation.belongsTo(models.Entity, { foreignKey: 'entityId' });
|
EventReservation.Entity = EventReservation.belongsTo(models.Entity, { foreignKey: 'entityId' });
|
||||||
EventReservation.Event = EventReservation.belongsTo(models.Event, { foreignKey: 'eventId' });
|
EventReservation.Event = EventReservation.belongsTo(models.Event, { foreignKey: 'eventId' });
|
||||||
|
EventReservation.Inscriptions = EventReservation.hasMany(models.EventInscription, { foreignKey: 'reservationId' });
|
||||||
EventReservation.UserCreate = EventReservation.belongsTo(models.User, { foreignKey: 'userId' });
|
EventReservation.UserCreate = EventReservation.belongsTo(models.User, { foreignKey: 'userId' });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
EventReservation.addScope('includeEvent', () => {
|
||||||
|
return {
|
||||||
|
include: [
|
||||||
|
{ model: sequelize.models.Event}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
EventReservation.addScope('includeInscriptions', () => {
|
||||||
|
return {
|
||||||
|
include: [
|
||||||
|
{ model: sequelize.models.EventInscription }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
});
|
||||||
return EventReservation;
|
return EventReservation;
|
||||||
};
|
};
|
||||||
Loading…
Reference in New Issue
Block a user