fix(ticket): canEdit use aclFunc
gitea/salix/pipeline/head There was a failure building this commit
Details
gitea/salix/pipeline/head There was a failure building this commit
Details
This commit is contained in:
parent
fe8ae164eb
commit
5f39249edb
|
@ -14,23 +14,22 @@ module.exports = Self => {
|
|||
root: true
|
||||
},
|
||||
http: {
|
||||
path: `/isEditable`,
|
||||
path: `/canEdit`,
|
||||
verb: 'get'
|
||||
}
|
||||
});
|
||||
|
||||
Self.canEdit = async(ctx, sales, options) => {
|
||||
const models = Self.app.models;
|
||||
const userId = ctx.req.accessToken.userId;
|
||||
const myOptions = {};
|
||||
|
||||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
|
||||
/* const firstSale = await models.Sale.findById(sales[0], null, myOptions);
|
||||
const firstSale = await models.Sale.findById(sales[0], null, myOptions);
|
||||
const isTicketEditable = await models.Ticket.isEditable(ctx, firstSale.ticketFk, myOptions);
|
||||
if (!isTicketEditable)
|
||||
throw new UserError(`The sales of this ticket can't be modified`);*/
|
||||
throw new UserError(`The sales of this ticket can't be modified`);
|
||||
|
||||
const saleTracking = await models.SaleTracking.find({where: {saleFk: {inq: sales}}}, myOptions);
|
||||
const hasSaleTracking = saleTracking.length;
|
||||
|
@ -38,15 +37,11 @@ module.exports = Self => {
|
|||
const saleCloned = await models.SaleCloned.find({where: {saleClonedFk: {inq: sales}}}, myOptions);
|
||||
const hasSaleCloned = saleCloned.length;
|
||||
|
||||
/* const isProductionRole = await models.Account.hasRole(userId, 'production', myOptions);
|
||||
const canEdit = (isProductionRole || !hasSaleTracking);// && (isRole || !hasSaleCloned);
|
||||
const canEditTracked = await models.Account.aclFunc(ctx, 'editTracked');
|
||||
const canEditCloned = await models.Account.aclFunc(ctx, 'editCloned');
|
||||
|
||||
const isRole = await models.Account.hasRole(userId, 'developer', myOptions);*/
|
||||
const editTracked = await models.Account.aclFunc(ctx, 'editTracked');
|
||||
const editCloned = await models.Account.aclFunc(ctx, 'editCloned');
|
||||
console.log(editTracked);
|
||||
const canEdit = (editTracked || !hasSaleTracking) && (editCloned || !hasSaleCloned);
|
||||
const canEdit = (canEditTracked || !hasSaleTracking) && (canEditCloned || !hasSaleCloned);
|
||||
|
||||
return canEdit;// && isTicketEditable;
|
||||
return canEdit;
|
||||
};
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue