Spaces:
Sleeping
Sleeping
fix: convert datetime to str in admin users list to fix JSON serializable error
Browse files
app.py
CHANGED
|
@@ -3047,7 +3047,10 @@ def admin_users_list():
|
|
| 3047 |
cursor.execute("SELECT id, email, role, created_at FROM users ORDER BY id ASC")
|
| 3048 |
user_list = cursor.fetchall()
|
| 3049 |
for u in user_list:
|
| 3050 |
-
|
|
|
|
|
|
|
|
|
|
| 3051 |
u['permissions'] = [row['tool_path'] for row in cursor.fetchall()]
|
| 3052 |
conn.close()
|
| 3053 |
return render_template('tools/admin_users/index.html', users=user_list, available_tools=AVAILABLE_TOOLS)
|
|
|
|
| 3047 |
cursor.execute("SELECT id, email, role, created_at FROM users ORDER BY id ASC")
|
| 3048 |
user_list = cursor.fetchall()
|
| 3049 |
for u in user_list:
|
| 3050 |
+
# Convert datetime to string so Jinja2 tojson can serialize it
|
| 3051 |
+
if u.get('created_at') and not isinstance(u['created_at'], str):
|
| 3052 |
+
u['created_at'] = str(u['created_at'])
|
| 3053 |
+
cursor.execute("SELECT tool_path FROM user_permissions WHERE user_id = %s", (u['id'],))
|
| 3054 |
u['permissions'] = [row['tool_path'] for row in cursor.fetchall()]
|
| 3055 |
conn.close()
|
| 3056 |
return render_template('tools/admin_users/index.html', users=user_list, available_tools=AVAILABLE_TOOLS)
|