6745-2404_testToMaster #1950

Merged
alexm merged 191 commits from 6745-2404_testToMaster into master 2024-01-25 07:39:13 +00:00
2 changed files with 10 additions and 11 deletions
Showing only changes of commit ccf5387e04 - Show all commits

View File

@ -49,7 +49,7 @@ module.exports = Self => {
for (const id of ticketIds) {
const promise = await models.Ticket.state(ctx, {
stateFk: state.id,
workerFk: worker.id,
userFk: worker.id,
ticketFk: id
}, myOptions);
promises.push(promise);

View File

@ -7,7 +7,6 @@ module.exports = Self => {
accepts: [
{
arg: 'data',
description: 'Model instance data',
type: 'Object',
required: true,
http: {source: 'body'}
@ -37,21 +36,21 @@ module.exports = Self => {
}
try {
const {userId} = ctx.req.accessToken;
if (!params.stateFk && !params.code)
throw new UserError('State cannot be blank');
if (params.stateFk) {
const {code} = await models.State.findById(params.stateFk, {fields: ['code']}, myOptions);
params.code = code;
} else {
const {id} = await models.State.findOne({where: {code: params.code}}, myOptions);
params.stateFk = id;
}
if (!params.userFk) {
const worker = await models.Worker.findOne({
where: {id: userId}
where: {id: ctx.req.accessToken.userId}
}, myOptions);
params.userFk = worker.id;
}
@ -59,9 +58,10 @@ module.exports = Self => {
fields: ['stateFk']
}, myOptions);
let oldStateAllowed;
if (ticketState)
oldStateAllowed = await models.State.isEditable(ctx, ticketState.stateFk, myOptions);
const oldStateAllowed = ticketState ?
await models.State.isEditable(ctx, ticketState.stateFk, myOptions) :
false;
const newStateAllowed = await models.State.isEditable(ctx, params.stateFk, myOptions);
if (!((!ticketState || oldStateAllowed == true) && newStateAllowed == true))
@ -75,8 +75,7 @@ module.exports = Self => {
limit: 1
}, myOptions);
if (params.workerFk)
await ticketTracking.updateAttribute('workerFk', params.workerFk, myOptions);
await ticketTracking.updateAttribute('userFk', params.userFk, myOptions);
if (tx) await tx.commit();