ACL's
gitea/salix/pipeline/head There was a failure building this commit Details

This commit is contained in:
Joan Sanchez 2022-09-30 13:54:20 +02:00
parent 1ac35c0b68
commit 3b0f1efbf4
25 changed files with 54 additions and 32 deletions

View File

@ -2,20 +2,22 @@ INSERT INTO `salix`.`ACL` (model, property, accessType, permission, principalTyp
VALUES VALUES
('ClientConsumptionQueue', '*', 'WRITE', 'ALLOW', 'ROLE', 'employee'), ('ClientConsumptionQueue', '*', 'WRITE', 'ALLOW', 'ROLE', 'employee'),
('Ticket', 'deliveryNotePdf', 'READ', 'ALLOW', 'ROLE', 'employee'), ('Ticket', 'deliveryNotePdf', 'READ', 'ALLOW', 'ROLE', 'employee'),
('Ticket', 'deliveryNoteEmail', 'READ', 'ALLOW', 'ROLE', 'employee'), ('Ticket', 'deliveryNoteEmail', 'WRITE', 'ALLOW', 'ROLE', 'employee'),
('Client', 'campaignMetricsPdf', 'READ', 'ALLOW', 'ROLE', 'employee'), ('Client', 'campaignMetricsPdf', 'READ', 'ALLOW', 'ROLE', 'employee'),
('Client', 'campaignMetricsEmail', 'READ', 'ALLOW', 'ROLE', 'employee'), ('Client', 'campaignMetricsEmail', 'WRITE', 'ALLOW', 'ROLE', 'employee'),
('Client', 'clientWelcomeHtml', 'READ', 'ALLOW', 'ROLE', 'employee'), ('Client', 'clientWelcomeHtml', 'READ', 'ALLOW', 'ROLE', 'employee'),
('Client', 'clientWelcomeEmail', 'READ', 'ALLOW', 'ROLE', 'employee'), ('Client', 'clientWelcomeEmail', 'WRITE', 'ALLOW', 'ROLE', 'employee'),,
('Client', 'creditRequestHtml', 'READ', 'ALLOW', 'ROLE', 'employee'),
('Client', 'creditRequestEmail', 'WRITE', 'ALLOW', 'ROLE', 'employee'),
('Client', 'printerSetupHtml', 'READ', 'ALLOW', 'ROLE', 'employee'), ('Client', 'printerSetupHtml', 'READ', 'ALLOW', 'ROLE', 'employee'),
('Client', 'printerSetupEmail', 'READ', 'ALLOW', 'ROLE', 'employee'), ('Client', 'printerSetupEmail', 'WRITE', 'ALLOW', 'ROLE', 'employee'),
('Client', 'sepaCoreEmail', 'READ', 'ALLOW', 'ROLE', 'employee'), ('Client', 'sepaCoreEmail', 'WRITE', 'ALLOW', 'ROLE', 'employee'),
('Client', 'letterDebtorStHtml', 'READ', 'ALLOW', 'ROLE', 'employee'), ('Client', 'letterDebtorStHtml', 'READ', 'ALLOW', 'ROLE', 'employee'),
('Client', 'letterDebtorStEmail', 'READ', 'ALLOW', 'ROLE', 'employee'), ('Client', 'letterDebtorStEmail', 'WRITE', 'ALLOW', 'ROLE', 'employee'),
('Client', 'letterDebtorNdHtml', 'READ', 'ALLOW', 'ROLE', 'employee'), ('Client', 'letterDebtorNdHtml', 'READ', 'ALLOW', 'ROLE', 'employee'),
('Client', 'letterDebtorNdEmail', 'READ', 'ALLOW', 'ROLE', 'employee'), ('Client', 'letterDebtorNdEmail', 'WRITE', 'ALLOW', 'ROLE', 'employee'),
('Client', 'clientDebtStatementHtml', 'READ', 'ALLOW', 'ROLE', 'employee'), ('Client', 'clientDebtStatementHtml', 'READ', 'ALLOW', 'ROLE', 'employee'),
('Client', 'clientDebtStatementEmail', 'READ', 'ALLOW', 'ROLE', 'employee'), ('Client', 'clientDebtStatementEmail', 'WRITE', 'ALLOW', 'ROLE', 'employee'),
('Client', 'incotermsAuthorizationHtml', 'READ', 'ALLOW', 'ROLE', 'employee'), ('Client', 'incotermsAuthorizationHtml', 'READ', 'ALLOW', 'ROLE', 'employee'),
('Client', 'incotermsAuthorizationEmail', 'WRITE', 'ALLOW', 'ROLE', 'employee'), ('Client', 'incotermsAuthorizationEmail', 'WRITE', 'ALLOW', 'ROLE', 'employee'),
('Client', 'consumptionSendQueued', 'WRITE', 'ALLOW', 'ROLE', 'system'), ('Client', 'consumptionSendQueued', 'WRITE', 'ALLOW', 'ROLE', 'system'),
@ -28,7 +30,9 @@ INSERT INTO `salix`.`ACL` (model, property, accessType, permission, principalTyp
('Travel', 'extraCommunityEmail', 'WRITE', 'ALLOW', 'ROLE', 'employee'), ('Travel', 'extraCommunityEmail', 'WRITE', 'ALLOW', 'ROLE', 'employee'),
('Entry', 'entryOrderPdf', 'READ', 'ALLOW', 'ROLE', 'employee'), ('Entry', 'entryOrderPdf', 'READ', 'ALLOW', 'ROLE', 'employee'),
('OsTicket', 'osTicketReportEmail', 'WRITE', 'ALLOW', 'ROLE', 'system'), ('OsTicket', 'osTicketReportEmail', 'WRITE', 'ALLOW', 'ROLE', 'system'),
('Item', 'buyerWasteEmail', 'WRITE', 'ALLOW', 'ROLE', 'system'); ('Item', 'buyerWasteEmail', 'WRITE', 'ALLOW', 'ROLE', 'system'),
('Claim', 'claimPickupPdf', 'READ', 'ALLOW', 'ROLE', 'employee'),
('Claim', 'claimPickupEmail', 'WRITE', 'ALLOW', 'ROLE', 'claimManager');
INSERT INTO `salix`.`ACL` (model,property,accessType,permission,principalType,principalId) INSERT INTO `salix`.`ACL` (model,property,accessType,permission,principalType,principalId)
VALUES ('Sector','*','READ','ALLOW','ROLE','employee'); VALUES ('Sector','*','READ','ALLOW','ROLE','employee');

View File

@ -3,4 +3,4 @@ alter table `vn`.`sample`
UPDATE vn.sample t UPDATE vn.sample t
SET t.model = 'Clients' SET t.model = 'Clients'
WHERE t.id IN(13, 14, 15, 16, 18, 19, 20); WHERE t.id IN(12, 13, 14, 15, 16, 18, 19, 20);

View File

@ -5,8 +5,6 @@
<slot-menu> <slot-menu>
<vn-item <vn-item
ng-click="$ctrl.showPickupOrder()" ng-click="$ctrl.showPickupOrder()"
vn-acl="salesPerson"
vn-acl-action="remove"
translate> translate>
Show Pickup order Show Pickup order
</vn-item> </vn-item>

View File

@ -3,6 +3,7 @@ const {Email} = require('vn-print');
module.exports = Self => { module.exports = Self => {
Self.remoteMethodCtx('campaignMetricsEmail', { Self.remoteMethodCtx('campaignMetricsEmail', {
description: 'Sends the campaign metrics email with an attached PDF', description: 'Sends the campaign metrics email with an attached PDF',
accessType: 'WRITE',
accepts: [ accepts: [
{ {
arg: 'id', arg: 'id',

View File

@ -3,6 +3,7 @@ const {Report} = require('vn-print');
module.exports = Self => { module.exports = Self => {
Self.remoteMethodCtx('campaignMetricsPdf', { Self.remoteMethodCtx('campaignMetricsPdf', {
description: 'Returns the campaign metrics pdf', description: 'Returns the campaign metrics pdf',
accessType: 'READ',
accepts: [ accepts: [
{ {
arg: 'id', arg: 'id',

View File

@ -3,6 +3,7 @@ const {Email} = require('vn-print');
module.exports = Self => { module.exports = Self => {
Self.remoteMethodCtx('clientDebtStatementEmail', { Self.remoteMethodCtx('clientDebtStatementEmail', {
description: 'Sends the client debt statement email with an attached PDF', description: 'Sends the client debt statement email with an attached PDF',
accessType: 'WRITE',
accepts: [ accepts: [
{ {
arg: 'id', arg: 'id',

View File

@ -3,6 +3,7 @@ const {Email} = require('vn-print');
module.exports = Self => { module.exports = Self => {
Self.remoteMethodCtx('clientDebtStatementHtml', { Self.remoteMethodCtx('clientDebtStatementHtml', {
description: 'Returns the client debt statement email preview', description: 'Returns the client debt statement email preview',
accessType: 'READ',
accepts: [ accepts: [
{ {
arg: 'id', arg: 'id',

View File

@ -3,6 +3,7 @@ const {Email} = require('vn-print');
module.exports = Self => { module.exports = Self => {
Self.remoteMethodCtx('clientWelcomeEmail', { Self.remoteMethodCtx('clientWelcomeEmail', {
description: 'Sends the client welcome email with an attached PDF', description: 'Sends the client welcome email with an attached PDF',
accessType: 'WRITE',
accepts: [ accepts: [
{ {
arg: 'id', arg: 'id',

View File

@ -3,6 +3,7 @@ const {Email} = require('vn-print');
module.exports = Self => { module.exports = Self => {
Self.remoteMethodCtx('clientWelcomeHtml', { Self.remoteMethodCtx('clientWelcomeHtml', {
description: 'Returns the client welcome email preview', description: 'Returns the client welcome email preview',
accessType: 'READ',
accepts: [ accepts: [
{ {
arg: 'id', arg: 'id',

View File

@ -3,6 +3,7 @@ const {Email} = require('vn-print');
module.exports = Self => { module.exports = Self => {
Self.remoteMethodCtx('clientCreditEmail', { Self.remoteMethodCtx('clientCreditEmail', {
description: 'Sends the credit request email with an attached PDF', description: 'Sends the credit request email with an attached PDF',
accessType: 'WRITE',
accepts: [ accepts: [
{ {
arg: 'id', arg: 'id',

View File

@ -3,6 +3,7 @@ const {Email} = require('vn-print');
module.exports = Self => { module.exports = Self => {
Self.remoteMethodCtx('creditRequestHtml', { Self.remoteMethodCtx('creditRequestHtml', {
description: 'Returns the credit request email preview', description: 'Returns the credit request email preview',
accessType: 'READ',
accepts: [ accepts: [
{ {
arg: 'id', arg: 'id',

View File

@ -3,6 +3,7 @@ const {Email} = require('vn-print');
module.exports = Self => { module.exports = Self => {
Self.remoteMethodCtx('letterDebtorNdEmail', { Self.remoteMethodCtx('letterDebtorNdEmail', {
description: 'Sends the second debtor letter email with an attached PDF', description: 'Sends the second debtor letter email with an attached PDF',
accessType: 'WRITE',
accepts: [ accepts: [
{ {
arg: 'id', arg: 'id',

View File

@ -3,6 +3,7 @@ const {Email} = require('vn-print');
module.exports = Self => { module.exports = Self => {
Self.remoteMethodCtx('letterDebtorNdHtml', { Self.remoteMethodCtx('letterDebtorNdHtml', {
description: 'Returns the second letter debtor email preview', description: 'Returns the second letter debtor email preview',
accessType: 'READ',
accepts: [ accepts: [
{ {
arg: 'id', arg: 'id',

View File

@ -3,6 +3,7 @@ const {Email} = require('vn-print');
module.exports = Self => { module.exports = Self => {
Self.remoteMethodCtx('letterDebtorStEmail', { Self.remoteMethodCtx('letterDebtorStEmail', {
description: 'Sends the printer setup email with an attached PDF', description: 'Sends the printer setup email with an attached PDF',
accessType: 'WRITE',
accepts: [ accepts: [
{ {
arg: 'id', arg: 'id',

View File

@ -3,6 +3,7 @@ const {Email} = require('vn-print');
module.exports = Self => { module.exports = Self => {
Self.remoteMethodCtx('letterDebtorStHtml', { Self.remoteMethodCtx('letterDebtorStHtml', {
description: 'Returns the letter debtor email preview', description: 'Returns the letter debtor email preview',
accessType: 'READ',
accepts: [ accepts: [
{ {
arg: 'id', arg: 'id',

View File

@ -3,6 +3,7 @@ const {Email} = require('vn-print');
module.exports = Self => { module.exports = Self => {
Self.remoteMethodCtx('printerSetupEmail', { Self.remoteMethodCtx('printerSetupEmail', {
description: 'Sends the printer setup email with an attached PDF', description: 'Sends the printer setup email with an attached PDF',
accessType: 'WRITE',
accepts: [ accepts: [
{ {
arg: 'id', arg: 'id',

View File

@ -3,6 +3,7 @@ const {Email} = require('vn-print');
module.exports = Self => { module.exports = Self => {
Self.remoteMethodCtx('printerSetupHtml', { Self.remoteMethodCtx('printerSetupHtml', {
description: 'Returns the printer setup email preview', description: 'Returns the printer setup email preview',
accessType: 'READ',
accepts: [ accepts: [
{ {
arg: 'id', arg: 'id',

View File

@ -3,6 +3,7 @@ const {Email} = require('vn-print');
module.exports = Self => { module.exports = Self => {
Self.remoteMethodCtx('sepaCoreEmail', { Self.remoteMethodCtx('sepaCoreEmail', {
description: 'Sends the campaign metrics email with an attached PDF', description: 'Sends the campaign metrics email with an attached PDF',
accessType: 'WRITE',
accepts: [ accepts: [
{ {
arg: 'id', arg: 'id',

View File

@ -1,4 +1,3 @@
const got = require('got');
const UserError = require('vn-loopback/util/user-error'); const UserError = require('vn-loopback/util/user-error');
const getFinalState = require('vn-loopback/util/hook').getFinalState; const getFinalState = require('vn-loopback/util/hook').getFinalState;
const isMultiple = require('vn-loopback/util/hook').isMultiple; const isMultiple = require('vn-loopback/util/hook').isMultiple;
@ -292,23 +291,22 @@ module.exports = Self => {
const $t = httpRequest.__; const $t = httpRequest.__;
const headers = httpRequest.headers; const headers = httpRequest.headers;
const origin = headers.origin; const origin = headers.origin;
const authorization = headers.authorization;
const salesPersonId = instance.salesPersonFk; const salesPersonId = instance.salesPersonFk;
if (salesPersonId) { if (salesPersonId) {
// Send email to client // Send email to client
if (instance.email) { if (instance.email) {
const {Email} = require('vn-print');
const worker = await models.EmailUser.findById(salesPersonId); const worker = await models.EmailUser.findById(salesPersonId);
const params = { const params = {
authorization: authorization, id: instance.id,
recipientId: instance.id, recipientId: instance.id,
recipient: instance.email, recipient: instance.email,
replyTo: worker.email replyTo: worker.email
}; };
await got.get(`${origin}/api/email/payment-update`, { const email = new Email('payment-update', params);
searchParams: params await email.send();
});
} }
const fullUrl = `${origin}/#!/client/${instance.id}/billing-data`; const fullUrl = `${origin}/#!/client/${instance.id}/billing-data`;

View File

@ -3,6 +3,7 @@ const {Email} = require('vn-print');
module.exports = Self => { module.exports = Self => {
Self.remoteMethodCtx('deliveryNoteEmail', { Self.remoteMethodCtx('deliveryNoteEmail', {
description: 'Sends the delivery note email with an attached PDF', description: 'Sends the delivery note email with an attached PDF',
accessType: 'WRITE',
accepts: [ accepts: [
{ {
arg: 'id', arg: 'id',

View File

@ -3,6 +3,7 @@ const {Report} = require('vn-print');
module.exports = Self => { module.exports = Self => {
Self.remoteMethodCtx('deliveryNotePdf', { Self.remoteMethodCtx('deliveryNotePdf', {
description: 'Returns the delivery note pdf', description: 'Returns the delivery note pdf',
accessType: 'READ',
accepts: [ accepts: [
{ {
arg: 'id', arg: 'id',

View File

@ -29,7 +29,7 @@ module.exports = {
for (let attachment of options.attachments) { for (let attachment of options.attachments) {
const fileName = attachment.filename; const fileName = attachment.filename;
const filePath = attachment.path; const filePath = attachment.path;
if (fileName.includes('.png')) return; if (fileName.includes('.png')) continue;
if (fileName || filePath) if (fileName || filePath)
attachments.push(filePath ? filePath : fileName); attachments.push(filePath ? filePath : fileName);

View File

@ -1,8 +1,12 @@
const Stylesheet = require(`${appPath}/core/stylesheet`); const Stylesheet = require(`vn-print/core/stylesheet`);
const path = require('path');
const vnPrintPath = path.resolve('print');
module.exports = new Stylesheet([ module.exports = new Stylesheet([
`${appPath}/common/css/spacing.css`, `${vnPrintPath}/common/css/spacing.css`,
`${appPath}/common/css/misc.css`, `${vnPrintPath}/common/css/misc.css`,
`${appPath}/common/css/layout.css`, `${vnPrintPath}/common/css/layout.css`,
`${appPath}/common/css/email.css`]) `${vnPrintPath}/common/css/email.css`])
.mergeStyles(); .mergeStyles();

View File

@ -1,11 +1,11 @@
const Component = require(`${appPath}/core/component`); const Component = require(`vn-print/core/component`);
const emailHeader = new Component('email-header'); const emailHeader = new Component('email-header');
const emailFooter = new Component('email-footer'); const emailFooter = new Component('email-footer');
module.exports = { module.exports = {
name: 'payment-update', name: 'payment-update',
async serverPrefetch() { async serverPrefetch() {
this.payMethod = await this.fetchPayMethod(this.recipientId); this.payMethod = await this.fetchPayMethod(this.id);
if (!this.payMethod) if (!this.payMethod)
throw new Error('Something went wrong'); throw new Error('Something went wrong');
@ -16,8 +16,8 @@ module.exports = {
}, },
}, },
methods: { methods: {
fetchPayMethod(clientId) { fetchPayMethod(id) {
return this.findOneFromDef('payMethod', [clientId]); return this.findOneFromDef('payMethod', [id]);
} }
}, },
components: { components: {
@ -25,9 +25,10 @@ module.exports = {
'email-footer': emailFooter.build() 'email-footer': emailFooter.build()
}, },
props: { props: {
recipientId: { id: {
type: [Number, String], type: [Number, String],
required: true required: true,
description: 'The client id'
} }
} }
}; };

View File

@ -17,7 +17,7 @@
<tbody> <tbody>
<tr> <tr>
<td class="font gray uppercase">{{$t('claimId')}}</td> <td class="font gray uppercase">{{$t('claimId')}}</td>
<th>{{claimId}}</th> <th>{{id}}</th>
</tr> </tr>
<tr> <tr>
<td class="font gray uppercase">{{$t('clientId')}}</td> <td class="font gray uppercase">{{$t('clientId')}}</td>
@ -85,7 +85,7 @@
</div> </div>
<!-- Footer block --> <!-- Footer block -->
<report-footer id="pageFooter" <report-footer id="pageFooter"
v-bind:left-text="$t('claim', [claimId])" v-bind:left-text="$t('claim', [id])"
v-bind:center-text="client.name" v-bind:center-text="client.name"
v-bind="$props"> v-bind="$props">
</report-footer> </report-footer>