-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
140 lines (120 loc) Β· 4.32 KB
/
Copy pathsetup.py
File metadata and controls
140 lines (120 loc) Β· 4.32 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
134
135
136
137
138
139
140
# setup.py - Initialize QLess Database
from utils.firebase_config import initialize_firebase, get_db_reference
from auth.authentication import auth_manager
from services.facility_service import facility_service
from config import SUPER_ADMIN_EMAILS, ROLES
from datetime import datetime
def setup_database():
"""Initialize database with default data"""
print("π§ Initializing QLess Database...")
print("=" * 60)
# Initialize Firebase
initialize_firebase()
# 1. Create default facilities
print("\nπ Creating default facilities...")
default_facilities = [
{
'name': 'Food Sutra Mess Hall',
'capacity': 200,
'icon': 'π½οΈ',
'avg_time_per_person': 2,
'open_hour_start': 7,
'open_hour_end': 22,
'description': 'serving breakfast, lunch, and dinner'
},
{
'name': 'Sheela Mess Hall',
'capacity': 200,
'icon': 'π½οΈ',
'avg_time_per_person': 2,
'open_hour_start': 7,
'open_hour_end': 22,
'description': 'serving breakfast, lunch, and dinner'
},
{
'name': 'Surinder Arora Mess Hall',
'capacity': 200,
'icon': 'π½οΈ',
'avg_time_per_person': 2,
'open_hour_start': 7,
'open_hour_end': 22,
'description': 'serving breakfast, lunch, and dinner'
}
]
for facility in default_facilities:
success, message = facility_service.create_facility(**facility)
if success:
print(f" β
Created: {facility['icon']} {facility['name']}")
else:
print(f" β οΈ {facility['name']}: {message}")
# 2. Create admin accounts
print("\nπ₯ Creating admin accounts...")
for email in SUPER_ADMIN_EMAILS:
success, message = auth_manager.register_user(
email=email,
password='superadmin123',
name='Super Admin User',
role=ROLES['SUPER_ADMIN']
)
if success:
print(f" β
Created admin: {email}")
print(f" π Default password: admin123 (CHANGE THIS!)")
else:
print(f" β οΈ {email}: {message}")
# 3. Create sample student account
print("\nπ Creating sample student account...")
success, message = auth_manager.register_user(
email='student@iiti.ac.in',
password='student123',
name='Test Student',
role=ROLES['STUDENT']
)
if success:
print(f" β
Created student: student@campus.edu")
print(f" π Password: student123")
else:
print(f" β οΈ {message}")
success, message = auth_manager.register_user(
email='admin@iiti.ac.in',
password='admin123',
name='Test Admin',
role=ROLES['ADMIN']
)
if success:
print(f" β
Created admin: admin@campus.edu")
print(f" π Password: admin123")
else:
print(f" β οΈ {message}")
# 4. Initialize settings
print("\nβοΈ Initializing system settings...")
settings_ref = get_db_reference('settings')
settings_ref.set({
'app_name': 'QLess',
'version': '1.0.0',
'initialized_at': datetime.now().isoformat(),
'auto_refresh_interval': 5000,
'features': {
'notifications': False,
'predictions': False
}
})
print(" β
Settings initialized")
# Success message
print("\n" + "=" * 60)
print("β
Database initialization complete!")
print("=" * 60)
print("\nπ You can now run: streamlit run app.py")
print("\nπ Default Login Credentials:")
print(" Admin: admin@campus.edu / admin123")
print(" Student: student@campus.edu / student123")
print("\nβ οΈ IMPORTANT: Change default passwords after first login!")
print("=" * 60)
if __name__ == "__main__":
try:
setup_database()
except Exception as e:
print(f"\nβ Setup failed: {e}")
print("\nPlease check:")
print("1. serviceAccountKey.json is in the project root")
print("2. Firebase database URL is correct in config.py")
print("3. Firebase Realtime Database is enabled")