Merge branch 'dev' into feature/17-automated_tests
# Conflicts: # src/controllers/RunnerTeamController.ts
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
import { Body, Delete, Get, JsonController, OnUndefined, Param, Post, Put, QueryParam } from 'routing-controllers';
|
||||
import { OpenAPI, ResponseSchema } from 'routing-controllers-openapi';
|
||||
import { getConnectionManager, Repository } from 'typeorm';
|
||||
import { EntityFromBody } from 'typeorm-routing-controllers-extensions';
|
||||
import { RunnerTeamHasRunnersError, RunnerTeamIdsNotMatchingError, RunnerTeamNotFoundError } from '../errors/RunnerTeamErrors';
|
||||
import { CreateRunnerTeam } from '../models/actions/CreateRunnerTeam';
|
||||
import { UpdateRunnerTeam } from '../models/actions/UpdateRunnerTeam';
|
||||
import { RunnerTeam } from '../models/entities/RunnerTeam';
|
||||
import { ResponseEmpty } from '../models/responses/ResponseEmpty';
|
||||
import { ResponseRunnerTeam } from '../models/responses/ResponseRunnerTeam';
|
||||
@@ -67,7 +67,7 @@ export class RunnerTeamController {
|
||||
@ResponseSchema(RunnerTeamNotFoundError, { statusCode: 404 })
|
||||
@ResponseSchema(RunnerTeamIdsNotMatchingError, { statusCode: 406 })
|
||||
@OpenAPI({ description: "Update a runnerTeam object (id can't be changed)." })
|
||||
async put(@Param('id') id: number, @EntityFromBody() runnerTeam: RunnerTeam) {
|
||||
async put(@Param('id') id: number, @Body({ validate: true }) runnerTeam: UpdateRunnerTeam) {
|
||||
let oldRunnerTeam = await this.runnerTeamRepository.findOne({ id: id }, { relations: ['parentGroup', 'contact'] });
|
||||
|
||||
if (!oldRunnerTeam) {
|
||||
@@ -78,10 +78,9 @@ export class RunnerTeamController {
|
||||
throw new RunnerTeamIdsNotMatchingError();
|
||||
}
|
||||
|
||||
await this.runnerTeamRepository.update(oldRunnerTeam, runnerTeam);
|
||||
await this.runnerTeamRepository.update(oldRunnerTeam, await runnerTeam.toRunnerTeam());
|
||||
|
||||
runnerTeam = await this.runnerTeamRepository.findOne(runnerTeam, { relations: ['parentGroup', 'contact'] });
|
||||
return new ResponseRunnerTeam(runnerTeam);
|
||||
return new ResponseRunnerTeam(await this.runnerTeamRepository.findOne({ id: runnerTeam.id }, { relations: ['parentGroup', 'contact'] }));
|
||||
}
|
||||
|
||||
@Delete('/:id')
|
||||
|
||||
Reference in New Issue
Block a user