-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlist_users.py
More file actions
39 lines (31 loc) · 1.12 KB
/
list_users.py
File metadata and controls
39 lines (31 loc) · 1.12 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
#!/usr/bin/env python3
"""Quick script to list all user accounts"""
import sys
import os
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
from app import app, db, User
from datetime import datetime
def list_users():
with app.app_context():
users = User.query.order_by(User.created_at.desc()).all()
if not users:
print("❌ No users found")
return
print(f"👥 Found {len(users)} user(s):")
print("=" * 60)
for user in users:
status = "✅ Active" if user.is_active else "❌ Disabled"
created = user.created_at.strftime('%Y-%m-%d %H:%M')
role_emoji = {
'admin': '🔴',
'manager': '🟡',
'operator': '🔵',
'readonly': '⚪'
}.get(user.role, '❓')
print(f"{role_emoji} {user.username}")
print(f" Role: {user.role.title()}")
print(f" Status: {status}")
print(f" Created: {created}")
print("-" * 40)
if __name__ == '__main__':
list_users()