7253-devToTest_2418 #2350
|
@ -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');
|
||||
});
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue