feat: refs #6724 hook added
gitea/salix/pipeline/pr-dev There was a failure building this commit Details

This commit is contained in:
Jorge Penadés 2024-03-28 16:10:52 +01:00
parent 3e1f8b5937
commit a62e189e47
1 changed files with 11 additions and 0 deletions

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');
});
};