Cleaned up realations regarding response classes
	
		
			
	
		
	
	
		
	
		
			All checks were successful
		
		
	
	
		
			
				
	
				continuous-integration/drone/pr Build is passing
				
			
		
		
	
	
				
					
				
			
		
			All checks were successful
		
		
	
	continuous-integration/drone/pr Build is passing
				
			ref #132
This commit is contained in:
		@@ -78,7 +78,7 @@ export class DonationController {
 | 
				
			|||||||
	async postDistance(@Body({ validate: true }) createDonation: CreateDistanceDonation) {
 | 
						async postDistance(@Body({ validate: true }) createDonation: CreateDistanceDonation) {
 | 
				
			||||||
		let donation = await createDonation.toEntity();
 | 
							let donation = await createDonation.toEntity();
 | 
				
			||||||
		donation = await this.distanceDonationRepository.save(donation);
 | 
							donation = await this.distanceDonationRepository.save(donation);
 | 
				
			||||||
		return (await this.donationRepository.findOne({ id: donation.id }, { relations: ['runner', 'donor', 'runner.scans', 'runner.scans.track'] })).toResponse();
 | 
							return (await this.distanceDonationRepository.findOne({ id: donation.id }, { relations: ['runner', 'donor', 'runner.scans', 'runner.scans.track'] })).toResponse();
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	@Put('/fixed/:id')
 | 
						@Put('/fixed/:id')
 | 
				
			||||||
@@ -124,7 +124,7 @@ export class DonationController {
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		await this.distanceDonationRepository.save(await donation.update(oldDonation));
 | 
							await this.distanceDonationRepository.save(await donation.update(oldDonation));
 | 
				
			||||||
		return (await this.donationRepository.findOne({ id: donation.id }, { relations: ['runner', 'donor', 'runner.scans', 'runner.scans.track'] })).toResponse();
 | 
							return (await this.distanceDonationRepository.findOne({ id: donation.id }, { relations: ['runner', 'donor', 'runner.scans', 'runner.scans.track'] })).toResponse();
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	@Delete('/:id')
 | 
						@Delete('/:id')
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -36,7 +36,7 @@ export class ScanController {
 | 
				
			|||||||
	@OpenAPI({ description: 'Lists all scans (normal or track) from all runners. <br> This includes the scan\'s runner\'s distance ran.' })
 | 
						@OpenAPI({ description: 'Lists all scans (normal or track) from all runners. <br> This includes the scan\'s runner\'s distance ran.' })
 | 
				
			||||||
	async getAll() {
 | 
						async getAll() {
 | 
				
			||||||
		let responseScans: ResponseScan[] = new Array<ResponseScan>();
 | 
							let responseScans: ResponseScan[] = new Array<ResponseScan>();
 | 
				
			||||||
		const scans = await this.scanRepository.find({ relations: ['runner', 'track', 'runner.scans', 'runner.scans.track', 'card', 'station'] });
 | 
							const scans = await this.scanRepository.find({ relations: ['runner', 'track', 'runner.scans', 'runner.group', 'runner.scans.track', 'card', 'station'] });
 | 
				
			||||||
		scans.forEach(scan => {
 | 
							scans.forEach(scan => {
 | 
				
			||||||
			responseScans.push(scan.toResponse());
 | 
								responseScans.push(scan.toResponse());
 | 
				
			||||||
		});
 | 
							});
 | 
				
			||||||
@@ -51,7 +51,7 @@ export class ScanController {
 | 
				
			|||||||
	@OnUndefined(ScanNotFoundError)
 | 
						@OnUndefined(ScanNotFoundError)
 | 
				
			||||||
	@OpenAPI({ description: 'Lists all information about the scan whose id got provided. This includes the scan\'s runner\'s distance ran.' })
 | 
						@OpenAPI({ description: 'Lists all information about the scan whose id got provided. This includes the scan\'s runner\'s distance ran.' })
 | 
				
			||||||
	async getOne(@Param('id') id: number) {
 | 
						async getOne(@Param('id') id: number) {
 | 
				
			||||||
		let scan = await this.scanRepository.findOne({ id: id }, { relations: ['runner', 'track', 'runner.scans', 'runner.scans.track', 'card', 'station'] })
 | 
							let scan = await this.scanRepository.findOne({ id: id }, { relations: ['runner', 'track', 'runner.scans', 'runner.group', 'runner.scans.track', 'card', 'station'] })
 | 
				
			||||||
		if (!scan) { throw new ScanNotFoundError(); }
 | 
							if (!scan) { throw new ScanNotFoundError(); }
 | 
				
			||||||
		return scan.toResponse();
 | 
							return scan.toResponse();
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
@@ -64,7 +64,7 @@ export class ScanController {
 | 
				
			|||||||
	async post(@Body({ validate: true }) createScan: CreateScan) {
 | 
						async post(@Body({ validate: true }) createScan: CreateScan) {
 | 
				
			||||||
		let scan = await createScan.toEntity();
 | 
							let scan = await createScan.toEntity();
 | 
				
			||||||
		scan = await this.scanRepository.save(scan);
 | 
							scan = await this.scanRepository.save(scan);
 | 
				
			||||||
		return (await this.scanRepository.findOne({ id: scan.id }, { relations: ['runner', 'track', 'runner.scans', 'runner.scans.track', 'card', 'station'] })).toResponse();
 | 
							return (await this.scanRepository.findOne({ id: scan.id }, { relations: ['runner', 'track', 'runner.scans', 'runner.group', 'runner.scans.track', 'card', 'station'] })).toResponse();
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	@Post("/trackscans")
 | 
						@Post("/trackscans")
 | 
				
			||||||
@@ -75,7 +75,7 @@ export class ScanController {
 | 
				
			|||||||
	async postTrackScans(@Body({ validate: true }) createScan: CreateTrackScan) {
 | 
						async postTrackScans(@Body({ validate: true }) createScan: CreateTrackScan) {
 | 
				
			||||||
		let scan = await createScan.toEntity();
 | 
							let scan = await createScan.toEntity();
 | 
				
			||||||
		scan = await this.trackScanRepository.save(scan);
 | 
							scan = await this.trackScanRepository.save(scan);
 | 
				
			||||||
		return (await this.scanRepository.findOne({ id: scan.id }, { relations: ['runner', 'track', 'runner.scans', 'runner.scans.track', 'card', 'station'] })).toResponse();
 | 
							return (await this.scanRepository.findOne({ id: scan.id }, { relations: ['runner', 'track', 'runner.scans', 'runner.group', 'runner.scans.track', 'card', 'station'] })).toResponse();
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	@Put('/:id')
 | 
						@Put('/:id')
 | 
				
			||||||
@@ -97,7 +97,7 @@ export class ScanController {
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		await this.scanRepository.save(await scan.update(oldScan));
 | 
							await this.scanRepository.save(await scan.update(oldScan));
 | 
				
			||||||
		return (await this.scanRepository.findOne({ id: id }, { relations: ['runner', 'track', 'runner.scans', 'runner.scans.track', 'card', 'station'] })).toResponse();
 | 
							return (await this.scanRepository.findOne({ id: id }, { relations: ['runner', 'track', 'runner.scans', 'runner.group', 'runner.scans.track', 'card', 'station'] })).toResponse();
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	@Put('/trackscans/:id')
 | 
						@Put('/trackscans/:id')
 | 
				
			||||||
@@ -120,7 +120,7 @@ export class ScanController {
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		await this.trackScanRepository.save(await scan.update(oldScan));
 | 
							await this.trackScanRepository.save(await scan.update(oldScan));
 | 
				
			||||||
		return (await this.scanRepository.findOne({ id: id }, { relations: ['runner', 'track', 'runner.scans', 'runner.scans.track', 'card', 'station'] })).toResponse();
 | 
							return (await this.scanRepository.findOne({ id: id }, { relations: ['runner', 'track', 'runner.scans', 'runner.group', 'runner.scans.track', 'card', 'station'] })).toResponse();
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	@Delete('/:id')
 | 
						@Delete('/:id')
 | 
				
			||||||
@@ -132,7 +132,7 @@ export class ScanController {
 | 
				
			|||||||
	async remove(@Param("id") id: number, @QueryParam("force") force: boolean) {
 | 
						async remove(@Param("id") id: number, @QueryParam("force") force: boolean) {
 | 
				
			||||||
		let scan = await this.scanRepository.findOne({ id: id });
 | 
							let scan = await this.scanRepository.findOne({ id: id });
 | 
				
			||||||
		if (!scan) { return null; }
 | 
							if (!scan) { return null; }
 | 
				
			||||||
		const responseScan = await this.scanRepository.findOne({ id: scan.id }, { relations: ['runner', 'track', 'runner.scans', 'runner.scans.track', 'card', 'station'] });
 | 
							const responseScan = await this.scanRepository.findOne({ id: scan.id }, { relations: ['runner', 'track', 'runner.scans', 'runner.group', 'runner.scans.track', 'card', 'station'] });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		await this.scanRepository.delete(scan);
 | 
							await this.scanRepository.delete(scan);
 | 
				
			||||||
		return responseScan.toResponse();
 | 
							return responseScan.toResponse();
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -4,7 +4,6 @@ import {
 | 
				
			|||||||
  IsString
 | 
					  IsString
 | 
				
			||||||
} from "class-validator";
 | 
					} from "class-validator";
 | 
				
			||||||
import { ChildEntity, Column } from "typeorm";
 | 
					import { ChildEntity, Column } from "typeorm";
 | 
				
			||||||
import { ResponsePrincipal } from '../responses/ResponsePrincipal';
 | 
					 | 
				
			||||||
import { ResponseUserGroup } from '../responses/ResponseUserGroup';
 | 
					import { ResponseUserGroup } from '../responses/ResponseUserGroup';
 | 
				
			||||||
import { Principal } from './Principal';
 | 
					import { Principal } from './Principal';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -34,7 +33,7 @@ export class UserGroup extends Principal {
 | 
				
			|||||||
  /**
 | 
					  /**
 | 
				
			||||||
   * Turns this entity into it's response class.
 | 
					   * Turns this entity into it's response class.
 | 
				
			||||||
   */
 | 
					   */
 | 
				
			||||||
  public toResponse(): ResponsePrincipal {
 | 
					  public toResponse(): ResponseUserGroup {
 | 
				
			||||||
    return new ResponseUserGroup(this);
 | 
					    return new ResponseUserGroup(this);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -36,7 +36,7 @@ export class ResponseDistanceDonation extends ResponseDonation implements IRespo
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    public constructor(donation: DistanceDonation) {
 | 
					    public constructor(donation: DistanceDonation) {
 | 
				
			||||||
        super(donation);
 | 
					        super(donation);
 | 
				
			||||||
        this.runner = donation.runner.toResponse();
 | 
					        if (donation.runner) { this.runner = donation.runner.toResponse(); }
 | 
				
			||||||
        this.amountPerDistance = donation.amountPerDistance;
 | 
					        this.amountPerDistance = donation.amountPerDistance;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -77,8 +77,10 @@ export class ResponseGroupContact implements IResponse {
 | 
				
			|||||||
        this.email = contact.email;
 | 
					        this.email = contact.email;
 | 
				
			||||||
        this.address = contact.address;
 | 
					        this.address = contact.address;
 | 
				
			||||||
        this.groups = new Array<ResponseRunnerGroup>();
 | 
					        this.groups = new Array<ResponseRunnerGroup>();
 | 
				
			||||||
 | 
					        if (contact.groups) {
 | 
				
			||||||
            for (let group of contact.groups) {
 | 
					            for (let group of contact.groups) {
 | 
				
			||||||
                this.groups.push(group.toResponse());
 | 
					                this.groups.push(group.toResponse());
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -3,10 +3,10 @@ import {
 | 
				
			|||||||
    IsObject
 | 
					    IsObject
 | 
				
			||||||
} from "class-validator";
 | 
					} from "class-validator";
 | 
				
			||||||
import { Runner } from '../entities/Runner';
 | 
					import { Runner } from '../entities/Runner';
 | 
				
			||||||
import { RunnerGroup } from '../entities/RunnerGroup';
 | 
					 | 
				
			||||||
import { ResponseObjectType } from '../enums/ResponseObjectType';
 | 
					import { ResponseObjectType } from '../enums/ResponseObjectType';
 | 
				
			||||||
import { IResponse } from './IResponse';
 | 
					import { IResponse } from './IResponse';
 | 
				
			||||||
import { ResponseParticipant } from './ResponseParticipant';
 | 
					import { ResponseParticipant } from './ResponseParticipant';
 | 
				
			||||||
 | 
					import { ResponseRunnerGroup } from './ResponseRunnerGroup';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * Defines the runner response.
 | 
					 * Defines the runner response.
 | 
				
			||||||
@@ -28,7 +28,7 @@ export class ResponseRunner extends ResponseParticipant implements IResponse {
 | 
				
			|||||||
     * The runner's group.
 | 
					     * The runner's group.
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    @IsObject()
 | 
					    @IsObject()
 | 
				
			||||||
    group: RunnerGroup;
 | 
					    group: ResponseRunnerGroup;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Creates a ResponseRunner object from a runner.
 | 
					     * Creates a ResponseRunner object from a runner.
 | 
				
			||||||
@@ -38,6 +38,6 @@ export class ResponseRunner extends ResponseParticipant implements IResponse {
 | 
				
			|||||||
        super(runner);
 | 
					        super(runner);
 | 
				
			||||||
        if (!runner.scans) { this.distance = 0 }
 | 
					        if (!runner.scans) { this.distance = 0 }
 | 
				
			||||||
        else { this.distance = runner.validScans.reduce((sum, current) => sum + current.distance, 0); }
 | 
					        else { this.distance = runner.validScans.reduce((sum, current) => sum + current.distance, 0); }
 | 
				
			||||||
        this.group = runner.group;
 | 
					        if (runner.group) { this.group = runner.group.toResponse(); }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,8 +1,8 @@
 | 
				
			|||||||
import { IsInt, IsNotEmpty, IsObject, IsOptional, IsString } from "class-validator";
 | 
					import { IsInt, IsNotEmpty, IsObject, IsOptional, IsString } from "class-validator";
 | 
				
			||||||
import { GroupContact } from '../entities/GroupContact';
 | 
					 | 
				
			||||||
import { RunnerGroup } from '../entities/RunnerGroup';
 | 
					import { RunnerGroup } from '../entities/RunnerGroup';
 | 
				
			||||||
import { ResponseObjectType } from '../enums/ResponseObjectType';
 | 
					import { ResponseObjectType } from '../enums/ResponseObjectType';
 | 
				
			||||||
import { IResponse } from './IResponse';
 | 
					import { IResponse } from './IResponse';
 | 
				
			||||||
 | 
					import { ResponseGroupContact } from './ResponseGroupContact';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * Defines the runnerGroup response.
 | 
					 * Defines the runnerGroup response.
 | 
				
			||||||
@@ -34,7 +34,7 @@ export abstract class ResponseRunnerGroup implements IResponse {
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    @IsObject()
 | 
					    @IsObject()
 | 
				
			||||||
    @IsOptional()
 | 
					    @IsOptional()
 | 
				
			||||||
    contact?: GroupContact;
 | 
					    contact?: ResponseGroupContact;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Creates a ResponseRunnerGroup object from a runnerGroup.
 | 
					     * Creates a ResponseRunnerGroup object from a runnerGroup.
 | 
				
			||||||
@@ -43,6 +43,6 @@ export abstract class ResponseRunnerGroup implements IResponse {
 | 
				
			|||||||
    public constructor(group: RunnerGroup) {
 | 
					    public constructor(group: RunnerGroup) {
 | 
				
			||||||
        this.id = group.id;
 | 
					        this.id = group.id;
 | 
				
			||||||
        this.name = group.name;
 | 
					        this.name = group.name;
 | 
				
			||||||
        this.contact = group.contact;
 | 
					        if (group.contact) { this.contact = group.contact.toResponse(); };
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -11,10 +11,10 @@ import {
 | 
				
			|||||||
} from "class-validator";
 | 
					} from "class-validator";
 | 
				
			||||||
import { Address } from '../entities/Address';
 | 
					import { Address } from '../entities/Address';
 | 
				
			||||||
import { RunnerOrganization } from '../entities/RunnerOrganization';
 | 
					import { RunnerOrganization } from '../entities/RunnerOrganization';
 | 
				
			||||||
import { RunnerTeam } from '../entities/RunnerTeam';
 | 
					 | 
				
			||||||
import { ResponseObjectType } from '../enums/ResponseObjectType';
 | 
					import { ResponseObjectType } from '../enums/ResponseObjectType';
 | 
				
			||||||
import { IResponse } from './IResponse';
 | 
					import { IResponse } from './IResponse';
 | 
				
			||||||
import { ResponseRunnerGroup } from './ResponseRunnerGroup';
 | 
					import { ResponseRunnerGroup } from './ResponseRunnerGroup';
 | 
				
			||||||
 | 
					import { ResponseRunnerTeam } from './ResponseRunnerTeam';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * Defines the runnerOrganization response.
 | 
					 * Defines the runnerOrganization response.
 | 
				
			||||||
@@ -37,7 +37,7 @@ export class ResponseRunnerOrganization extends ResponseRunnerGroup implements I
 | 
				
			|||||||
     * The runnerOrganization associated teams.
 | 
					     * The runnerOrganization associated teams.
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    @IsArray()
 | 
					    @IsArray()
 | 
				
			||||||
    teams: RunnerTeam[];
 | 
					    teams: ResponseRunnerTeam[];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * The organization's registration key.
 | 
					     * The organization's registration key.
 | 
				
			||||||
@@ -62,7 +62,13 @@ export class ResponseRunnerOrganization extends ResponseRunnerGroup implements I
 | 
				
			|||||||
    public constructor(org: RunnerOrganization) {
 | 
					    public constructor(org: RunnerOrganization) {
 | 
				
			||||||
        super(org);
 | 
					        super(org);
 | 
				
			||||||
        this.address = org.address;
 | 
					        this.address = org.address;
 | 
				
			||||||
        this.teams = org.teams;
 | 
					        this.teams = new Array<ResponseRunnerTeam>();
 | 
				
			||||||
 | 
					        if (org.teams) {
 | 
				
			||||||
 | 
					            for (let team of org.teams) {
 | 
				
			||||||
 | 
					                this.teams.push(team.toResponse());
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (!org.key) { this.registrationEnabled = false; }
 | 
					        if (!org.key) { this.registrationEnabled = false; }
 | 
				
			||||||
        else { this.registrationKey = Buffer.from(org.key).toString('base64'); }
 | 
					        else { this.registrationKey = Buffer.from(org.key).toString('base64'); }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -28,6 +28,6 @@ export class ResponseRunnerTeam extends ResponseRunnerGroup implements IResponse
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    public constructor(team: RunnerTeam) {
 | 
					    public constructor(team: RunnerTeam) {
 | 
				
			||||||
        super(team);
 | 
					        super(team);
 | 
				
			||||||
        this.parentGroup = team.parentGroup.toResponse();
 | 
					        if (team.parentGroup) { this.parentGroup = team.parentGroup.toResponse(); }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -47,7 +47,7 @@ export class ResponseScan implements IResponse {
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    public constructor(scan: Scan) {
 | 
					    public constructor(scan: Scan) {
 | 
				
			||||||
        this.id = scan.id;
 | 
					        this.id = scan.id;
 | 
				
			||||||
        this.runner = scan.runner.toResponse();
 | 
					        if (scan.runner) { this.runner = scan.runner.toResponse(); }
 | 
				
			||||||
        this.distance = scan.distance;
 | 
					        this.distance = scan.distance;
 | 
				
			||||||
        this.valid = scan.valid;
 | 
					        this.valid = scan.valid;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -72,7 +72,7 @@ export class ResponseScanStation implements IResponse {
 | 
				
			|||||||
        this.description = station.description;
 | 
					        this.description = station.description;
 | 
				
			||||||
        this.prefix = station.prefix;
 | 
					        this.prefix = station.prefix;
 | 
				
			||||||
        this.key = "Only visible on creation.";
 | 
					        this.key = "Only visible on creation.";
 | 
				
			||||||
        this.track = station.track.toResponse();
 | 
					        if (station.track) { this.track = station.track.toResponse(); }
 | 
				
			||||||
        this.enabled = station.enabled;
 | 
					        this.enabled = station.enabled;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -4,9 +4,9 @@ import {
 | 
				
			|||||||
    IsString
 | 
					    IsString
 | 
				
			||||||
} from "class-validator";
 | 
					} from "class-validator";
 | 
				
			||||||
import { Runner } from '../entities/Runner';
 | 
					import { Runner } from '../entities/Runner';
 | 
				
			||||||
import { RunnerGroup } from '../entities/RunnerGroup';
 | 
					 | 
				
			||||||
import { ResponseObjectType } from '../enums/ResponseObjectType';
 | 
					import { ResponseObjectType } from '../enums/ResponseObjectType';
 | 
				
			||||||
import { IResponse } from './IResponse';
 | 
					import { IResponse } from './IResponse';
 | 
				
			||||||
 | 
					import { ResponseRunnerGroup } from './ResponseRunnerGroup';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * Defines the runner stats response.
 | 
					 * Defines the runner stats response.
 | 
				
			||||||
@@ -59,7 +59,7 @@ export class ResponseStatsRunner implements IResponse {
 | 
				
			|||||||
     * The runner's group.
 | 
					     * The runner's group.
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    @IsObject()
 | 
					    @IsObject()
 | 
				
			||||||
    group: RunnerGroup;
 | 
					    group: ResponseRunnerGroup;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Creates a new runner stats response from a runner
 | 
					     * Creates a new runner stats response from a runner
 | 
				
			||||||
@@ -72,6 +72,6 @@ export class ResponseStatsRunner implements IResponse {
 | 
				
			|||||||
        this.lastname = runner.lastname;
 | 
					        this.lastname = runner.lastname;
 | 
				
			||||||
        this.distance = runner.distance;
 | 
					        this.distance = runner.distance;
 | 
				
			||||||
        this.donationAmount = runner.distanceDonationAmount;
 | 
					        this.donationAmount = runner.distanceDonationAmount;
 | 
				
			||||||
        this.group = runner.group;
 | 
					        this.group = runner.group.toResponse();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -3,10 +3,10 @@ import {
 | 
				
			|||||||
    IsObject,
 | 
					    IsObject,
 | 
				
			||||||
    IsString
 | 
					    IsString
 | 
				
			||||||
} from "class-validator";
 | 
					} from "class-validator";
 | 
				
			||||||
import { RunnerGroup } from '../entities/RunnerGroup';
 | 
					 | 
				
			||||||
import { RunnerTeam } from '../entities/RunnerTeam';
 | 
					import { RunnerTeam } from '../entities/RunnerTeam';
 | 
				
			||||||
import { ResponseObjectType } from '../enums/ResponseObjectType';
 | 
					import { ResponseObjectType } from '../enums/ResponseObjectType';
 | 
				
			||||||
import { IResponse } from './IResponse';
 | 
					import { IResponse } from './IResponse';
 | 
				
			||||||
 | 
					import { ResponseRunnerGroup } from './ResponseRunnerGroup';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * Defines the team stats response.
 | 
					 * Defines the team stats response.
 | 
				
			||||||
@@ -47,7 +47,7 @@ export class ResponseStatsTeam implements IResponse {
 | 
				
			|||||||
     * The teams's parent group.
 | 
					     * The teams's parent group.
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    @IsObject()
 | 
					    @IsObject()
 | 
				
			||||||
    parent: RunnerGroup;
 | 
					    parent: ResponseRunnerGroup;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Creates a new team stats response from a team
 | 
					     * Creates a new team stats response from a team
 | 
				
			||||||
@@ -56,7 +56,7 @@ export class ResponseStatsTeam implements IResponse {
 | 
				
			|||||||
    public constructor(team: RunnerTeam) {
 | 
					    public constructor(team: RunnerTeam) {
 | 
				
			||||||
        this.name = team.name;
 | 
					        this.name = team.name;
 | 
				
			||||||
        this.id = team.id;
 | 
					        this.id = team.id;
 | 
				
			||||||
        this.parent = team.parentGroup;
 | 
					        this.parent = team.parentGroup.toResponse();
 | 
				
			||||||
        this.distance = team.distance;
 | 
					        this.distance = team.distance;
 | 
				
			||||||
        this.donationAmount = team.distanceDonationAmount;
 | 
					        this.donationAmount = team.distanceDonationAmount;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -49,8 +49,8 @@ export class ResponseTrackScan extends ResponseScan implements IResponse {
 | 
				
			|||||||
    public constructor(scan: TrackScan) {
 | 
					    public constructor(scan: TrackScan) {
 | 
				
			||||||
        super(scan);
 | 
					        super(scan);
 | 
				
			||||||
        this.track = new ResponseTrack(scan.track);
 | 
					        this.track = new ResponseTrack(scan.track);
 | 
				
			||||||
        this.card = scan.card.toResponse();
 | 
					        if (scan.card) { scan.card.toResponse(); }
 | 
				
			||||||
        this.station = scan.station.toResponse();
 | 
					        if (scan.station) { scan.station.toResponse(); }
 | 
				
			||||||
        this.timestamp = scan.timestamp;
 | 
					        this.timestamp = scan.timestamp;
 | 
				
			||||||
        this.distance = scan.distance;
 | 
					        this.distance = scan.distance;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -6,10 +6,10 @@ import {
 | 
				
			|||||||
    IsString
 | 
					    IsString
 | 
				
			||||||
} from "class-validator";
 | 
					} from "class-validator";
 | 
				
			||||||
import { User } from '../entities/User';
 | 
					import { User } from '../entities/User';
 | 
				
			||||||
import { UserGroup } from '../entities/UserGroup';
 | 
					 | 
				
			||||||
import { ResponseObjectType } from '../enums/ResponseObjectType';
 | 
					import { ResponseObjectType } from '../enums/ResponseObjectType';
 | 
				
			||||||
import { IResponse } from './IResponse';
 | 
					import { IResponse } from './IResponse';
 | 
				
			||||||
import { ResponsePrincipal } from './ResponsePrincipal';
 | 
					import { ResponsePrincipal } from './ResponsePrincipal';
 | 
				
			||||||
 | 
					import { ResponseUserGroup } from './ResponseUserGroup';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * Defines the user response.
 | 
					 * Defines the user response.
 | 
				
			||||||
@@ -74,7 +74,7 @@ export class ResponseUser extends ResponsePrincipal implements IResponse {
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    @IsArray()
 | 
					    @IsArray()
 | 
				
			||||||
    @IsOptional()
 | 
					    @IsOptional()
 | 
				
			||||||
    groups: UserGroup[];
 | 
					    groups: ResponseUserGroup[];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * The user's permissions.
 | 
					     * The user's permissions.
 | 
				
			||||||
@@ -98,10 +98,13 @@ export class ResponseUser extends ResponsePrincipal implements IResponse {
 | 
				
			|||||||
        this.username = user.username;
 | 
					        this.username = user.username;
 | 
				
			||||||
        this.enabled = user.enabled;
 | 
					        this.enabled = user.enabled;
 | 
				
			||||||
        this.profilePic = user.profilePic;
 | 
					        this.profilePic = user.profilePic;
 | 
				
			||||||
        this.groups = user.groups;
 | 
					        this.groups = new Array<ResponseUserGroup>();
 | 
				
			||||||
        this.permissions = user.allPermissions;
 | 
					        this.permissions = user.allPermissions;
 | 
				
			||||||
        if (this.groups) {
 | 
					        if (user.groups) {
 | 
				
			||||||
            this.groups.forEach(function (g) { delete g.permissions });
 | 
					            for (let group of user.groups) {
 | 
				
			||||||
 | 
					                delete group.permissions;
 | 
				
			||||||
 | 
					                this.groups.push(group.toResponse());
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,8 +1,8 @@
 | 
				
			|||||||
import { IsArray, IsNotEmpty, IsOptional, IsString } from "class-validator";
 | 
					import { IsArray, IsNotEmpty, IsOptional, IsString } from "class-validator";
 | 
				
			||||||
import { Permission } from '../entities/Permission';
 | 
					 | 
				
			||||||
import { UserGroup } from '../entities/UserGroup';
 | 
					import { UserGroup } from '../entities/UserGroup';
 | 
				
			||||||
import { ResponseObjectType } from '../enums/ResponseObjectType';
 | 
					import { ResponseObjectType } from '../enums/ResponseObjectType';
 | 
				
			||||||
import { IResponse } from './IResponse';
 | 
					import { IResponse } from './IResponse';
 | 
				
			||||||
 | 
					import { ResponsePermission } from './ResponsePermission';
 | 
				
			||||||
import { ResponsePrincipal } from './ResponsePrincipal';
 | 
					import { ResponsePrincipal } from './ResponsePrincipal';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
@@ -34,7 +34,7 @@ export class ResponseUserGroup extends ResponsePrincipal implements IResponse {
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    @IsArray()
 | 
					    @IsArray()
 | 
				
			||||||
    @IsOptional()
 | 
					    @IsOptional()
 | 
				
			||||||
    permissions: Permission[];
 | 
					    permissions: ResponsePermission[];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Creates a ResponseUserGroup object from a userGroup.
 | 
					     * Creates a ResponseUserGroup object from a userGroup.
 | 
				
			||||||
@@ -44,6 +44,10 @@ export class ResponseUserGroup extends ResponsePrincipal implements IResponse {
 | 
				
			|||||||
        super(group);
 | 
					        super(group);
 | 
				
			||||||
        this.name = group.name;
 | 
					        this.name = group.name;
 | 
				
			||||||
        this.description = group.description;
 | 
					        this.description = group.description;
 | 
				
			||||||
        this.permissions = group.permissions;
 | 
					        if (group.permissions) {
 | 
				
			||||||
 | 
					            for (let permission of group.permissions) {
 | 
				
			||||||
 | 
					                this.permissions.push(permission.toResponse());
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user