#136 added personal project creation in user creation process in the fixtures

parent 0d57310f
......@@ -6,6 +6,7 @@ import { priorityType, Task, taskFinishType } from "./models/Task";
import { Project } from "./models/Project";
import { Member, MemberRole } from "./models/Member";
import { DateTimeTask } from "./models/DateTimeTask";
import { PasswordRecovery } from "./models/PasswordRecovery";
function randomIntFromInterval(min:number, max:number) {
min = Math.ceil(min);
......@@ -50,6 +51,8 @@ const loadFixtures = async () => {
await repositoryProject.delete({})
const repositoryUser = myDataSource.getRepository(User);
await repositoryUser.delete({});
const repositoryPasswordRecovery = myDataSource.getRepository(PasswordRecovery);
await repositoryPasswordRecovery.delete({});
console.log('========================== ' + '\n' + 'Data Source has been cleared!' +'\n' + '==========================')
const userRoles = [{role: UserRole.SUPERUSER}, {role: UserRole.USER}, {role: UserRole.USER},{role: UserRole.USER},];
......@@ -68,6 +71,24 @@ const loadFixtures = async () => {
user.role = userRoles[i].role;
user.generateToken()
await user.save();
const newProject = new Project();
newProject.title = 'Личные дела';
newProject.color= '#f595ee';
await newProject.save()
const newMember = new Member();
newMember.user = user;
newMember.project = newProject;
newMember.roleProject = MemberRole.ADMIN;
await newMember.save();
const notDefinedTaskProject = new Project();
notDefinedTaskProject.title = 'Не определено';
notDefinedTaskProject.color= '#03fcfc';
await notDefinedTaskProject.save()
const notDefinedTaskProjectMember = new Member();
notDefinedTaskProjectMember.user = user;
notDefinedTaskProjectMember.project = notDefinedTaskProject;
notDefinedTaskProjectMember.roleProject = MemberRole.ADMIN;
await notDefinedTaskProjectMember.save();
users.push(user)
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment