Removed obsolete dir
Numeric conversions for all ids coming in as route req params. Infrastructure for proper error message when dependencies prevent entity deletion.
This commit is contained in:
parent
2b57396a5d
commit
0a08088893
636 changed files with 291 additions and 73346 deletions
|
@ -83,14 +83,21 @@ async function updateWithConsistencyCheck(context, entity) {
|
|||
|
||||
async function remove(context, id) {
|
||||
await knex.transaction(async tx => {
|
||||
const rows = await tx('templates').where('type', 'mosaico').select(['data']);
|
||||
for (const row of rows) {
|
||||
const deps = [];
|
||||
const tmpls = await tx('templates').where('type', 'mosaico').select(['id', 'name', 'data']);
|
||||
for (const row of tmpls) {
|
||||
const data = JSON.parse(row.data);
|
||||
if (data.template === id) {
|
||||
throw new interoperableErrors.DependencyPresentError();
|
||||
if (data.mosaicoTemplate === id) {
|
||||
deps.push({ entityTypeId: 'template', name: row.name, link: `templates/${row.id}` });
|
||||
}
|
||||
}
|
||||
|
||||
if (deps.length > 0) {
|
||||
throw new interoperableErrors.DependencyPresentError('', {
|
||||
dependencies: deps
|
||||
});
|
||||
}
|
||||
|
||||
await shares.enforceEntityPermissionTx(tx, context, 'mosaicoTemplate', id, 'delete');
|
||||
|
||||
await tx('mosaico_templates').where('id', id).del();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue