larxius commited on
Commit
86f532a
·
verified ·
1 Parent(s): a531bf8

Update backend_structured/routes.py

Browse files
Files changed (1) hide show
  1. backend_structured/routes.py +16 -1
backend_structured/routes.py CHANGED
@@ -1299,12 +1299,27 @@ def get_global_stats(current_user):
1299
  all_users = User.query.all()
1300
  for u in all_users:
1301
  org = db.session.get(Organization, u.org_id) if u.org_id else None
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1302
  users_data.append({
1303
  'id': u.id,
1304
  'email': u.email,
1305
  'role': u.role,
1306
  'org_id': u.org_id,
1307
- 'org_name': org.name if org else 'No Org (Super Admin)',
1308
  'created_at': u.created_at.isoformat() + 'Z' if u.created_at else None
1309
  })
1310
 
 
1299
  all_users = User.query.all()
1300
  for u in all_users:
1301
  org = db.session.get(Organization, u.org_id) if u.org_id else None
1302
+ if org:
1303
+ org_name = org.name
1304
+ elif u.role == 'super_admin':
1305
+ org_name = 'No Org (Super Admin)'
1306
+ elif u.role == 'admin':
1307
+ org_name = 'No Org (Admin)'
1308
+ elif u.role == 'support_engineer':
1309
+ org_name = 'No Org (Support Engineer)'
1310
+ elif u.role == 'soc_analyst':
1311
+ org_name = 'No Org (SOC Analyst)'
1312
+ elif u.role == 'executive_user':
1313
+ org_name = 'No Org (Executive)'
1314
+ else:
1315
+ org_name = 'No Org'
1316
+
1317
  users_data.append({
1318
  'id': u.id,
1319
  'email': u.email,
1320
  'role': u.role,
1321
  'org_id': u.org_id,
1322
+ 'org_name': org_name,
1323
  'created_at': u.created_at.isoformat() + 'Z' if u.created_at else None
1324
  })
1325