Report templates ported to ReactJS and Knex.

Does not run yet because reports have dependencies on the old report templates.
This commit is contained in:
Tomas Bures 2017-07-09 15:41:53 +02:00
parent be7da791db
commit d4cea46f07
29 changed files with 807 additions and 688 deletions

50
lib/permissions.js Normal file
View file

@ -0,0 +1,50 @@
'use strict';
const config = require('config');
class ListPermission {
constructor(name) {
this.name = name;
this.entityType = 'list';
}
}
class NamespacePermission {
constructor(name) {
this.name = name;
this.entityType = 'namespace';
}
}
const ListPermissions = {
View: new ListPermissions('view')
};
const NamespacePermissions = {
View: new NamespacePermission('view'),
Edit: new NamespacePermission('edit'),
Create: new NamespacePermission('create'),
Delete: new NamespacePermission('delete'),
CreateList: new NamespacePermission('create list')
};
async function can(context, operation, entityId) {
if (!context.user) {
return false;
}
const result = await knex('permissions_' + operation.entityType).select(['id']).where({
entity: entityId,
user: context.user.id,
operation: operation.name
}).first();
return !!result;
}
async function buildPermissions() {
}
can(ctx, ListPermissions.View, 3)
can(ctx, NamespacePermissions.CreateList, 2)