bug in updateWorkshop

pull/35/head
leonnicolas 4 years ago
parent 06e225096b
commit 0d44a98377
No known key found for this signature in database
GPG Key ID: 088D0743E2B65C07

@ -55,6 +55,8 @@ export class WorkshopAPI extends DataSource {
async updateWorkshop (workshop: any, userId: number) {
const keepLock = workshop.keepLock;
delete workshop.keepLock;
const workshopTypeId = workshop.workshopTypeId;
delete workshop.workshopTypeId;
await this.connection.transaction(async (entityManger: EntityManager) => {
if (await LockUtils.isLocked(entityManger, Workshop, 'w', workshop.id, userId)) {
throw new ResourceLockedError('Workshop', 'Attempting to update locked resource');
@ -71,6 +73,11 @@ export class WorkshopAPI extends DataSource {
throw new NotFoundError('Workshop', 'id', workshop.id);
}
});
workshopTypeId && await entityManger.getRepository(Workshop)
.createQueryBuilder('w')
.relation(Workshop, 'workshopTypeId')
.of(workshop.id)
.set(workshopTypeId);
});
!keepLock && await this.unlockWorkshop(workshop.id, userId);
return await this.workshopById(workshop.id);

Loading…
Cancel
Save