Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into 1781-zoneHoliday
gitea/salix/pipeline/head This commit is unstable
Details
gitea/salix/pipeline/head This commit is unstable
Details
This commit is contained in:
commit
e9c98a98e7
|
@ -5,17 +5,17 @@ module.exports = Self => {
|
|||
accepts: [
|
||||
{
|
||||
arg: 'id',
|
||||
type: 'Number',
|
||||
type: 'number',
|
||||
description: 'The user id',
|
||||
http: {source: 'path'}
|
||||
}, {
|
||||
arg: 'oldPassword',
|
||||
type: 'String',
|
||||
type: 'string',
|
||||
description: 'The old password',
|
||||
required: true
|
||||
}, {
|
||||
arg: 'newPassword',
|
||||
type: 'String',
|
||||
type: 'string',
|
||||
description: 'The new password',
|
||||
required: true
|
||||
}
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
CREATE TABLE `vn`.`mdbBranch` (
|
||||
`name` VARCHAR(255),
|
||||
PRIMARY KEY(`name`)
|
||||
);
|
||||
|
||||
CREATE TABLE `vn`.`mdbVersion` (
|
||||
`app` VARCHAR(255) NOT NULL,
|
||||
`branchFk` VARCHAR(255) NOT NULL,
|
||||
`version` INT,
|
||||
CONSTRAINT `mdbVersion_branchFk` FOREIGN KEY (`branchFk`) REFERENCES `vn`.`mdbBranch` (`name`) ON DELETE CASCADE ON UPDATE CASCADE
|
||||
);
|
||||
|
||||
INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
|
||||
VALUES('MdbVersion', '*', '*', 'ALLOW', 'ROLE', 'developer');
|
|
@ -2588,3 +2588,12 @@ INSERT INTO `vn`.`zoneExclusionGeo` (`zoneExclusionFk`, `geoFk`)
|
|||
VALUES
|
||||
(2, 1);
|
||||
|
||||
INSERT INTO `vn`.`mdbBranch` (`name`)
|
||||
VALUES
|
||||
('test'),
|
||||
('master');
|
||||
|
||||
INSERT INTO `vn`.`mdbVersion` (`app`, `branchFk`, `version`)
|
||||
VALUES
|
||||
('tpv', 'test', '1'),
|
||||
('lab', 'master', '1');
|
||||
|
|
|
@ -32,6 +32,7 @@ services:
|
|||
- /mnt/appdata/pdfs:/var/lib/salix/pdfs
|
||||
- /mnt/appdata/dms:/var/lib/salix/dms
|
||||
- /mnt/appdata/image:/var/lib/salix/image
|
||||
- /mnt/appdata/vn-access:/var/lib/salix/vn-access
|
||||
deploy:
|
||||
replicas: ${BACK_REPLICAS:?}
|
||||
placement:
|
||||
|
|
|
@ -123,19 +123,19 @@ describe('Client lock verified data path', () => {
|
|||
await page.accessToSection('client.card.fiscalData');
|
||||
}, 20000);
|
||||
|
||||
it('should confirm verified data button is disabled for salesAssistant', async() => {
|
||||
it('should confirm verified data button is enabled for salesAssistant', async() => {
|
||||
const isDisabled = await page.isDisabled(selectors.clientFiscalData.verifiedDataCheckbox);
|
||||
|
||||
expect(isDisabled).toBeTrue();
|
||||
expect(isDisabled).toBeFalsy();
|
||||
});
|
||||
|
||||
it('should return error when edit the social name', async() => {
|
||||
it('should now edit the social name', async() => {
|
||||
await page.clearInput(selectors.clientFiscalData.socialName);
|
||||
await page.write(selectors.clientFiscalData.socialName, 'new social name edition');
|
||||
await page.waitToClick(selectors.clientFiscalData.saveButton);
|
||||
const message = await page.waitForSnackbar();
|
||||
|
||||
expect(message.text).toContain(`Not enough privileges to edit a client with verified data`);
|
||||
expect(message.text).toContain(`Data saved!`);
|
||||
});
|
||||
|
||||
it('should now confirm the social name have been edited once and for all', async() => {
|
||||
|
|
|
@ -98,5 +98,15 @@
|
|||
"image/jpg",
|
||||
"video/mp4"
|
||||
]
|
||||
},
|
||||
"accessStorage": {
|
||||
"name": "accessStorage",
|
||||
"connector": "loopback-component-storage",
|
||||
"provider": "filesystem",
|
||||
"root": "./storage/access",
|
||||
"maxFileSize": "524288000",
|
||||
"allowedContentTypes": [
|
||||
"application/x-7z-compressed"
|
||||
]
|
||||
}
|
||||
}
|
|
@ -86,7 +86,6 @@ module.exports = Self => {
|
|||
};
|
||||
ticketFk = await createTicket(ctx, myOptions);
|
||||
}
|
||||
|
||||
await models.Sale.create({
|
||||
ticketFk: ticketFk,
|
||||
itemFk: sale.itemFk,
|
||||
|
|
|
@ -125,10 +125,10 @@ module.exports = Self => {
|
|||
}
|
||||
|
||||
try {
|
||||
const isAdministrative = await models.Account.hasRole(userId, 'administrative', myOptions);
|
||||
const isSalesAssistant = await models.Account.hasRole(userId, 'salesAssistant', myOptions);
|
||||
const client = await models.Client.findById(clientId, null, myOptions);
|
||||
|
||||
if (!isAdministrative && client.isTaxDataChecked)
|
||||
if (!isSalesAssistant && client.isTaxDataChecked)
|
||||
throw new UserError(`Not enough privileges to edit a client with verified data`);
|
||||
|
||||
// Sage data validation
|
||||
|
|
|
@ -232,7 +232,6 @@ module.exports = Self => {
|
|||
const loopBackContext = LoopBackContext.getCurrentContext();
|
||||
const userId = loopBackContext.active.accessToken.userId;
|
||||
|
||||
const isAdministrative = await models.Account.hasRole(userId, 'administrative', ctx.options);
|
||||
const isSalesAssistant = await models.Account.hasRole(userId, 'salesAssistant', ctx.options);
|
||||
const hasChanges = orgData && changes;
|
||||
|
||||
|
@ -245,7 +244,7 @@ module.exports = Self => {
|
|||
const sageTransactionType = hasChanges && (changes.sageTransactionTypeFk || orgData.sageTransactionTypeFk);
|
||||
const sageTransactionTypeChanged = hasChanges && orgData.sageTransactionTypeFk != sageTransactionType;
|
||||
|
||||
const cantEditVerifiedData = isTaxDataCheckedChanged && !isAdministrative;
|
||||
const cantEditVerifiedData = isTaxDataCheckedChanged && !isSalesAssistant;
|
||||
const cantChangeSageData = (sageTaxTypeChanged || sageTransactionTypeChanged) && !isSalesAssistant;
|
||||
|
||||
if (cantEditVerifiedData || cantChangeSageData)
|
||||
|
|
|
@ -182,7 +182,7 @@
|
|||
vn-one
|
||||
label="Verified data"
|
||||
ng-model="$ctrl.client.isTaxDataChecked"
|
||||
vn-acl="administrative">
|
||||
vn-acl="salesAssistant">
|
||||
</vn-check>
|
||||
</vn-horizontal>
|
||||
</vn-card>
|
||||
|
|
|
@ -0,0 +1,121 @@
|
|||
const fs = require('fs-extra');
|
||||
const path = require('path');
|
||||
const UserError = require('vn-loopback/util/user-error');
|
||||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('upload', {
|
||||
description: 'Upload and attach a access file',
|
||||
accepts: [
|
||||
{
|
||||
arg: 'appName',
|
||||
type: 'string',
|
||||
required: true,
|
||||
description: 'The app name'
|
||||
},
|
||||
{
|
||||
arg: 'newVersion',
|
||||
type: 'number',
|
||||
required: true,
|
||||
description: `The new version number`
|
||||
},
|
||||
{
|
||||
arg: 'branch',
|
||||
type: 'string',
|
||||
required: true,
|
||||
description: `The branch name`
|
||||
}
|
||||
],
|
||||
returns: {
|
||||
type: ['object'],
|
||||
root: true
|
||||
},
|
||||
http: {
|
||||
path: `/upload`,
|
||||
verb: 'POST'
|
||||
}
|
||||
});
|
||||
|
||||
Self.upload = async(ctx, appName, newVersion, branch, options) => {
|
||||
const models = Self.app.models;
|
||||
const myOptions = {};
|
||||
|
||||
const TempContainer = models.TempContainer;
|
||||
const AccessContainer = models.AccessContainer;
|
||||
const fileOptions = {};
|
||||
|
||||
let tx;
|
||||
|
||||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
|
||||
if (!myOptions.transaction) {
|
||||
tx = await Self.beginTransaction({});
|
||||
myOptions.transaction = tx;
|
||||
}
|
||||
|
||||
let srcFile;
|
||||
try {
|
||||
const tempContainer = await TempContainer.container('access');
|
||||
const uploaded = await TempContainer.upload(tempContainer.name, ctx.req, ctx.result, fileOptions);
|
||||
const files = Object.values(uploaded.files).map(file => {
|
||||
return file[0];
|
||||
});
|
||||
const uploadedFile = files[0];
|
||||
|
||||
const file = await TempContainer.getFile(tempContainer.name, uploadedFile.name);
|
||||
srcFile = path.join(file.client.root, file.container, file.name);
|
||||
|
||||
const accessContainer = await AccessContainer.container('.archive');
|
||||
const destinationFile = path.join(
|
||||
accessContainer.client.root, accessContainer.name, appName, `${newVersion}.7z`);
|
||||
|
||||
if (process.env.NODE_ENV == 'test')
|
||||
await fs.unlink(srcFile);
|
||||
else {
|
||||
await fs.move(srcFile, destinationFile, {
|
||||
overwrite: true
|
||||
});
|
||||
await fs.chmod(destinationFile, 0o644);
|
||||
|
||||
const existBranch = await models.MdbBranch.findOne({
|
||||
where: {name: branch}
|
||||
});
|
||||
|
||||
if (!existBranch)
|
||||
throw new UserError('Not exist this branch');
|
||||
|
||||
const branchPath = path.join(accessContainer.client.root, 'branches', branch);
|
||||
await fs.mkdir(branchPath, {recursive: true});
|
||||
|
||||
const destinationBranch = path.join(branchPath, `${appName}.7z`);
|
||||
const destinationRoot = path.join(accessContainer.client.root, `${appName}.7z`);
|
||||
try {
|
||||
await fs.unlink(destinationBranch);
|
||||
} catch (e) {}
|
||||
await fs.symlink(destinationFile, destinationBranch);
|
||||
|
||||
if (branch == 'master') {
|
||||
try {
|
||||
await fs.unlink(destinationRoot);
|
||||
} catch (e) {}
|
||||
await fs.symlink(destinationFile, destinationRoot);
|
||||
}
|
||||
}
|
||||
|
||||
await models.MdbVersion.upsert({
|
||||
app: appName,
|
||||
branchFk: branch,
|
||||
version: newVersion
|
||||
});
|
||||
|
||||
if (tx) await tx.commit();
|
||||
} catch (e) {
|
||||
if (tx) await tx.rollback();
|
||||
|
||||
if (fs.existsSync(srcFile))
|
||||
await fs.unlink(srcFile);
|
||||
|
||||
throw e;
|
||||
}
|
||||
};
|
||||
};
|
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"MdbBranch": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"MdbVersion": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"AccessContainer": {
|
||||
"dataSource": "accessStorage"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
"name": "AccessContainer",
|
||||
"base": "Container",
|
||||
"acls": [{
|
||||
"accessType": "*",
|
||||
"principalType": "ROLE",
|
||||
"principalId": "developer",
|
||||
"permission": "ALLOW"
|
||||
}]
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
"name": "MdbBranch",
|
||||
"base": "VnModel",
|
||||
"options": {
|
||||
"mysql": {
|
||||
"table": "mdbBranch"
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
"name": {
|
||||
"id": true,
|
||||
"type": "string",
|
||||
"description": "Identifier"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = Self => {
|
||||
require('../methods/mdbVersion/upload')(Self);
|
||||
};
|
|
@ -0,0 +1,26 @@
|
|||
{
|
||||
"name": "MdbVersion",
|
||||
"base": "VnModel",
|
||||
"options": {
|
||||
"mysql": {
|
||||
"table": "mdbVersion"
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
"app": {
|
||||
"type": "string",
|
||||
"description": "The app name",
|
||||
"id": true
|
||||
},
|
||||
"version": {
|
||||
"type": "number"
|
||||
}
|
||||
},
|
||||
"relations": {
|
||||
"branch": {
|
||||
"type": "belongsTo",
|
||||
"model": "MdbBranch",
|
||||
"foreignKey": "branchFk"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -304,7 +304,8 @@ module.exports = Self => {
|
|||
{'tp.hasTicketRequest': true},
|
||||
{'tp.hasComponentLack': true},
|
||||
{'tp.isTaxDataChecked': false},
|
||||
{'tp.itemShortage': {neq: null}}
|
||||
{'tp.itemShortage': {neq: null}},
|
||||
{'tp.isTooLittle': true}
|
||||
]};
|
||||
} else if (hasProblems === false) {
|
||||
whereProblems = {and: [
|
||||
|
@ -313,7 +314,8 @@ module.exports = Self => {
|
|||
{'tp.hasTicketRequest': false},
|
||||
{'tp.hasComponentLack': false},
|
||||
{'tp.isTaxDataChecked': true},
|
||||
{'tp.itemShortage': null}
|
||||
{'tp.itemShortage': null},
|
||||
{'tp.isTooLittle': false}
|
||||
]};
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
Forces tmp folder creation!
|
Loading…
Reference in New Issue