-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.py
More file actions
133 lines (112 loc) · 2.95 KB
/
script.py
File metadata and controls
133 lines (112 loc) · 2.95 KB
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
import sys
import os
if len(sys.argv) < 2:
exit()
def seed_database():
from passlib.hash import bcrypt
from db.database import Session
import db.tables
from core.division.model import Division
from core.grade.model import Grade
from core.schedule.model import Schedule
from core.grade.type import GradeLevel, Vocational
from core.user.model import User, UserPending
from core.user.type import Role
from core.attendance.model import Attendance
from core.attendance.type import State
db = Session()
grade = Grade(
grade=GradeLevel.XII,
vocational=Vocational.TKI,
name="XII PPLG 1"
)
division = Division(
name="Game Development",
wa_group_link="https://whatsapp.com",
)
division2 = Division(
name="Web Development",
wa_group_link="https://whatsapp.com",
)
schedule = Schedule(
title='Pertemuan rutin',
note="This is schedule note",
location="D2.4",
token="TOKEN123",
attendance_is_open=False,
division_id=1
)
schedule2 = Schedule(
title='Pertemuan rutin',
note="This is schedule note",
location="C22",
token="TOKEN234",
attendance_is_open=False,
division_id=2
)
user_pending = UserPending(
name="John Doe",
email="johndoe@gmail.com",
motivation="Here is my motivation",
division_id=1,
grade_id=1,
)
user = User(
name="User",
email="user@gmail.com",
password=bcrypt.hash("password"),
role=Role.user,
refresh_token="123",
phone_number="08123456789",
division_id=1,
grade_id=1,
)
admin = User(
name="Admin",
email="admin@gmail.com",
password=bcrypt.hash("password"),
role=Role.admin,
refresh_token="1234",
phone_number="08123456789",
division_id=1,
grade_id=1,
)
superadmin = User(
name="SuperAdmin",
email="superadmin@gmail.com",
password=bcrypt.hash("password"),
role=Role.superadmin,
refresh_token="12345",
phone_number="08123456789",
division_id=1,
grade_id=1,
)
attendance = Attendance(
status=State.HADIR,
rating=5,
feedback="Good",
suggestion="Talking too fast",
)
db.add(grade)
db.add(division)
db.add(division2)
db.add(schedule)
db.add(schedule2)
db.add(user_pending)
db.add(user)
db.add(admin)
db.add(superadmin)
db.commit()
attendance.schedule_id = schedule.id
attendance.user_id = user.id
db.add(attendance)
db.commit()
if __name__ == "__main__":
sys.path.insert(0, os.path.abspath(
os.path.join(os.path.dirname(__file__), "src")
))
if sys.argv[1] == "seed":
seed_database()
elif sys.argv[1] == "drop-all":
from db import tables
tables.drop_all()