feat: add admin panel dto & validation
This commit is contained in:
@@ -72,19 +72,21 @@ export class TestsCommandProvider {
|
||||
}
|
||||
|
||||
const accessType = updateTestDto.accessType ?? test.accessType;
|
||||
const price = updateTestDto.price ?? test.price;
|
||||
const price =
|
||||
updateTestDto.price !== undefined ? updateTestDto.price : test.price;
|
||||
|
||||
if (
|
||||
(accessType === AccessType.PAID && !price) ||
|
||||
(accessType !== AccessType.PAID && price)
|
||||
(accessType === AccessType.PAID && price == null) ||
|
||||
(accessType !== AccessType.PAID && price != null)
|
||||
) {
|
||||
throw new BadRequestException('tests.errors.priceAccessConstraint');
|
||||
}
|
||||
|
||||
Object.assign(test, updateTestDto);
|
||||
|
||||
if (updateTestDto.status === TestStatus.PUBLISHED) {
|
||||
if (test.status === TestStatus.PUBLISHED) {
|
||||
await this.publishTestValidatorProvider.validate(test.id);
|
||||
test.structureLocked = true;
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user