remove unnecessary isEditable
gitea/salix/pipeline/head There was a failure building this commit
Details
gitea/salix/pipeline/head There was a failure building this commit
Details
This commit is contained in:
parent
376d46b67e
commit
99271f275f
|
@ -42,7 +42,10 @@ module.exports = Self => {
|
|||
|
||||
try {
|
||||
const saleIds = sales.map(sale => sale.id);
|
||||
|
||||
const canEditSales = await models.Sale.canEdit(ctx, saleIds, myOptions);
|
||||
if (!canEditSales)
|
||||
throw new UserError(`Sale(s) blocked, please contact production`);
|
||||
|
||||
const ticket = await models.Ticket.findById(ticketId, {
|
||||
include: {
|
||||
|
@ -58,13 +61,6 @@ module.exports = Self => {
|
|||
}
|
||||
}, myOptions);
|
||||
|
||||
const isTicketEditable = await models.Ticket.isEditable(ctx, ticketId, myOptions);
|
||||
if (!isTicketEditable)
|
||||
throw new UserError(`The sales of this ticket can't be modified`);
|
||||
|
||||
if (!canEditSales)
|
||||
throw new UserError(`Sale(s) blocked, please contact production`);
|
||||
|
||||
const promises = [];
|
||||
let deletions = '';
|
||||
for (let sale of sales) {
|
||||
|
|
|
@ -37,10 +37,6 @@ module.exports = Self => {
|
|||
try {
|
||||
const salesIds = sales.map(sale => sale.id);
|
||||
|
||||
const isEditable = await models.Ticket.isEditable(ctx, sales[0].ticketFk, myOptions);
|
||||
if (!isEditable)
|
||||
throw new UserError(`The sales of this ticket can't be modified`);
|
||||
|
||||
const canEditSale = await models.Sale.canEdit(ctx, salesIds, myOptions);
|
||||
if (!canEditSale)
|
||||
throw new UserError(`Sale(s) blocked, please contact production`);
|
||||
|
|
|
@ -49,13 +49,9 @@ module.exports = Self => {
|
|||
}
|
||||
|
||||
try {
|
||||
const isTicketEditable = await models.Ticket.isEditable(ctx, ticketId, myOptions);
|
||||
if (!isTicketEditable)
|
||||
throw new UserError(`The sales of this ticket can't be modified`);
|
||||
|
||||
const salesIds = sales.map(sale => sale.id);
|
||||
const canEditSale = await models.Sale.canEdit(ctx, salesIds, myOptions);
|
||||
|
||||
const canEditSale = await models.Sale.canEdit(ctx, salesIds, myOptions);
|
||||
if (!canEditSale)
|
||||
throw new UserError(`Sale(s) blocked, please contact production`);
|
||||
|
||||
|
|
|
@ -66,12 +66,7 @@ module.exports = Self => {
|
|||
|
||||
const sale = await models.Sale.findById(id, filter, myOptions);
|
||||
|
||||
const isEditable = await models.Ticket.isEditable(ctx, sale.ticketFk, myOptions);
|
||||
if (!isEditable)
|
||||
throw new UserError(`The sales of this ticket can't be modified`);
|
||||
|
||||
const canEditSale = await models.Sale.canEdit(ctx, [id], myOptions);
|
||||
|
||||
if (!canEditSale)
|
||||
throw new UserError(`Sale(s) blocked, please contact production`);
|
||||
|
||||
|
|
Loading…
Reference in New Issue