Download scripts/set_admin_flag.py from dn-scribe/attstore: direct link, hf CLI and curl.
- Browser
- Download file 836 Bytes
-
https://huggingface.co/spaces/dn-scribe/attstore/resolve/main/scripts/set_admin_flag.py
- Command line
-
hf download hf://spaces/dn-scribe/attstore/scripts/set_admin_flag.py
-
curl -L -o set_admin_flag.py https://huggingface.co/spaces/dn-scribe/attstore/resolve/main/scripts/set_admin_flag.py
836 Bytes
| #!/usr/bin/env python3 | |
| """ | |
| One-time script to set is_admin flag for existing admin user(s) | |
| Run this after adding the is_admin column to the database | |
| """ | |
| import sys | |
| import os | |
| # Add parent directory to path so we can import app | |
| sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) | |
| from app import db | |
| from models import User | |
| def main(): | |
| print("Setting admin flag for existing admin users...") | |
| # Find the admin user | |
| admin_user = User.query.filter_by(username='admin').first() | |
| if admin_user: | |
| admin_user.is_admin = True | |
| db.session.commit() | |
| print(f"Updated user {admin_user.username} (ID: {admin_user.id}) - admin flag set to True") | |
| else: | |
| print("Warning: No 'admin' user found in the database") | |
| print("Done!") | |
| if __name__ == "__main__": | |
| main() | |