2016-01-26 05:12:23 +00:00
|
|
|
# coding=utf-8
|
2016-01-26 08:39:30 +00:00
|
|
|
from django.core.management.base import BaseCommand
|
2016-01-26 05:12:23 +00:00
|
|
|
from account.models import User, SUPER_ADMIN, UserProfile
|
|
|
|
from utils.shortcuts import rand_str
|
|
|
|
|
|
|
|
|
|
|
|
class Command(BaseCommand):
|
|
|
|
def handle(self, *args, **options):
|
|
|
|
user = User.objects.create(username="root", real_name="root", email="root@oj.com", admin_type=SUPER_ADMIN)
|
|
|
|
rand_password = rand_str(length=6)
|
|
|
|
user.set_password(rand_password)
|
|
|
|
user.save()
|
|
|
|
UserProfile.objects.create(user=user)
|
2016-01-26 08:39:30 +00:00
|
|
|
self.stdout.write(self.style.SUCCESS("Successfully created super admin user.\nUsername: root\nPassword: %s\n"
|
|
|
|
"Remember to change password and turn on two factors auth "
|
|
|
|
"after installation." % rand_password))
|