@@ -1,8 +1,10 @@
 | 
				
			|||||||
import { IsObject, IsOptional } from 'class-validator';
 | 
					import { IsBoolean, IsObject, IsOptional } from 'class-validator';
 | 
				
			||||||
 | 
					import * as uuid from 'uuid';
 | 
				
			||||||
import { Address } from '../../entities/Address';
 | 
					import { Address } from '../../entities/Address';
 | 
				
			||||||
import { RunnerOrganisation } from '../../entities/RunnerOrganisation';
 | 
					import { RunnerOrganisation } from '../../entities/RunnerOrganisation';
 | 
				
			||||||
import { CreateRunnerGroup } from './CreateRunnerGroup';
 | 
					import { CreateRunnerGroup } from './CreateRunnerGroup';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * This classed is used to create a new RunnerOrganisation entity from a json body (post request).
 | 
					 * This classed is used to create a new RunnerOrganisation entity from a json body (post request).
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
@@ -14,6 +16,13 @@ export class CreateRunnerOrganisation extends CreateRunnerGroup {
 | 
				
			|||||||
    @IsObject()
 | 
					    @IsObject()
 | 
				
			||||||
    address?: Address;
 | 
					    address?: Address;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Is registration enabled for the new organisation?
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    @IsOptional()
 | 
				
			||||||
 | 
					    @IsBoolean()
 | 
				
			||||||
 | 
					    registrtionEnabled?: boolean = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Creates a new RunnerOrganisation entity from this.
 | 
					     * Creates a new RunnerOrganisation entity from this.
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
@@ -25,6 +34,10 @@ export class CreateRunnerOrganisation extends CreateRunnerGroup {
 | 
				
			|||||||
        newRunnerOrganisation.address = this.address;
 | 
					        newRunnerOrganisation.address = this.address;
 | 
				
			||||||
        Address.validate(newRunnerOrganisation.address);
 | 
					        Address.validate(newRunnerOrganisation.address);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (this.registrtionEnabled) {
 | 
				
			||||||
 | 
					            newRunnerOrganisation.key = uuid.v4().toUpperCase();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return newRunnerOrganisation;
 | 
					        return newRunnerOrganisation;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -1,4 +1,5 @@
 | 
				
			|||||||
import { IsInt, IsObject, IsOptional } from 'class-validator';
 | 
					import { IsBoolean, IsInt, IsNotEmpty, IsObject, IsOptional } from 'class-validator';
 | 
				
			||||||
 | 
					import * as uuid from 'uuid';
 | 
				
			||||||
import { Address } from '../../entities/Address';
 | 
					import { Address } from '../../entities/Address';
 | 
				
			||||||
import { RunnerOrganisation } from '../../entities/RunnerOrganisation';
 | 
					import { RunnerOrganisation } from '../../entities/RunnerOrganisation';
 | 
				
			||||||
import { CreateRunnerGroup } from '../create/CreateRunnerGroup';
 | 
					import { CreateRunnerGroup } from '../create/CreateRunnerGroup';
 | 
				
			||||||
@@ -22,6 +23,13 @@ export class UpdateRunnerOrganisation extends CreateRunnerGroup {
 | 
				
			|||||||
    @IsObject()
 | 
					    @IsObject()
 | 
				
			||||||
    address?: Address;
 | 
					    address?: Address;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Is registration enabled for the updated organisation?
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    @IsNotEmpty()
 | 
				
			||||||
 | 
					    @IsBoolean()
 | 
				
			||||||
 | 
					    registrtionEnabled: boolean;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Updates a provided RunnerOrganisation entity based on this.
 | 
					     * Updates a provided RunnerOrganisation entity based on this.
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
@@ -33,6 +41,13 @@ export class UpdateRunnerOrganisation extends CreateRunnerGroup {
 | 
				
			|||||||
        else { organisation.address = this.address; }
 | 
					        else { organisation.address = this.address; }
 | 
				
			||||||
        Address.validate(organisation.address);
 | 
					        Address.validate(organisation.address);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (this.registrtionEnabled) {
 | 
				
			||||||
 | 
					            organisation.key = uuid.v4().toUpperCase();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        else {
 | 
				
			||||||
 | 
					            organisation.key = null;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return organisation;
 | 
					        return organisation;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -1,8 +1,13 @@
 | 
				
			|||||||
import {
 | 
					import {
 | 
				
			||||||
    IsArray,
 | 
					    IsArray,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    IsBase64,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    IsBoolean,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    IsObject,
 | 
					    IsObject,
 | 
				
			||||||
    IsOptional
 | 
					    IsOptional,
 | 
				
			||||||
 | 
					    IsString
 | 
				
			||||||
} from "class-validator";
 | 
					} from "class-validator";
 | 
				
			||||||
import { Address } from '../entities/Address';
 | 
					import { Address } from '../entities/Address';
 | 
				
			||||||
import { RunnerOrganisation } from '../entities/RunnerOrganisation';
 | 
					import { RunnerOrganisation } from '../entities/RunnerOrganisation';
 | 
				
			||||||
@@ -27,6 +32,22 @@ export class ResponseRunnerOrganisation extends ResponseRunnerGroup {
 | 
				
			|||||||
    @IsArray()
 | 
					    @IsArray()
 | 
				
			||||||
    teams: RunnerTeam[];
 | 
					    teams: RunnerTeam[];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * The organisation's registration key.
 | 
				
			||||||
 | 
					     * If registration is disabled this is null.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    @IsString()
 | 
				
			||||||
 | 
					    @IsOptional()
 | 
				
			||||||
 | 
					    @IsBase64()
 | 
				
			||||||
 | 
					    registrationKey?: string;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Is registration enabled for the organisation?
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    @IsOptional()
 | 
				
			||||||
 | 
					    @IsBoolean()
 | 
				
			||||||
 | 
					    registrtionEnabled?: boolean = true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Creates a ResponseRunnerOrganisation object from a runnerOrganisation.
 | 
					     * Creates a ResponseRunnerOrganisation object from a runnerOrganisation.
 | 
				
			||||||
     * @param org The runnerOrganisation the response shall be build for.
 | 
					     * @param org The runnerOrganisation the response shall be build for.
 | 
				
			||||||
@@ -35,5 +56,7 @@ export class ResponseRunnerOrganisation extends ResponseRunnerGroup {
 | 
				
			|||||||
        super(org);
 | 
					        super(org);
 | 
				
			||||||
        this.address = org.address;
 | 
					        this.address = org.address;
 | 
				
			||||||
        this.teams = org.teams;
 | 
					        this.teams = org.teams;
 | 
				
			||||||
 | 
					        if (!org.key) { this.registrtionEnabled = false; }
 | 
				
			||||||
 | 
					        else { this.registrationKey = Buffer.from(org.key).toString('base64'); }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user