Reports halfway through
Datatable now correctly handles the situation when user is not logged in and access protected resources
This commit is contained in:
parent
aba42d94ac
commit
3f7b428546
28 changed files with 421 additions and 471 deletions
|
@ -8,37 +8,37 @@ const interoperableErrors = require('../shared/interoperable-errors');
|
|||
|
||||
const allowedKeys = new Set(['name', 'description', 'mime_type', 'user_fields', 'js', 'hbs']);
|
||||
|
||||
function hash(ns) {
|
||||
return hasher.hash(filterObject(ns, allowedKeys));
|
||||
function hash(entity) {
|
||||
return hasher.hash(filterObject(entity, allowedKeys));
|
||||
}
|
||||
|
||||
async function getById(templateId) {
|
||||
const template = await knex('report_templates').where('id', templateId).first();
|
||||
if (!template) {
|
||||
async function getById(id) {
|
||||
const entity = await knex('report_templates').where('id', id).first();
|
||||
if (!entity) {
|
||||
throw new interoperableErrors.NotFoundError();
|
||||
}
|
||||
|
||||
return template;
|
||||
return entity;
|
||||
}
|
||||
|
||||
async function listDTAjax(params) {
|
||||
return await dtHelpers.ajaxList(params, tx => tx('report_templates'), ['report_templates.id', 'report_templates.name', 'report_templates.description', 'report_templates.created']);
|
||||
}
|
||||
|
||||
async function create(template) {
|
||||
const templateId = await knex('report_templates').insert(filterObject(template, allowedKeys));
|
||||
return templateId;
|
||||
async function create(entity) {
|
||||
const id = await knex('report_templates').insert(filterObject(entity, allowedKeys));
|
||||
return id;
|
||||
}
|
||||
|
||||
async function updateWithConsistencyCheck(template) {
|
||||
await knex.transaction(async tx => {
|
||||
const existingTemplate = await tx('report_templates').where('id', template.id).first();
|
||||
const existing = await tx('report_templates').where('id', template.id).first();
|
||||
if (!template) {
|
||||
throw new interoperableErrors.NotFoundError();
|
||||
}
|
||||
|
||||
const existingNsHash = hash(existingTemplate);
|
||||
if (existingNsHash != template.originalHash) {
|
||||
const existingHash = hash(existing);
|
||||
if (existingHash != template.originalHash) {
|
||||
throw new interoperableErrors.ChangedError();
|
||||
}
|
||||
|
||||
|
@ -46,8 +46,8 @@ async function updateWithConsistencyCheck(template) {
|
|||
});
|
||||
}
|
||||
|
||||
async function remove(templateId) {
|
||||
await knex('report_templates').where('id', templateId).del();
|
||||
async function remove(id) {
|
||||
await knex('report_templates').where('id', id).del();
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue