Merge branch 'master' of https://gitea.verdnatura.es/verdnatura/salix into test
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
commit
fddbf6451b
|
@ -21,7 +21,7 @@ pipeline {
|
|||
steps {
|
||||
script {
|
||||
// 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) {
|
||||
case 'dev':
|
||||
|
|
|
@ -1,23 +1,6 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
|
||||
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() => {
|
||||
const tx = await models.MailAliasAccount.beginTransaction({});
|
||||
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.deinit();
|
||||
}
|
||||
dockerStart.description = `Starts the salix-db container`;
|
||||
dockerStart.description = `Starts the DB container`;
|
||||
|
||||
async function docker() {
|
||||
const myt = new Myt();
|
||||
|
@ -246,7 +246,7 @@ async function docker() {
|
|||
await myt.run(Run);
|
||||
await myt.deinit();
|
||||
}
|
||||
docker.description = `Runs the salix-db container`;
|
||||
docker.description = `Builds and starts the DB container`;
|
||||
|
||||
module.exports = {
|
||||
default: defaultTask,
|
||||
|
|
|
@ -203,5 +203,7 @@
|
|||
"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}}",
|
||||
"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}}*",
|
||||
"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",
|
||||
"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",
|
||||
"Unable to clone this travel": "No ha sido posible clonar este travel",
|
||||
"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",
|
||||
"Incorrect pin": "Pin incorrecto",
|
||||
"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"
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
const UserError = require('vn-loopback/util/user-error');
|
||||
const ForbiddenError = require('vn-loopback/util/forbiddenError');
|
||||
|
||||
module.exports = Self => {
|
||||
Self.rewriteDbError(function(err) {
|
||||
|
@ -8,38 +8,38 @@ module.exports = Self => {
|
|||
return err;
|
||||
});
|
||||
|
||||
Self.observe('before save', async ctx => {
|
||||
const changes = ctx.currentInstance || ctx.instance;
|
||||
|
||||
await checkModifyPermission(ctx, changes.mailAlias);
|
||||
Self.beforeRemote('create', async function(ctx) {
|
||||
const mailAlias = ctx.args.data?.mailAlias;
|
||||
if (!mailAlias) return;
|
||||
await checkModifyPermission(ctx, mailAlias);
|
||||
});
|
||||
|
||||
Self.observe('before delete', async ctx => {
|
||||
const mailAliasAccount = await Self.findById(ctx.where.id);
|
||||
|
||||
await checkModifyPermission(ctx, mailAliasAccount.mailAlias);
|
||||
Self.beforeRemote('deleteById', async function(ctx) {
|
||||
const instance = await Self.findById(ctx.args.id,
|
||||
{fields: ['mailAlias']}
|
||||
);
|
||||
await checkModifyPermission(ctx, instance.mailAlias);
|
||||
});
|
||||
|
||||
async function checkModifyPermission(ctx, mailAliasFk) {
|
||||
const userId = ctx.options.accessToken.userId;
|
||||
const models = Self.app.models;
|
||||
const userId = ctx.req.accessToken.userId;
|
||||
|
||||
const roles = await models.RoleMapping.find({
|
||||
fields: ['roleId'],
|
||||
where: {principalId: userId}
|
||||
const canEditAlias = await models.ACL.checkAccessAcl(ctx,
|
||||
'MailAliasAccount', 'canEditAlias', 'WRITE');
|
||||
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({
|
||||
fields: ['mailAliasFk'],
|
||||
include: {relation: 'mailAlias'},
|
||||
where: {
|
||||
roleFk: {
|
||||
inq: roles.map(role => role.roleId),
|
||||
},
|
||||
mailAliasFk
|
||||
}
|
||||
});
|
||||
|
||||
if (!availableMailAlias) throw new UserError('The alias cant be modified');
|
||||
if (!nRoles)
|
||||
throw new ForbiddenError('You are not allowed to modify the alias');
|
||||
}
|
||||
};
|
||||
|
|
|
@ -21,16 +21,16 @@ module.exports = Self => {
|
|||
require('../methods/route/getByWorker')(Self);
|
||||
|
||||
Self.validate('kmStart', validateDistance, {
|
||||
message: 'Distance must be lesser than 1000'
|
||||
message: 'Distance must be lesser than 4000'
|
||||
});
|
||||
|
||||
Self.validate('kmEnd', validateDistance, {
|
||||
message: 'Distance must be lesser than 1000'
|
||||
message: 'Distance must be lesser than 4000'
|
||||
});
|
||||
|
||||
function validateDistance(err) {
|
||||
const routeTotalKm = this.kmEnd - this.kmStart;
|
||||
const routeMaxKm = 1000;
|
||||
const routeMaxKm = 4000;
|
||||
if (routeTotalKm > routeMaxKm || this.kmStart > this.kmEnd)
|
||||
err();
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -36,7 +36,8 @@
|
|||
"md5": "^2.2.1",
|
||||
"node-ssh": "^11.0.0",
|
||||
"object.pick": "^1.3.0",
|
||||
"puppeteer": "^21.10.0",
|
||||
"puppeteer": "^21.11.0",
|
||||
"read-chunk": "^3.2.0",
|
||||
"require-yaml": "0.0.1",
|
||||
"smbhash": "0.0.1",
|
||||
"strong-error-handler": "^2.3.2",
|
||||
|
|
|
@ -6,7 +6,7 @@ module.exports = {
|
|||
init() {
|
||||
if (this.pool) return;
|
||||
Cluster.launch({
|
||||
concurrency: Cluster.CONCURRENCY_CONTEXT,
|
||||
concurrency: Cluster.CONCURRENCY_PAGE,
|
||||
maxConcurrency: cpus().length,
|
||||
puppeteerOptions: {
|
||||
headless: 'new',
|
||||
|
|
|
@ -46,6 +46,9 @@ section.text-area {
|
|||
padding-left: 1em;
|
||||
padding-right: 1em;
|
||||
background-color: #e5e5e5;
|
||||
& > p {
|
||||
word-break: break-all;
|
||||
}
|
||||
}
|
||||
|
||||
.route-block {
|
||||
|
|
|
@ -5,7 +5,6 @@ module.exports = {
|
|||
mixins: [vnReport],
|
||||
async serverPrefetch() {
|
||||
let ids = this.id;
|
||||
|
||||
const hasMultipleRoutes = String(this.id).includes(',');
|
||||
if (hasMultipleRoutes)
|
||||
ids = this.id.split(',');
|
||||
|
@ -30,7 +29,7 @@ module.exports = {
|
|||
},
|
||||
props: {
|
||||
id: {
|
||||
type: Number,
|
||||
type: String,
|
||||
required: true,
|
||||
description: 'The route id'
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ SELECT pack.packages,
|
|||
LEFT JOIN vn.province p ON p.id = c.provinceFk
|
||||
JOIN vn.ticket t ON t.refFk = io.ref
|
||||
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
|
||||
JOIN vn.sale s ON s.ticketFk = t.id
|
||||
JOIN (
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
SELECT IF(incotermsFk IS NULL, FALSE, TRUE) AS hasIncoterms
|
||||
FROM ticket t
|
||||
JOIN invoiceOut io ON io.ref = t.refFk
|
||||
JOIN client c ON c.id = t.clientFk
|
||||
JOIN address a ON a.id = t.addressFk
|
||||
WHERE t.refFk = ?
|
||||
AND IF(c.hasToinvoiceByAddress = FALSE, c.defaultAddressFk, TRUE)
|
||||
LIMIT 1
|
||||
SELECT COUNT(*) AS hasIncoterms
|
||||
FROM invoiceOut io
|
||||
JOIN vn.invoiceOutSerial ios ON ios.code = io.serial
|
||||
AND ios.taxAreaFk = 'WORLD'
|
||||
WHERE io.ref = ?
|
||||
|
|
Loading…
Reference in New Issue