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) => {
return async (req, res, next) => {
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);
} catch (error) {
return handleErrorResponse(_options.MODULE_NAME, 'delete', error, res)

View File

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

View File

@ -72,7 +72,7 @@ module.exports = function (sequelize, DataTypes) {
EventInscription.associate = function (models) {
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.UserValidate = EventInscription.belongsTo(models.User, { foreignKey: 'validateUserId' });
};

View File

@ -101,23 +101,24 @@ module.exports = function (sequelize, DataTypes) {
foreignKey: 'overflow_reservationId' });
EventReservation.Entity = EventReservation.belongsTo(models.Entity, { foreignKey: 'entityId' });
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.addScope('includeEvent', () => {
return {
include: [
{ model: sequelize.models.Event}
]
include: [{
model: sequelize.models.Event
}]
}
});
EventReservation.addScope('includeInscriptions', () => {
return {
include: [
{ model: sequelize.models.EventInscription }
]
include: [{
model: sequelize.models.EventInscription,
as: 'inscriptions'
}]
}
});
return EventReservation;