.
This commit is contained in:
parent
4267e3a8c8
commit
42a6eefa48
@ -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)
|
||||||
|
|||||||
@ -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()
|
||||||
|
|||||||
@ -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' });
|
||||||
};
|
};
|
||||||
|
|||||||
@ -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;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user