##// END OF EJS Templates
Add 'reset pedestal' option
Add 'reset pedestal' option

File last commit:

r376:cd7f82cbe0ca
r444:d8e453ba0459
Show More
createsuperuser_if_none_exists.py
25 lines | 860 B | text/x-python | PythonLexer
/ volumes / sirm / apps / accounts / management / commands / createsuperuser_if_none_exists.py
import os
from django.core.management.base import BaseCommand
from django.contrib.auth import get_user_model
class Command(BaseCommand):
"""
Create a superuser if none exist
Example:
manage.py createsuperuser_if_none_exists --user=admin123 --password=admin123 --email=admin123@igp.gob.pe
"""
def handle(self, *args, **options):
User = get_user_model()
username = os.environ.get('SIRM_USER', 'admin')
password = os.environ.get('SIRM_PASSWORD', 'soporte')
email = os.environ.get('SIRM_EMAIL', 'admin@igp.gob.pe')
if User.objects.exists():
self.stdout.write(f'Local user "{username}" currently exists')
return
User.objects.create_superuser(username=username, password=password, email=email)
self.stdout.write(f'Local user "{username}" was created')