- Add audit status filter (Audited/Not Audited) to agent management and admin dashboard - Add token usage tracking: token_count per timeline entry, total_tokens on agents - Token badge on agent cards, Total Tokens stat in usage modal, dual-axis chart - Sort by Total Tokens option, total_tokens in CSV export - Mailgun email notifications for high token usage (optional, non-blocking) - Cooldown-based notification tracking in MongoDB token_notifications collection - Add promote_admin.py utility script for user promotion - Update CLAUDE.md documentation for all new features Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
35 lines
902 B
Python
35 lines
902 B
Python
"""One-time script to promote a user to admin. Run on the server where .env has the correct MONGODB_URI.
|
|
|
|
Usage: python promote_admin.py nick.viljoen@brandtech.plus
|
|
"""
|
|
import asyncio
|
|
import sys
|
|
from dotenv import load_dotenv
|
|
|
|
load_dotenv()
|
|
|
|
from database import users_collection
|
|
|
|
|
|
async def promote(email: str):
|
|
user = await users_collection.find_one({"email": email})
|
|
if not user:
|
|
print(f"User '{email}' not found in database.")
|
|
return
|
|
|
|
if user.get("is_admin"):
|
|
print(f"User '{email}' is already an admin.")
|
|
return
|
|
|
|
await users_collection.update_one(
|
|
{"email": email},
|
|
{"$set": {"is_admin": True}},
|
|
)
|
|
print(f"User '{email}' promoted to admin successfully.")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
if len(sys.argv) != 2:
|
|
print("Usage: python promote_admin.py <email>")
|
|
sys.exit(1)
|
|
asyncio.run(promote(sys.argv[1]))
|