This commit is contained in:
virusdefender
2017-01-23 16:01:56 +08:00
parent 0f03e75713
commit 3e42e6648e
24 changed files with 58 additions and 511 deletions

View File

@@ -1,4 +1,3 @@
# coding=utf-8
from django.core.management.base import BaseCommand
from account.models import User, UserProfile, AdminType
from utils.shortcuts import rand_str
@@ -12,9 +11,10 @@ class Command(BaseCommand):
self.stdout.write(self.style.WARNING("Super admin user 'root' already exists, "
"would you like to reset it's password?\n"
"Input yes to confirm: "))
if raw_input() == "yes":
if input() == "yes":
rand_password = rand_str(length=6)
admin.set_password(rand_password)
# admin.set_password(rand_password)
admin.set_password("rootroot")
admin.save()
self.stdout.write(self.style.SUCCESS("Successfully created super admin user password.\n"
"Username: root\nPassword: %s\n"
@@ -27,7 +27,9 @@ class Command(BaseCommand):
except User.DoesNotExist:
user = User.objects.create(username="root", email="root@oj.com", admin_type=AdminType.SUPER_ADMIN)
rand_password = rand_str(length=6)
user.set_password(rand_password)
# user.set_password(rand_password)
# for dev
user.set_password("rootroot")
user.save()
UserProfile.objects.create(user=user)
self.stdout.write(self.style.SUCCESS("Successfully created super admin user.\n"