Create an admin user as post-deploy step
This commit is contained in:
Родитель
073cb90531
Коммит
5f556b8b4f
11
app.json
11
app.json
|
@ -13,9 +13,6 @@
|
|||
"client_secret": {
|
||||
"required": true
|
||||
},
|
||||
"CORS_ORIGIN_WHITELIST": {
|
||||
"required": true
|
||||
},
|
||||
"AWS_ACCESS_KEY_ID": {
|
||||
"required": true
|
||||
},
|
||||
|
@ -32,7 +29,8 @@
|
|||
"required": true
|
||||
},
|
||||
"USE_S3": "True",
|
||||
"SSL_PROTECTION": "True"
|
||||
"SSL_PROTECTION": "True",
|
||||
"CORS_ORIGIN_ALLOW_ALL": "True"
|
||||
},
|
||||
"addons": [
|
||||
"heroku-postgresql:hobby-dev"
|
||||
|
@ -41,5 +39,8 @@
|
|||
{
|
||||
"url": "heroku/python"
|
||||
}
|
||||
]
|
||||
],
|
||||
"scripts": {
|
||||
"postdeploy": "python manage.py review_app_admin"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
"""
|
||||
Management command called during Heroku Review App post-deployment phase: create an admin user and print its random
|
||||
password in the logs.
|
||||
"""
|
||||
|
||||
from django.core.management.base import BaseCommand
|
||||
|
||||
from pulseapi.users.models import EmailUser
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
help = "Create a super admin user to use on Heroku Review App"
|
||||
|
||||
def handle(self, *args, **options):
|
||||
password = EmailUser.objects.make_random_password()
|
||||
self.stdout.write('Your admin password is: {}'.format(password))
|
||||
user = EmailUser.objects.create_superuser('test', 'test@test.org', password)
|
||||
user.save()
|
Загрузка…
Ссылка в новой задаче