forked from alages97/jersey_bidding
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsetUpSQL.py
123 lines (113 loc) · 5.3 KB
/
setUpSQL.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
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
from jersey_bidder import create_app, db
from jersey_bidder.models import *
from flask_user import login_required, SQLAlchemyAdapter, UserManager, UserMixin
def setUp(app):
with app.app_context():
#drop all tables first
UserSports.__table__.drop(db.engine)
Sport.__table__.drop(db.engine)
Choice.__table__.drop(db.engine)
User.__table__.drop(db.engine)
JerseyNumber.__table__.drop(db.engine)
Gender.__table__.drop(db.engine)
Admin.__table__.drop(db.engine)
FlaskUserRoles.__table__.drop(db.engine)
FlaskUser.__table__.drop(db.engine)
Role.__table__.drop(db.engine)
db.create_all()
admin = Role(name='Admin')
bidder = Role(name='Bidder')
viewer = Role(name='Viewer')
db.session.add(admin)
db.session.add(bidder)
db.session.add(viewer)
# Create Admin Account For Hackers
flaskUserHacker = FlaskUser(email='[email protected]', username='eusoffhacker', password='noshady')
flaskUserHacker.roles.append(admin)
hackerAdmin = Admin(name='The Master', flaskUser=flaskUserHacker)
db.session.add(hackerAdmin)
# Create Admin Account For SMC
flaskUserSMC = FlaskUser(email='[email protected]', username='eusoffSMC', password='ydraxan3rg')
flaskUserSMC.roles.append(admin)
smcAdmin = Admin(name='SMC Admin', flaskUser=flaskUserSMC)
db.session.add(smcAdmin)
#add Gender
male = Gender(genderName = "Male")
female = Gender(genderName = "Female")
mixed = Gender(genderName = "Mixed")
db.session.add(male)
db.session.add(female)
db.session.add(mixed)
# Add sports
frisbee = Sport(sportName = "Frisbee", Gender=mixed)
Softball = Sport(sportName = "Softball", Gender=mixed)
Takraw_Male = Sport(sportName = "Takraw", Gender=male)
Netball_Female = Sport(sportName = "Netball", Gender=female)
Tennis_Male = Sport(sportName = "Tennis", Gender=male)
Tennis_Female = Sport(sportName = "Tennis", Gender=female)
Floorball_Male = Sport(sportName = "Floorball", Gender=male)
Floorball_Female = Sport(sportName = "Floorball", Gender=female)
Squash_Male = Sport(sportName = "Squash", Gender=male)
Squash_Female = Sport(sportName = "Squash", Gender=female)
Badminton_Male = Sport(sportName = "Badminton", Gender=male)
Badminton_Female = Sport(sportName = "Badminton", Gender=female)
Soccer_Male = Sport(sportName = "Soccer", Gender=male)
Soccer_Female = Sport(sportName = "Soccer", Gender=female)
TableTennis_Male = Sport(sportName = "Table Tennis", Gender=male)
TableTennis_Female = Sport(sportName = "Table Tennis", Gender=female)
Handball_Male = Sport(sportName = "Handball", Gender=male)
Handball_Female = Sport(sportName = "Handball", Gender=female)
RoadRelay_Male = Sport(sportName = "Road Relay", Gender=male)
RoadRelay_Female = Sport(sportName = "Road Relay", Gender=female)
Basketball_Male = Sport(sportName = "Basketball", Gender=male)
Basketball_Femal = Sport(sportName = "Basketball", Gender=female)
Swim_Male = Sport(sportName = "Swim", Gender=male)
Swim_Female = Sport(sportName = "Swim", Gender=female)
TouchRugby_Male = Sport(sportName = "Touch Rugby", Gender=male)
TouchRugby_Female = Sport(sportName = "Touch Rugby", Gender=female)
Track_Male = Sport(sportName = "Track", Gender=male)
Track_Female = Sport(sportName = "Track", Gender=female)
Volleyball_Male = Sport(sportName = "Volleyball", Gender=male)
Volleyball_Female = Sport(sportName = "Volleyball", Gender=female)
db.session.add(frisbee)
db.session.add(Softball)
db.session.add(Takraw_Male)
db.session.add(Netball_Female)
db.session.add(Tennis_Male)
db.session.add(Tennis_Female)
db.session.add(Floorball_Male)
db.session.add(Floorball_Female)
db.session.add(Squash_Male)
db.session.add(Squash_Female)
db.session.add(Badminton_Male)
db.session.add(Badminton_Female)
db.session.add(Soccer_Male)
db.session.add(Soccer_Female)
db.session.add(TableTennis_Male)
db.session.add(TableTennis_Female)
db.session.add(Handball_Male)
db.session.add(Handball_Female)
db.session.add(RoadRelay_Male)
db.session.add(RoadRelay_Female)
db.session.add(Basketball_Male)
db.session.add(Basketball_Femal)
db.session.add(Swim_Male)
db.session.add(Swim_Female)
db.session.add(TouchRugby_Male)
db.session.add(TouchRugby_Female)
db.session.add(Track_Male)
db.session.add(Track_Female)
db.session.add(Volleyball_Male)
db.session.add(Volleyball_Female)
#add jersey numbers
for i in range(198):
currentGender = male
currentNumber = i + 1
if currentNumber > 99:
currentGender = female
currentNumber = currentNumber - 99
currentJersey = JerseyNumber(number = currentNumber, isTaken = False, gender = currentGender)
db.session.add(currentJersey)
db.session.commit()
if __name__ == "__main__":
setUp(create_app())