feat: refs #6724 permissions to vn.entry.isBooked #2147

Merged
guillermo merged 9 commits from 6724-permisos-vn.entry.isBooked into dev 2024-04-18 11:06:48 +00:00
1 changed files with 11 additions and 0 deletions
Showing only changes of commit a62e189e47 - Show all commits

View File

@ -46,4 +46,15 @@ module.exports = Self => {
}
}
});
Self.observe('before delete', async function(ctx) {
let isBooked = ctx.instance && ctx.instance.isBooked;
if (isBooked === undefined) {
const entryInstance = await Self.findById(ctx.where.id);
isBooked = entryInstance.isBooked;
}
if (isBooked) throw new Error('Booked entry cannot be deleted');
guillermo marked this conversation as resolved Outdated

Esta parte sobra, ya se ha realizado en un trigger de la db

Esta parte sobra, ya se ha realizado en un trigger de la db
});
};