diff --git a/src/controllers/DonorController.ts b/src/controllers/DonorController.ts
index 54a5ba4..078d37a 100644
--- a/src/controllers/DonorController.ts
+++ b/src/controllers/DonorController.ts
@@ -3,7 +3,7 @@ import { OpenAPI, ResponseSchema } from 'routing-controllers-openapi';
import { getConnectionManager, Repository } from 'typeorm';
import { DonorIdsNotMatchingError, DonorNotFoundError } from '../errors/DonorErrors';
import { CreateDonor } from '../models/actions/CreateDonor';
-import { UpdateDonor } from '../models/actions/UpdateDonor';
+import { UpdateDonor } from '../models/actions/update/UpdateDonor';
import { Donor } from '../models/entities/Donor';
import { ResponseDonor } from '../models/responses/ResponseDonor';
import { ResponseEmpty } from '../models/responses/ResponseEmpty';
diff --git a/src/models/actions/CreateAddress.ts b/src/models/actions/create/CreateAddress.ts
similarity index 94%
rename from src/models/actions/CreateAddress.ts
rename to src/models/actions/create/CreateAddress.ts
index 66ee9bd..365035e 100644
--- a/src/models/actions/CreateAddress.ts
+++ b/src/models/actions/create/CreateAddress.ts
@@ -1,6 +1,6 @@
import { IsNotEmpty, IsOptional, IsPostalCode, IsString } from 'class-validator';
-import { config } from '../../config';
-import { Address } from '../entities/Address';
+import { config } from '../../../config';
+import { Address } from '../../entities/Address';
/**
* This classed is used to create a new Address entity from a json body (post request).
diff --git a/src/models/actions/CreateAuth.ts b/src/models/actions/create/CreateAuth.ts
similarity index 100%
rename from src/models/actions/CreateAuth.ts
rename to src/models/actions/create/CreateAuth.ts
diff --git a/src/models/actions/CreateDonor.ts b/src/models/actions/create/CreateDonor.ts
similarity index 100%
rename from src/models/actions/CreateDonor.ts
rename to src/models/actions/create/CreateDonor.ts
diff --git a/src/models/actions/CreateGroupContact.ts b/src/models/actions/create/CreateGroupContact.ts
similarity index 96%
rename from src/models/actions/CreateGroupContact.ts
rename to src/models/actions/create/CreateGroupContact.ts
index 915f897..711d14a 100644
--- a/src/models/actions/CreateGroupContact.ts
+++ b/src/models/actions/create/CreateGroupContact.ts
@@ -1,85 +1,85 @@
-import { IsEmail, IsInt, IsNotEmpty, IsOptional, IsPhoneNumber, IsString } from 'class-validator';
-import { getConnectionManager } from 'typeorm';
-import { config } from '../../config';
-import { AddressNotFoundError, AddressWrongTypeError } from '../../errors/AddressErrors';
-import { Address } from '../entities/Address';
-import { GroupContact } from '../entities/GroupContact';
-
-/**
- * This classed is used to create a new Group entity from a json body (post request).
- */
-export class CreateGroupContact {
- /**
- * The new contact's first name.
- */
- @IsNotEmpty()
- @IsString()
- firstname: string;
-
- /**
- * The new contact's middle name.
- */
- @IsOptional()
- @IsString()
- middlename?: string;
-
- /**
- * The new contact's last name.
- */
- @IsNotEmpty()
- @IsString()
- lastname: string;
-
- /**
- * The new contact's address.
- * Must be the address's id.
- */
- @IsInt()
- @IsOptional()
- address?: number;
-
- /**
- * The contact's phone number.
- * This will be validated against the configured country phone numer syntax (default: international).
- */
- @IsOptional()
- @IsPhoneNumber(config.phone_validation_countrycode)
- phone?: string;
-
- /**
- * The contact's email address.
- */
- @IsOptional()
- @IsEmail()
- email?: string;
-
- /**
- * Gets the new contact's address by it's id.
- */
- public async getAddress(): Promise
{
- if (this.address === undefined || this.address === null) {
- return null;
- }
- if (!isNaN(this.address)) {
- let address = await getConnectionManager().get().getRepository(Address).findOne({ id: this.address });
- if (!address) { throw new AddressNotFoundError; }
- return address;
- }
-
- throw new AddressWrongTypeError;
- }
-
- /**
- * Creates a new Address entity from this.
- */
- public async toGroupContact(): Promise {
- let contact: GroupContact = new GroupContact();
- contact.firstname = this.firstname;
- contact.middlename = this.middlename;
- contact.lastname = this.lastname;
- contact.email = this.email;
- contact.phone = this.phone;
- contact.address = await this.getAddress();
- return null;
- }
+import { IsEmail, IsInt, IsNotEmpty, IsOptional, IsPhoneNumber, IsString } from 'class-validator';
+import { getConnectionManager } from 'typeorm';
+import { config } from '../../config';
+import { AddressNotFoundError, AddressWrongTypeError } from '../../errors/AddressErrors';
+import { Address } from '../entities/Address';
+import { GroupContact } from '../entities/GroupContact';
+
+/**
+ * This classed is used to create a new Group entity from a json body (post request).
+ */
+export class CreateGroupContact {
+ /**
+ * The new contact's first name.
+ */
+ @IsNotEmpty()
+ @IsString()
+ firstname: string;
+
+ /**
+ * The new contact's middle name.
+ */
+ @IsOptional()
+ @IsString()
+ middlename?: string;
+
+ /**
+ * The new contact's last name.
+ */
+ @IsNotEmpty()
+ @IsString()
+ lastname: string;
+
+ /**
+ * The new contact's address.
+ * Must be the address's id.
+ */
+ @IsInt()
+ @IsOptional()
+ address?: number;
+
+ /**
+ * The contact's phone number.
+ * This will be validated against the configured country phone numer syntax (default: international).
+ */
+ @IsOptional()
+ @IsPhoneNumber(config.phone_validation_countrycode)
+ phone?: string;
+
+ /**
+ * The contact's email address.
+ */
+ @IsOptional()
+ @IsEmail()
+ email?: string;
+
+ /**
+ * Gets the new contact's address by it's id.
+ */
+ public async getAddress(): Promise {
+ if (this.address === undefined || this.address === null) {
+ return null;
+ }
+ if (!isNaN(this.address)) {
+ let address = await getConnectionManager().get().getRepository(Address).findOne({ id: this.address });
+ if (!address) { throw new AddressNotFoundError; }
+ return address;
+ }
+
+ throw new AddressWrongTypeError;
+ }
+
+ /**
+ * Creates a new Address entity from this.
+ */
+ public async toGroupContact(): Promise {
+ let contact: GroupContact = new GroupContact();
+ contact.firstname = this.firstname;
+ contact.middlename = this.middlename;
+ contact.lastname = this.lastname;
+ contact.email = this.email;
+ contact.phone = this.phone;
+ contact.address = await this.getAddress();
+ return null;
+ }
}
\ No newline at end of file
diff --git a/src/models/actions/CreateParticipant.ts b/src/models/actions/create/CreateParticipant.ts
similarity index 96%
rename from src/models/actions/CreateParticipant.ts
rename to src/models/actions/create/CreateParticipant.ts
index 165bddb..cba347a 100644
--- a/src/models/actions/CreateParticipant.ts
+++ b/src/models/actions/create/CreateParticipant.ts
@@ -1,72 +1,72 @@
-import { IsEmail, IsInt, IsNotEmpty, IsOptional, IsPhoneNumber, IsString } from 'class-validator';
-import { getConnectionManager } from 'typeorm';
-import { config } from '../../config';
-import { AddressNotFoundError, AddressWrongTypeError } from '../../errors/AddressErrors';
-import { Address } from '../entities/Address';
-
-/**
- * This classed is used to create a new Participant entity from a json body (post request).
- */
-export abstract class CreateParticipant {
- /**
- * The new participant's first name.
- */
- @IsString()
- @IsNotEmpty()
- firstname: string;
-
- /**
- * The new participant's middle name.
- */
- @IsString()
- @IsOptional()
- middlename?: string;
-
- /**
- * The new participant's last name.
- */
- @IsString()
- @IsNotEmpty()
- lastname: string;
-
- /**
- * The new participant's phone number.
- * This will be validated against the configured country phone numer syntax (default: international).
- */
- @IsString()
- @IsOptional()
- @IsPhoneNumber(config.phone_validation_countrycode)
- phone?: string;
-
- /**
- * The new participant's e-mail address.
- */
- @IsString()
- @IsOptional()
- @IsEmail()
- email?: string;
-
- /**
- * The new participant's address.
- * Must be of type number (address id).
- */
- @IsInt()
- @IsOptional()
- address?: number;
-
- /**
- * Gets the new participant's address by it's address.
- */
- public async getAddress(): Promise {
- if (this.address === undefined || this.address === null) {
- return null;
- }
- if (!isNaN(this.address)) {
- let address = await getConnectionManager().get().getRepository(Address).findOne({ id: this.address });
- if (!address) { throw new AddressNotFoundError; }
- return address;
- }
-
- throw new AddressWrongTypeError;
- }
+import { IsEmail, IsInt, IsNotEmpty, IsOptional, IsPhoneNumber, IsString } from 'class-validator';
+import { getConnectionManager } from 'typeorm';
+import { config } from '../../config';
+import { AddressNotFoundError, AddressWrongTypeError } from '../../errors/AddressErrors';
+import { Address } from '../entities/Address';
+
+/**
+ * This classed is used to create a new Participant entity from a json body (post request).
+ */
+export abstract class CreateParticipant {
+ /**
+ * The new participant's first name.
+ */
+ @IsString()
+ @IsNotEmpty()
+ firstname: string;
+
+ /**
+ * The new participant's middle name.
+ */
+ @IsString()
+ @IsOptional()
+ middlename?: string;
+
+ /**
+ * The new participant's last name.
+ */
+ @IsString()
+ @IsNotEmpty()
+ lastname: string;
+
+ /**
+ * The new participant's phone number.
+ * This will be validated against the configured country phone numer syntax (default: international).
+ */
+ @IsString()
+ @IsOptional()
+ @IsPhoneNumber(config.phone_validation_countrycode)
+ phone?: string;
+
+ /**
+ * The new participant's e-mail address.
+ */
+ @IsString()
+ @IsOptional()
+ @IsEmail()
+ email?: string;
+
+ /**
+ * The new participant's address.
+ * Must be of type number (address id).
+ */
+ @IsInt()
+ @IsOptional()
+ address?: number;
+
+ /**
+ * Gets the new participant's address by it's address.
+ */
+ public async getAddress(): Promise {
+ if (this.address === undefined || this.address === null) {
+ return null;
+ }
+ if (!isNaN(this.address)) {
+ let address = await getConnectionManager().get().getRepository(Address).findOne({ id: this.address });
+ if (!address) { throw new AddressNotFoundError; }
+ return address;
+ }
+
+ throw new AddressWrongTypeError;
+ }
}
\ No newline at end of file
diff --git a/src/models/actions/CreatePermission.ts b/src/models/actions/create/CreatePermission.ts
similarity index 100%
rename from src/models/actions/CreatePermission.ts
rename to src/models/actions/create/CreatePermission.ts
diff --git a/src/models/actions/CreateResetToken.ts b/src/models/actions/create/CreateResetToken.ts
similarity index 100%
rename from src/models/actions/CreateResetToken.ts
rename to src/models/actions/create/CreateResetToken.ts
diff --git a/src/models/actions/CreateRunner.ts b/src/models/actions/create/CreateRunner.ts
similarity index 100%
rename from src/models/actions/CreateRunner.ts
rename to src/models/actions/create/CreateRunner.ts
diff --git a/src/models/actions/CreateRunnerCard.ts b/src/models/actions/create/CreateRunnerCard.ts
similarity index 100%
rename from src/models/actions/CreateRunnerCard.ts
rename to src/models/actions/create/CreateRunnerCard.ts
diff --git a/src/models/actions/CreateRunnerGroup.ts b/src/models/actions/create/CreateRunnerGroup.ts
similarity index 100%
rename from src/models/actions/CreateRunnerGroup.ts
rename to src/models/actions/create/CreateRunnerGroup.ts
diff --git a/src/models/actions/CreateRunnerOrganisation.ts b/src/models/actions/create/CreateRunnerOrganisation.ts
similarity index 100%
rename from src/models/actions/CreateRunnerOrganisation.ts
rename to src/models/actions/create/CreateRunnerOrganisation.ts
diff --git a/src/models/actions/CreateRunnerTeam.ts b/src/models/actions/create/CreateRunnerTeam.ts
similarity index 100%
rename from src/models/actions/CreateRunnerTeam.ts
rename to src/models/actions/create/CreateRunnerTeam.ts
diff --git a/src/models/actions/CreateScan.ts b/src/models/actions/create/CreateScan.ts
similarity index 100%
rename from src/models/actions/CreateScan.ts
rename to src/models/actions/create/CreateScan.ts
diff --git a/src/models/actions/CreateScanStation.ts b/src/models/actions/create/CreateScanStation.ts
similarity index 100%
rename from src/models/actions/CreateScanStation.ts
rename to src/models/actions/create/CreateScanStation.ts
diff --git a/src/models/actions/CreateStatsClient.ts b/src/models/actions/create/CreateStatsClient.ts
similarity index 100%
rename from src/models/actions/CreateStatsClient.ts
rename to src/models/actions/create/CreateStatsClient.ts
diff --git a/src/models/actions/CreateTrack.ts b/src/models/actions/create/CreateTrack.ts
similarity index 100%
rename from src/models/actions/CreateTrack.ts
rename to src/models/actions/create/CreateTrack.ts
diff --git a/src/models/actions/CreateTrackScan.ts b/src/models/actions/create/CreateTrackScan.ts
similarity index 100%
rename from src/models/actions/CreateTrackScan.ts
rename to src/models/actions/create/CreateTrackScan.ts
diff --git a/src/models/actions/CreateUser.ts b/src/models/actions/create/CreateUser.ts
similarity index 96%
rename from src/models/actions/CreateUser.ts
rename to src/models/actions/create/CreateUser.ts
index ad0f905..838d1e0 100644
--- a/src/models/actions/CreateUser.ts
+++ b/src/models/actions/create/CreateUser.ts
@@ -1,132 +1,132 @@
-import * as argon2 from "argon2";
-import { IsBoolean, IsEmail, IsOptional, IsPhoneNumber, IsString, IsUrl } from 'class-validator';
-import { getConnectionManager } from 'typeorm';
-import * as uuid from 'uuid';
-import { config } from '../../config';
-import { UsernameOrEmailNeededError } from '../../errors/UserErrors';
-import { UserGroupNotFoundError } from '../../errors/UserGroupErrors';
-import { User } from '../entities/User';
-import { UserGroup } from '../entities/UserGroup';
-
-/**
- * This classed is used to create a new User entity from a json body (post request).
- */
-export class CreateUser {
- /**
- * The new user's first name.
- */
- @IsString()
- firstname: string;
-
- /**
- * The new user's middle name.
- */
- @IsString()
- @IsOptional()
- middlename?: string;
-
- /**
- * The new user's last name.
- */
- @IsString()
- lastname: string;
-
- /**
- * The new user's username.
- * You have to provide at least one of: {email, username}.
- */
- @IsOptional()
- @IsString()
- username?: string;
-
- /**
- * The new user's email address.
- * You have to provide at least one of: {email, username}.
- */
- @IsEmail()
- @IsString()
- @IsOptional()
- email?: string;
-
- /**
- * The new user's phone number.
- * This will be validated against the configured country phone numer syntax (default: international).
- */
- @IsPhoneNumber(config.phone_validation_countrycode)
- @IsOptional()
- phone?: string;
-
- /**
- * The new user's password.
- * This will of course not be saved in plaintext :)
- */
- @IsString()
- password: string;
-
- /**
- * Will the new user be enabled from the start?
- * Default: true
- */
- @IsBoolean()
- @IsOptional()
- enabled?: boolean = true;
-
- /**
- * The new user's groups' id(s).
- * You can provide either one groupId or an array of groupIDs.
- */
- @IsOptional()
- groups?: number[] | number
-
- /**
- * The user's profile pic (or rather a url pointing to it).
- */
- @IsString()
- @IsUrl()
- @IsOptional()
- profilePic?: string;
-
- /**
- * Converts this to a User entity.
- */
- public async toUser(): Promise {
- let newUser: User = new User();
-
- if (this.email === undefined && this.username === undefined) {
- throw new UsernameOrEmailNeededError();
- }
-
- newUser.email = this.email
- newUser.username = this.username
- newUser.firstname = this.firstname
- newUser.middlename = this.middlename
- newUser.lastname = this.lastname
- newUser.uuid = uuid.v4()
- newUser.phone = this.phone
- newUser.password = await argon2.hash(this.password + newUser.uuid);
- newUser.groups = await this.getGroups();
- newUser.enabled = this.enabled;
-
- if (!this.profilePic) { newUser.profilePic = `https://dev.lauf-fuer-kaya.de/lfk-logo.png`; }
- else { newUser.profilePic = this.profilePic; }
-
- return newUser;
- }
-
- /**
- * Get's all groups for this user by their id's;
- */
- public async getGroups() {
- if (!this.groups) { return null; }
- let groups = new Array();
- if (!Array.isArray(this.groups)) {
- this.groups = [this.groups]
- }
- for (let group of this.groups) {
- let found = await getConnectionManager().get().getRepository(UserGroup).findOne({ id: group });
- if (!found) { throw new UserGroupNotFoundError(); }
- groups.push(found);
- }
- return groups;
- }
+import * as argon2 from "argon2";
+import { IsBoolean, IsEmail, IsOptional, IsPhoneNumber, IsString, IsUrl } from 'class-validator';
+import { getConnectionManager } from 'typeorm';
+import * as uuid from 'uuid';
+import { config } from '../../config';
+import { UsernameOrEmailNeededError } from '../../errors/UserErrors';
+import { UserGroupNotFoundError } from '../../errors/UserGroupErrors';
+import { User } from '../entities/User';
+import { UserGroup } from '../entities/UserGroup';
+
+/**
+ * This classed is used to create a new User entity from a json body (post request).
+ */
+export class CreateUser {
+ /**
+ * The new user's first name.
+ */
+ @IsString()
+ firstname: string;
+
+ /**
+ * The new user's middle name.
+ */
+ @IsString()
+ @IsOptional()
+ middlename?: string;
+
+ /**
+ * The new user's last name.
+ */
+ @IsString()
+ lastname: string;
+
+ /**
+ * The new user's username.
+ * You have to provide at least one of: {email, username}.
+ */
+ @IsOptional()
+ @IsString()
+ username?: string;
+
+ /**
+ * The new user's email address.
+ * You have to provide at least one of: {email, username}.
+ */
+ @IsEmail()
+ @IsString()
+ @IsOptional()
+ email?: string;
+
+ /**
+ * The new user's phone number.
+ * This will be validated against the configured country phone numer syntax (default: international).
+ */
+ @IsPhoneNumber(config.phone_validation_countrycode)
+ @IsOptional()
+ phone?: string;
+
+ /**
+ * The new user's password.
+ * This will of course not be saved in plaintext :)
+ */
+ @IsString()
+ password: string;
+
+ /**
+ * Will the new user be enabled from the start?
+ * Default: true
+ */
+ @IsBoolean()
+ @IsOptional()
+ enabled?: boolean = true;
+
+ /**
+ * The new user's groups' id(s).
+ * You can provide either one groupId or an array of groupIDs.
+ */
+ @IsOptional()
+ groups?: number[] | number
+
+ /**
+ * The user's profile pic (or rather a url pointing to it).
+ */
+ @IsString()
+ @IsUrl()
+ @IsOptional()
+ profilePic?: string;
+
+ /**
+ * Converts this to a User entity.
+ */
+ public async toUser(): Promise {
+ let newUser: User = new User();
+
+ if (this.email === undefined && this.username === undefined) {
+ throw new UsernameOrEmailNeededError();
+ }
+
+ newUser.email = this.email
+ newUser.username = this.username
+ newUser.firstname = this.firstname
+ newUser.middlename = this.middlename
+ newUser.lastname = this.lastname
+ newUser.uuid = uuid.v4()
+ newUser.phone = this.phone
+ newUser.password = await argon2.hash(this.password + newUser.uuid);
+ newUser.groups = await this.getGroups();
+ newUser.enabled = this.enabled;
+
+ if (!this.profilePic) { newUser.profilePic = `https://dev.lauf-fuer-kaya.de/lfk-logo.png`; }
+ else { newUser.profilePic = this.profilePic; }
+
+ return newUser;
+ }
+
+ /**
+ * Get's all groups for this user by their id's;
+ */
+ public async getGroups() {
+ if (!this.groups) { return null; }
+ let groups = new Array();
+ if (!Array.isArray(this.groups)) {
+ this.groups = [this.groups]
+ }
+ for (let group of this.groups) {
+ let found = await getConnectionManager().get().getRepository(UserGroup).findOne({ id: group });
+ if (!found) { throw new UserGroupNotFoundError(); }
+ groups.push(found);
+ }
+ return groups;
+ }
}
\ No newline at end of file
diff --git a/src/models/actions/CreateUserGroup.ts b/src/models/actions/create/CreateUserGroup.ts
similarity index 100%
rename from src/models/actions/CreateUserGroup.ts
rename to src/models/actions/create/CreateUserGroup.ts
diff --git a/src/models/actions/UpdateDonor.ts b/src/models/actions/update/UpdateDonor.ts
similarity index 90%
rename from src/models/actions/UpdateDonor.ts
rename to src/models/actions/update/UpdateDonor.ts
index b7139c8..21b2eb1 100644
--- a/src/models/actions/UpdateDonor.ts
+++ b/src/models/actions/update/UpdateDonor.ts
@@ -1,6 +1,6 @@
import { IsBoolean, IsInt, IsOptional } from 'class-validator';
-import { DonorReceiptAddressNeededError } from '../../errors/DonorErrors';
-import { Donor } from '../entities/Donor';
+import { DonorReceiptAddressNeededError } from '../../../errors/DonorErrors';
+import { Donor } from '../../entities/Donor';
import { CreateParticipant } from './CreateParticipant';
/**
diff --git a/src/models/actions/UpdatePermission.ts b/src/models/actions/update/UpdatePermission.ts
similarity index 100%
rename from src/models/actions/UpdatePermission.ts
rename to src/models/actions/update/UpdatePermission.ts
diff --git a/src/models/actions/UpdateRunner.ts b/src/models/actions/update/UpdateRunner.ts
similarity index 100%
rename from src/models/actions/UpdateRunner.ts
rename to src/models/actions/update/UpdateRunner.ts
diff --git a/src/models/actions/UpdateRunnerCard.ts b/src/models/actions/update/UpdateRunnerCard.ts
similarity index 100%
rename from src/models/actions/UpdateRunnerCard.ts
rename to src/models/actions/update/UpdateRunnerCard.ts
diff --git a/src/models/actions/UpdateRunnerOrganisation.ts b/src/models/actions/update/UpdateRunnerOrganisation.ts
similarity index 100%
rename from src/models/actions/UpdateRunnerOrganisation.ts
rename to src/models/actions/update/UpdateRunnerOrganisation.ts
diff --git a/src/models/actions/UpdateRunnerTeam.ts b/src/models/actions/update/UpdateRunnerTeam.ts
similarity index 100%
rename from src/models/actions/UpdateRunnerTeam.ts
rename to src/models/actions/update/UpdateRunnerTeam.ts
diff --git a/src/models/actions/UpdateScan.ts b/src/models/actions/update/UpdateScan.ts
similarity index 100%
rename from src/models/actions/UpdateScan.ts
rename to src/models/actions/update/UpdateScan.ts
diff --git a/src/models/actions/UpdateScanStation.ts b/src/models/actions/update/UpdateScanStation.ts
similarity index 100%
rename from src/models/actions/UpdateScanStation.ts
rename to src/models/actions/update/UpdateScanStation.ts
diff --git a/src/models/actions/UpdateTrack.ts b/src/models/actions/update/UpdateTrack.ts
similarity index 100%
rename from src/models/actions/UpdateTrack.ts
rename to src/models/actions/update/UpdateTrack.ts
diff --git a/src/models/actions/UpdateTrackScan.ts b/src/models/actions/update/UpdateTrackScan.ts
similarity index 100%
rename from src/models/actions/UpdateTrackScan.ts
rename to src/models/actions/update/UpdateTrackScan.ts
diff --git a/src/models/actions/UpdateUser.ts b/src/models/actions/update/UpdateUser.ts
similarity index 100%
rename from src/models/actions/UpdateUser.ts
rename to src/models/actions/update/UpdateUser.ts