This commit is contained in:
David Arranz 2019-08-16 23:27:18 +02:00
parent 4267e3a8c8
commit 42a6eefa48
4 changed files with 12 additions and 10 deletions

View File

@ -117,7 +117,8 @@ console.log('paraaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaams');
delete: (config) => { delete: (config) => {
return async (req, res, next) => { return async (req, res, next) => {
try { try {
const result = await service.delete(req.params, buildContext(req, config)); const params = extractParamsFromRequest(req, res, _options.params.delete);
const result = await service.delete(params, buildContext(req, config));
return handleResultResponse(result, null, req.params, res, httpStatus.NO_CONTENT); return handleResultResponse(result, null, req.params, res, httpStatus.NO_CONTENT);
} catch (error) { } catch (error) {
return handleErrorResponse(_options.MODULE_NAME, 'delete', error, res) return handleErrorResponse(_options.MODULE_NAME, 'delete', error, res)

View File

@ -346,7 +346,7 @@ routes.put('/admin/reservations/:id',
eventReservationController.update(), eventReservationController.update(),
); );
// Borrar ponente // Borrar reserva
routes.delete('/admin/reservations/:id', routes.delete('/admin/reservations/:id',
// isAdministratorUser, // isAdministratorUser,
eventReservationController.delete() eventReservationController.delete()

View File

@ -72,7 +72,7 @@ module.exports = function (sequelize, DataTypes) {
EventInscription.associate = function (models) { EventInscription.associate = function (models) {
EventInscription.Event = EventInscription.belongsTo(models.Event, { foreignKey: 'eventId', as: 'event' }); EventInscription.Event = EventInscription.belongsTo(models.Event, { foreignKey: 'eventId', as: 'event' });
EventInscription.Reservation = EventInscription.belongsTo(models.EventReservation, { foreignKey: 'reservationId', as: 'reservation' }); EventInscription.Reservation = EventInscription.belongsTo(models.EventReservation, { foreignKey: 'reservationId', as: 'reservation', onDelete: 'set null' });
EventInscription.User = EventInscription.belongsTo(models.User, { foreignKey: 'userId', as: 'user' }); EventInscription.User = EventInscription.belongsTo(models.User, { foreignKey: 'userId', as: 'user' });
EventInscription.UserValidate = EventInscription.belongsTo(models.User, { foreignKey: 'validateUserId' }); EventInscription.UserValidate = EventInscription.belongsTo(models.User, { foreignKey: 'validateUserId' });
}; };

View File

@ -101,23 +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.Inscriptions = EventReservation.hasMany(models.EventInscription, { foreignKey: 'reservationId', as: 'inscriptions' });
EventReservation.UserCreate = EventReservation.belongsTo(models.User, { foreignKey: 'userId' }); EventReservation.UserCreate = EventReservation.belongsTo(models.User, { foreignKey: 'userId' });
}; };
EventReservation.addScope('includeEvent', () => { EventReservation.addScope('includeEvent', () => {
return { return {
include: [ include: [{
{ model: sequelize.models.Event} model: sequelize.models.Event
] }]
} }
}); });
EventReservation.addScope('includeInscriptions', () => { EventReservation.addScope('includeInscriptions', () => {
return { return {
include: [ include: [{
{ model: sequelize.models.EventInscription } model: sequelize.models.EventInscription,
] as: 'inscriptions'
}]
} }
}); });
return EventReservation; return EventReservation;