snapshot: preserve current onboarding offboarding portal state
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
from django.contrib.auth import get_user_model
|
||||
from django.core.management.base import BaseCommand
|
||||
|
||||
|
||||
DEFAULT_USERS = [
|
||||
{
|
||||
'username': 'admin_test',
|
||||
'email': 'admin_test@tub.co',
|
||||
'password': 'admin12345',
|
||||
'first_name': 'Admin',
|
||||
'last_name': 'Test',
|
||||
'is_staff': True,
|
||||
'is_superuser': True,
|
||||
},
|
||||
{
|
||||
'username': 'user_test',
|
||||
'email': 'user_test@tub.co',
|
||||
'password': 'user12345',
|
||||
'first_name': 'Normal',
|
||||
'last_name': 'User',
|
||||
'is_staff': False,
|
||||
'is_superuser': False,
|
||||
},
|
||||
]
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
help = 'Create initial test/admin users when the database is empty.'
|
||||
|
||||
def handle(self, *args, **options):
|
||||
user_model = get_user_model()
|
||||
if user_model.objects.exists():
|
||||
self.stdout.write('bootstrap skipped: users already exist')
|
||||
return
|
||||
|
||||
for item in DEFAULT_USERS:
|
||||
user = user_model.objects.create_user(
|
||||
username=item['username'],
|
||||
email=item['email'],
|
||||
password=item['password'],
|
||||
first_name=item['first_name'],
|
||||
last_name=item['last_name'],
|
||||
is_staff=item['is_staff'],
|
||||
is_superuser=item['is_superuser'],
|
||||
)
|
||||
self.stdout.write(f'created {user.username}')
|
||||
|
||||
self.stdout.write(self.style.SUCCESS('initial users created'))
|
||||
Reference in New Issue
Block a user