Files
smoothschedule/smoothschedule/create_admin.py
poduck 2e111364a2 Initial commit: SmoothSchedule multi-tenant scheduling platform
This commit includes:
- Django backend with multi-tenancy (django-tenants)
- React + TypeScript frontend with Vite
- Platform administration API with role-based access control
- Authentication system with token-based auth
- Quick login dev tools for testing different user roles
- CORS and CSRF configuration for local development
- Docker development environment setup

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-27 01:43:20 -05:00

41 lines
1.1 KiB
Python

#!/usr/bin/env python
"""Create a platform admin user for testing."""
import os
import django
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings.local")
django.setup()
from smoothschedule.users.models import User
from rest_framework.authtoken.models import Token
# Create or get a superuser with platform admin role
user, created = User.objects.get_or_create(
username='admin',
defaults={
'email': 'admin@smoothschedule.com',
'is_staff': True,
'is_superuser': True,
'role': User.Role.SUPERUSER,
}
)
if created:
user.set_password('admin123')
user.save()
print(f"Created new superuser: {user.username}")
else:
user.role = User.Role.SUPERUSER
user.is_staff = True
user.is_superuser = True
user.set_password('admin123')
user.save()
print(f"Updated existing user: {user.username}")
# Create or get auth token
token, _ = Token.objects.get_or_create(user=user)
print(f"\nAuth token: {token.key}")
print(f"User role: {user.role}")
print(f"\nYou can now use this token to test the API:")
print(f'curl -H "Authorization: Token {token.key}" http://lvh.me:8000/api/platform/businesses/')