-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathloader.exs
65 lines (52 loc) · 1.64 KB
/
loader.exs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# Code.load_file
# TurnStile.Repo.transaction(fn ->
org1_params = %{
email: "[email protected]",
name: "Org1",
phone: "777777777",
slug: "org1"
}
{:ok, organization1} = TurnStile.Company.insert_and_preload_organization(org1_params)
# IO.inspect(organization1)
# EMPLOYEE1 - OWNER
emp1_params = %{
email: "[email protected]",
email_confirmation: "[email protected]",
last_name: "Jones1",
first_name: "Sam",
password: "password",
}
{:ok, employee1} =
TurnStile.Staff.insert_register_employee(emp1_params, organization: organization1)
# IO.inspect(employee1)
{:ok, org_w_emps} = TurnStile.Company.update_employee_assoc(organization1, employee1)
role =
TurnStile.Roles.build_role(%{
name: EmployeeRolesMap.get_permission_role("OWNER"),
value: to_string(EmployeeRolesMap.get_permission_role_value("OWNER"))
})
# add has_many role assocations
role = TurnStile.Roles.assocaiate_role_with_employee(role, employee1)
role = TurnStile.Roles.assocaiate_role_with_organization(role, org_w_emps)
# USERS W ORG1
user1 = %{
first_name: "Joe",
last_name: "Schmoe",
email: "[email protected]",
phone: "777777777",
health_card_num: 1234
}
{:ok, role1} = TurnStile.Roles.insert_role(employee1.id, org_w_emps.id, role)
{:ok, user1} = TurnStile.Patients.create_user_w_assocs(employee1, user1, role1, organization1)
{:ok, user1} = TurnStile.Patients.insert_user_struct(user1)
# IO.inspect(role1, label: "AAAAAA")
all = %{
organization: organization1,
employee: employee1,
role: role1,
user: user1
}
# IO.inspect(all, label: "AAAAAA")
# TurnStile .Repo.rollback({:rolling_back})
# end)
# {_, all} = List.last(elem(Code.eval_file("./loader.exs"),1))