Skip to content

Commit d431e7b

Browse files
committed
Allow tests to now be updated/edited
1 parent e949ea0 commit d431e7b

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

server/src/generic-controller.ts

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ export class GenericController {
376376
);
377377

378378
// Handle authors, parts, and related tests
379-
await this.handleAuthorsAndParts(paper, data, true);
379+
await this.handleAuthorsAndParts(paper, data, true, true);
380380

381381
console.log("Paper and all related entities processed successfully.");
382382
return await this.getFullPaperById(paper.id);
@@ -402,7 +402,7 @@ export class GenericController {
402402
await paper.update(paperData);
403403

404404
// Handle authors, parts, and related tests
405-
await this.handleAuthorsAndParts(paper, data, append);
405+
await this.handleAuthorsAndParts(paper, data, append, false);
406406

407407
console.log("Paper successfully updated.");
408408
return await this.getFullPaperById(id);
@@ -640,7 +640,12 @@ export class GenericController {
640640
/**
641641
* Helper function to handle Authors and Parts in both Create and Update operations
642642
*/
643-
static async handleAuthorsAndParts(paper: Paper, data: any, append: boolean) {
643+
static async handleAuthorsAndParts(
644+
paper: Paper,
645+
data: any,
646+
append: boolean,
647+
isCreate: boolean,
648+
) {
644649
// Handle authors
645650
if (data.authors) {
646651
const authors = (await this.manageEntities(
@@ -658,7 +663,13 @@ export class GenericController {
658663
append ? await paper.addParts(parts) : await paper.setParts(parts);
659664
console.log("gotty here");
660665
console.log(data.parts);
661-
await this.handleTestsForParts(parts, paper, data.parts, append);
666+
await this.handleTestsForParts(
667+
parts,
668+
paper,
669+
data.parts,
670+
append,
671+
isCreate,
672+
);
662673
}
663674
}
664675

@@ -670,6 +681,7 @@ export class GenericController {
670681
paper: Paper,
671682
partsData: any[],
672683
append: boolean,
684+
isCreate: boolean,
673685
) {
674686
for (const partData of partsData) {
675687
let part;
@@ -689,7 +701,7 @@ export class GenericController {
689701
const tids = (await this.manageEntities(
690702
"Tid",
691703
partData.tids,
692-
true,
704+
isCreate,
693705
)) as Tid[];
694706

695707
if (append) {

0 commit comments

Comments
 (0)