This commit is contained in:
parent
0b6fb70f28
commit
a0fee6ad50
|
@ -46,7 +46,7 @@ module.exports = Self => {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const isEditable = await models.Ticket.isEditableOrThrow(ctx, id, myOptions);
|
await models.Ticket.isEditableOrThrow(ctx, id, myOptions);
|
||||||
|
|
||||||
const item = await models.Item.findById(itemId, null, myOptions);
|
const item = await models.Item.findById(itemId, null, myOptions);
|
||||||
const ticket = await models.Ticket.findById(id, {
|
const ticket = await models.Ticket.findById(id, {
|
||||||
|
|
|
@ -115,7 +115,7 @@ module.exports = Self => {
|
||||||
const userId = ctx.req.accessToken.userId;
|
const userId = ctx.req.accessToken.userId;
|
||||||
const models = Self.app.models;
|
const models = Self.app.models;
|
||||||
const $t = ctx.req.__; // $translate
|
const $t = ctx.req.__; // $translate
|
||||||
const isEditable = await models.Ticket.isEditableOrThrow(ctx, args.id, myOptions);
|
await models.Ticket.isEditableOrThrow(ctx, args.id, myOptions);
|
||||||
|
|
||||||
const editZone = await models.ACL.checkAccessAcl(ctx, 'Ticket', 'editZone', 'WRITE');
|
const editZone = await models.ACL.checkAccessAcl(ctx, 'Ticket', 'editZone', 'WRITE');
|
||||||
if (!editZone) {
|
if (!editZone) {
|
||||||
|
|
|
@ -70,7 +70,7 @@ module.exports = Self => {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const isEditable = await Self.isEditableOrThrow(ctx, args.id, myOptions);
|
await Self.isEditableOrThrow(ctx, args.id, myOptions);
|
||||||
|
|
||||||
const editZone = await models.ACL.checkAccessAcl(ctx, 'Ticket', 'editZone', 'WRITE');
|
const editZone = await models.ACL.checkAccessAcl(ctx, 'Ticket', 'editZone', 'WRITE');
|
||||||
if (!editZone) {
|
if (!editZone) {
|
||||||
|
|
|
@ -32,7 +32,7 @@ module.exports = Self => {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const isEditable = await Self.isEditableOrThrow(ctx, id, myOptions);
|
await Self.isEditableOrThrow(ctx, id, myOptions);
|
||||||
|
|
||||||
const recalculation = await Self.rawSql('CALL vn.ticket_recalcComponents(?, NULL)', [id], myOptions);
|
const recalculation = await Self.rawSql('CALL vn.ticket_recalcComponents(?, NULL)', [id], myOptions);
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,7 @@ module.exports = Self => {
|
||||||
const ticketToDelete = await models.Ticket.findById(id, {fields: ['isDeleted']}, myOptions);
|
const ticketToDelete = await models.Ticket.findById(id, {fields: ['isDeleted']}, myOptions);
|
||||||
if (ticketToDelete.isDeleted) return false;
|
if (ticketToDelete.isDeleted) return false;
|
||||||
|
|
||||||
const isEditable = await Self.isEditableOrThrow(ctx, id, myOptions);
|
await Self.isEditableOrThrow(ctx, id, myOptions);
|
||||||
|
|
||||||
// Check if ticket has refunds
|
// Check if ticket has refunds
|
||||||
const ticketRefunds = await models.TicketRefund.find({
|
const ticketRefunds = await models.TicketRefund.find({
|
||||||
|
|
|
@ -65,13 +65,9 @@ describe('ticket isEditableOrThrow()', () => {
|
||||||
let error;
|
let error;
|
||||||
try {
|
try {
|
||||||
const options = {transaction: tx};
|
const options = {transaction: tx};
|
||||||
|
|
||||||
const ctx = {req: {accessToken: {userId: 1}}};
|
const ctx = {req: {accessToken: {userId: 1}}};
|
||||||
|
|
||||||
const result = await models.Ticket.isEditableOrThrow(ctx, 15, options);
|
await models.Ticket.isEditableOrThrow(ctx, 15, options);
|
||||||
|
|
||||||
expect(result).toEqual(false);
|
|
||||||
|
|
||||||
await tx.rollback();
|
await tx.rollback();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
error = e;
|
error = e;
|
||||||
|
|
|
@ -28,7 +28,7 @@ module.exports = Self => {
|
||||||
if (typeof options == 'object')
|
if (typeof options == 'object')
|
||||||
Object.assign(myOptions, options);
|
Object.assign(myOptions, options);
|
||||||
|
|
||||||
const isEditable = await Self.isEditableOrThrow(ctx, id, myOptions);
|
await Self.isEditableOrThrow(ctx, id, myOptions);
|
||||||
|
|
||||||
const ticket = await models.Ticket.findById(
|
const ticket = await models.Ticket.findById(
|
||||||
id,
|
id,
|
||||||
|
|
|
@ -48,7 +48,7 @@ module.exports = Self => {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const isEditable = await models.Ticket.isEditableOrThrow(ctx, id, myOptions);
|
await models.Ticket.isEditableOrThrow(ctx, id, myOptions);
|
||||||
|
|
||||||
if (ticketId) {
|
if (ticketId) {
|
||||||
const isReceiverEditable = await models.Ticket.isEditable(ctx, ticketId, myOptions);
|
const isReceiverEditable = await models.Ticket.isEditable(ctx, ticketId, myOptions);
|
||||||
|
|
Loading…
Reference in New Issue