-
Notifications
You must be signed in to change notification settings - Fork 0
/
seed.py
94 lines (82 loc) · 2.24 KB
/
seed.py
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
from app import app
from models.models import db
from models.User import User
from models.Experience import Experience
from datetime import datetime
# from dateutil import relativedelta
print("SEEDING")
db.create_all()
Experience.__table__.drop(db.engine)
db.drop_all()
db.create_all()
u1 = User.signup(
badge_number=100,
email='u1@mail.com',
password='password',
first_name="u1",
last_name="user",
dob=(datetime(year=2000, month=1, day=1).isoformat()),
gender="Prefer not to say",
address="123 Cherry lane",
city="New York",
state="NY",
zip_code="11001",
phone_number="9991234567",
is_student=True,
is_healthcare_provider=False,
is_multilingual=False
)
u2 = User.signup(
badge_number=200,
email='u2@mail.com',
password='password',
first_name="u2",
last_name="test",
dob=(datetime(year=2000, month=1, day=1).isoformat()),
gender="Prefer not to say",
address="1 Cherry lane",
city="New York",
state="NY",
zip_code="11001",
phone_number="9991234567",
is_student=False,
is_healthcare_provider=False,
is_multilingual=False
)
admin = User.signup(
badge_number=300,
email='admin@mail.com',
password='password',
first_name="Admin",
last_name="test",
dob=(datetime(year=2000, month=1, day=1).isoformat()),
gender="Prefer not to say",
address="123 Cherry lane",
city="New York",
state="NY",
zip_code="11001",
phone_number="9991234567",
is_student=False,
is_healthcare_provider=False,
is_multilingual=False
)
db.session.commit()
e1_sign_in = datetime(year=2022, month=1, day=5, hour=8).isoformat()
e1 = Experience(
date=datetime(year=2022, month=1, day=5),
sign_in_time=(datetime(year=2022, month=1, day=5, hour=8).isoformat()),
sign_out_time=(datetime(year=2022, month=1, day=5, hour=10).isoformat()),
department="Lab",
user_id=1
)
e2 = Experience(
date=datetime(year=2022, month=1, day=8),
sign_in_time=(datetime(year=2022, month=1, day=5, hour=12).isoformat()),
sign_out_time=(datetime(year=2022, month=1, day=5, hour=16).isoformat()),
department="Pharmacy",
user_id=1
)
# add experiences to db
db.session.add_all([e1, e2])
admin.is_admin = True
db.session.commit()