Merge branch 'test' into 2687_fix_travel_cloneWithEntries
gitea/salix/pipeline/pr-test This commit looks good
Details
gitea/salix/pipeline/pr-test This commit looks good
Details
This commit is contained in:
commit
234ea26fe2
|
@ -21,7 +21,7 @@ pipeline {
|
||||||
steps {
|
steps {
|
||||||
script {
|
script {
|
||||||
// Uncomment to enable debugging
|
// Uncomment to enable debugging
|
||||||
//env.DEBUG = 'strong-remoting:http-context,strong-remoting:shared-method'
|
// env.DEBUG = 'strong-remoting:shared-method,puppeteer-cluster:*'
|
||||||
|
|
||||||
switch (env.BRANCH_NAME) {
|
switch (env.BRANCH_NAME) {
|
||||||
case 'dev':
|
case 'dev':
|
||||||
|
|
|
@ -1,23 +1,6 @@
|
||||||
const models = require('vn-loopback/server/server').models;
|
const models = require('vn-loopback/server/server').models;
|
||||||
|
|
||||||
describe('loopback model MailAliasAccount', () => {
|
describe('loopback model MailAliasAccount', () => {
|
||||||
it('should fail to add a mail Alias if the worker doesnt have ACLs', async() => {
|
|
||||||
const tx = await models.MailAliasAccount.beginTransaction({});
|
|
||||||
let error;
|
|
||||||
|
|
||||||
try {
|
|
||||||
const options = {transaction: tx, accessToken: {userId: 57}};
|
|
||||||
await models.MailAliasAccount.create({mailAlias: 2, account: 5}, options);
|
|
||||||
|
|
||||||
await tx.rollback();
|
|
||||||
} catch (e) {
|
|
||||||
await tx.rollback();
|
|
||||||
error = e;
|
|
||||||
}
|
|
||||||
|
|
||||||
expect(error.message).toEqual('The alias cant be modified');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should add a mail Alias', async() => {
|
it('should add a mail Alias', async() => {
|
||||||
const tx = await models.MailAliasAccount.beginTransaction({});
|
const tx = await models.MailAliasAccount.beginTransaction({});
|
||||||
let error;
|
let error;
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
DELETE FROM salix.ACL
|
||||||
|
WHERE model = 'MailAliasAccount'
|
||||||
|
AND property = 'canEditAlias'
|
||||||
|
AND principalType = 'ROLE'
|
||||||
|
AND principalId = 'marketingBoss';
|
|
@ -238,7 +238,7 @@ async function dockerStart() {
|
||||||
await myt.run(Start);
|
await myt.run(Start);
|
||||||
await myt.deinit();
|
await myt.deinit();
|
||||||
}
|
}
|
||||||
dockerStart.description = `Starts the salix-db container`;
|
dockerStart.description = `Starts the DB container`;
|
||||||
|
|
||||||
async function docker() {
|
async function docker() {
|
||||||
const myt = new Myt();
|
const myt = new Myt();
|
||||||
|
@ -246,7 +246,7 @@ async function docker() {
|
||||||
await myt.run(Run);
|
await myt.run(Run);
|
||||||
await myt.deinit();
|
await myt.deinit();
|
||||||
}
|
}
|
||||||
docker.description = `Runs the salix-db container`;
|
docker.description = `Builds and starts the DB container`;
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
default: defaultTask,
|
default: defaultTask,
|
||||||
|
|
|
@ -203,5 +203,7 @@
|
||||||
"Cannot past travels with entries": "Cannot past travels with entries",
|
"Cannot past travels with entries": "Cannot past travels with entries",
|
||||||
"It was not able to remove the next expeditions:": "It was not able to remove the next expeditions: {{expeditions}}",
|
"It was not able to remove the next expeditions:": "It was not able to remove the next expeditions: {{expeditions}}",
|
||||||
"Incorrect pin": "Incorrect pin.",
|
"Incorrect pin": "Incorrect pin.",
|
||||||
"The notification subscription of this worker cant be modified": "The notification subscription of this worker cant be modified"
|
"The notification subscription of this worker cant be modified": "The notification subscription of this worker cant be modified",
|
||||||
|
"You are not allowed to modify the alias": "You are not allowed to modify the alias",
|
||||||
|
"You already have the mailAlias": "You already have the mailAlias"
|
||||||
}
|
}
|
|
@ -139,7 +139,7 @@
|
||||||
"Claim state has changed to": "Se ha cambiado el estado de la reclamación [({{claimId}})]({{{claimUrl}}}) del cliente *{{clientName}}* a *{{newState}}*",
|
"Claim state has changed to": "Se ha cambiado el estado de la reclamación [({{claimId}})]({{{claimUrl}}}) del cliente *{{clientName}}* a *{{newState}}*",
|
||||||
"Client checked as validated despite of duplication": "Cliente comprobado a pesar de que existe el cliente id {{clientId}}",
|
"Client checked as validated despite of duplication": "Cliente comprobado a pesar de que existe el cliente id {{clientId}}",
|
||||||
"ORDER_ROW_UNAVAILABLE": "No hay disponibilidad de este producto",
|
"ORDER_ROW_UNAVAILABLE": "No hay disponibilidad de este producto",
|
||||||
"Distance must be lesser than 1000": "La distancia debe ser inferior a 1000",
|
"Distance must be lesser than 4000": "La distancia debe ser inferior a 4000",
|
||||||
"This ticket is deleted": "Este ticket está eliminado",
|
"This ticket is deleted": "Este ticket está eliminado",
|
||||||
"Unable to clone this travel": "No ha sido posible clonar este travel",
|
"Unable to clone this travel": "No ha sido posible clonar este travel",
|
||||||
"This thermograph id already exists": "La id del termógrafo ya existe",
|
"This thermograph id already exists": "La id del termógrafo ya existe",
|
||||||
|
@ -335,6 +335,6 @@
|
||||||
"This user does not have an assigned tablet": "Este usuario no tiene tablet asignada",
|
"This user does not have an assigned tablet": "Este usuario no tiene tablet asignada",
|
||||||
"Incorrect pin": "Pin incorrecto",
|
"Incorrect pin": "Pin incorrecto",
|
||||||
"You already have the mailAlias": "Ya tienes este alias de correo",
|
"You already have the mailAlias": "Ya tienes este alias de correo",
|
||||||
"The alias cant be modified": "Este alias de correo no puede ser modificado",
|
"You are not allowed to modify the alias": "No estás autorizado a modificar el alias",
|
||||||
"No tickets to invoice": "No hay tickets para facturar"
|
"No tickets to invoice": "No hay tickets para facturar"
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
|
|
||||||
const UserError = require('vn-loopback/util/user-error');
|
const ForbiddenError = require('vn-loopback/util/forbiddenError');
|
||||||
|
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
Self.rewriteDbError(function(err) {
|
Self.rewriteDbError(function(err) {
|
||||||
|
@ -8,38 +8,38 @@ module.exports = Self => {
|
||||||
return err;
|
return err;
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.observe('before save', async ctx => {
|
Self.beforeRemote('create', async function(ctx) {
|
||||||
const changes = ctx.currentInstance || ctx.instance;
|
const mailAlias = ctx.args.data?.mailAlias;
|
||||||
|
if (!mailAlias) return;
|
||||||
await checkModifyPermission(ctx, changes.mailAlias);
|
await checkModifyPermission(ctx, mailAlias);
|
||||||
});
|
});
|
||||||
|
Self.beforeRemote('deleteById', async function(ctx) {
|
||||||
Self.observe('before delete', async ctx => {
|
const instance = await Self.findById(ctx.args.id,
|
||||||
const mailAliasAccount = await Self.findById(ctx.where.id);
|
{fields: ['mailAlias']}
|
||||||
|
);
|
||||||
await checkModifyPermission(ctx, mailAliasAccount.mailAlias);
|
await checkModifyPermission(ctx, instance.mailAlias);
|
||||||
});
|
});
|
||||||
|
|
||||||
async function checkModifyPermission(ctx, mailAliasFk) {
|
async function checkModifyPermission(ctx, mailAliasFk) {
|
||||||
const userId = ctx.options.accessToken.userId;
|
|
||||||
const models = Self.app.models;
|
const models = Self.app.models;
|
||||||
|
const userId = ctx.req.accessToken.userId;
|
||||||
|
|
||||||
const roles = await models.RoleMapping.find({
|
const canEditAlias = await models.ACL.checkAccessAcl(ctx,
|
||||||
fields: ['roleId'],
|
'MailAliasAccount', 'canEditAlias', 'WRITE');
|
||||||
where: {principalId: userId}
|
if (canEditAlias) return;
|
||||||
|
|
||||||
|
const allowedRoles = await models.MailAliasAcl.find({
|
||||||
|
fields: ['roleFk'],
|
||||||
|
where: {mailAliasFk}
|
||||||
});
|
});
|
||||||
|
const nRoles = allowedRoles.length &&
|
||||||
|
await models.RoleMapping.count({
|
||||||
|
principalId: userId,
|
||||||
|
principalType: 'USER',
|
||||||
|
roleId: {inq: allowedRoles.map(x => x.roleFk)}
|
||||||
|
});
|
||||||
|
|
||||||
const availableMailAlias = await models.MailAliasAcl.findOne({
|
if (!nRoles)
|
||||||
fields: ['mailAliasFk'],
|
throw new ForbiddenError('You are not allowed to modify the alias');
|
||||||
include: {relation: 'mailAlias'},
|
|
||||||
where: {
|
|
||||||
roleFk: {
|
|
||||||
inq: roles.map(role => role.roleId),
|
|
||||||
},
|
|
||||||
mailAliasFk
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!availableMailAlias) throw new UserError('The alias cant be modified');
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -21,16 +21,16 @@ module.exports = Self => {
|
||||||
require('../methods/route/getByWorker')(Self);
|
require('../methods/route/getByWorker')(Self);
|
||||||
|
|
||||||
Self.validate('kmStart', validateDistance, {
|
Self.validate('kmStart', validateDistance, {
|
||||||
message: 'Distance must be lesser than 1000'
|
message: 'Distance must be lesser than 4000'
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.validate('kmEnd', validateDistance, {
|
Self.validate('kmEnd', validateDistance, {
|
||||||
message: 'Distance must be lesser than 1000'
|
message: 'Distance must be lesser than 4000'
|
||||||
});
|
});
|
||||||
|
|
||||||
function validateDistance(err) {
|
function validateDistance(err) {
|
||||||
const routeTotalKm = this.kmEnd - this.kmStart;
|
const routeTotalKm = this.kmEnd - this.kmStart;
|
||||||
const routeMaxKm = 1000;
|
const routeMaxKm = 4000;
|
||||||
if (routeTotalKm > routeMaxKm || this.kmStart > this.kmEnd)
|
if (routeTotalKm > routeMaxKm || this.kmStart > this.kmEnd)
|
||||||
err();
|
err();
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -36,7 +36,8 @@
|
||||||
"md5": "^2.2.1",
|
"md5": "^2.2.1",
|
||||||
"node-ssh": "^11.0.0",
|
"node-ssh": "^11.0.0",
|
||||||
"object.pick": "^1.3.0",
|
"object.pick": "^1.3.0",
|
||||||
"puppeteer": "^21.10.0",
|
"puppeteer": "^21.11.0",
|
||||||
|
"read-chunk": "^3.2.0",
|
||||||
"require-yaml": "0.0.1",
|
"require-yaml": "0.0.1",
|
||||||
"smbhash": "0.0.1",
|
"smbhash": "0.0.1",
|
||||||
"strong-error-handler": "^2.3.2",
|
"strong-error-handler": "^2.3.2",
|
||||||
|
|
|
@ -6,7 +6,7 @@ module.exports = {
|
||||||
init() {
|
init() {
|
||||||
if (this.pool) return;
|
if (this.pool) return;
|
||||||
Cluster.launch({
|
Cluster.launch({
|
||||||
concurrency: Cluster.CONCURRENCY_CONTEXT,
|
concurrency: Cluster.CONCURRENCY_PAGE,
|
||||||
maxConcurrency: cpus().length,
|
maxConcurrency: cpus().length,
|
||||||
puppeteerOptions: {
|
puppeteerOptions: {
|
||||||
headless: 'new',
|
headless: 'new',
|
||||||
|
|
|
@ -46,6 +46,9 @@ section.text-area {
|
||||||
padding-left: 1em;
|
padding-left: 1em;
|
||||||
padding-right: 1em;
|
padding-right: 1em;
|
||||||
background-color: #e5e5e5;
|
background-color: #e5e5e5;
|
||||||
|
& > p {
|
||||||
|
word-break: break-all;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.route-block {
|
.route-block {
|
||||||
|
|
|
@ -5,7 +5,6 @@ module.exports = {
|
||||||
mixins: [vnReport],
|
mixins: [vnReport],
|
||||||
async serverPrefetch() {
|
async serverPrefetch() {
|
||||||
let ids = this.id;
|
let ids = this.id;
|
||||||
|
|
||||||
const hasMultipleRoutes = String(this.id).includes(',');
|
const hasMultipleRoutes = String(this.id).includes(',');
|
||||||
if (hasMultipleRoutes)
|
if (hasMultipleRoutes)
|
||||||
ids = this.id.split(',');
|
ids = this.id.split(',');
|
||||||
|
@ -30,7 +29,7 @@ module.exports = {
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
id: {
|
id: {
|
||||||
type: Number,
|
type: String,
|
||||||
required: true,
|
required: true,
|
||||||
description: 'The route id'
|
description: 'The route id'
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@ SELECT pack.packages,
|
||||||
LEFT JOIN vn.province p ON p.id = c.provinceFk
|
LEFT JOIN vn.province p ON p.id = c.provinceFk
|
||||||
JOIN vn.ticket t ON t.refFk = io.ref
|
JOIN vn.ticket t ON t.refFk = io.ref
|
||||||
JOIN vn.address a ON a.id = t.addressFk
|
JOIN vn.address a ON a.id = t.addressFk
|
||||||
LEFT JOIN vn.incoterms ic ON ic.code = a.incotermsFk
|
JOIN vn.incoterms ic ON ic.code = a.incotermsFk
|
||||||
LEFT JOIN vn.customsAgent ca ON ca.id = a.customsAgentFk
|
LEFT JOIN vn.customsAgent ca ON ca.id = a.customsAgentFk
|
||||||
JOIN vn.sale s ON s.ticketFk = t.id
|
JOIN vn.sale s ON s.ticketFk = t.id
|
||||||
JOIN (
|
JOIN (
|
||||||
|
|
|
@ -1,8 +1,5 @@
|
||||||
SELECT IF(incotermsFk IS NULL, FALSE, TRUE) AS hasIncoterms
|
SELECT COUNT(*) AS hasIncoterms
|
||||||
FROM ticket t
|
FROM invoiceOut io
|
||||||
JOIN invoiceOut io ON io.ref = t.refFk
|
JOIN vn.invoiceOutSerial ios ON ios.code = io.serial
|
||||||
JOIN client c ON c.id = t.clientFk
|
AND ios.taxAreaFk = 'WORLD'
|
||||||
JOIN address a ON a.id = t.addressFk
|
WHERE io.ref = ?
|
||||||
WHERE t.refFk = ?
|
|
||||||
AND IF(c.hasToinvoiceByAddress = FALSE, c.defaultAddressFk, TRUE)
|
|
||||||
LIMIT 1
|
|
||||||
|
|
Loading…
Reference in New Issue