mirror of https://github.com/doccano/doccano.git
3 changed files with 93 additions and 2 deletions
Split View
Diff Options
@ -0,0 +1,27 @@ |
|||
from django.contrib.auth.management.commands import createsuperuser |
|||
from django.core.management import CommandError |
|||
|
|||
|
|||
class Command(createsuperuser.Command): |
|||
help = 'Non-interactively create an admin user' |
|||
|
|||
def add_arguments(self, parser): |
|||
super(Command, self).add_arguments(parser) |
|||
parser.add_argument('--password', default=None, |
|||
help='The password for the admin.') |
|||
|
|||
def handle(self, *args, **options): |
|||
password = options.get('password') |
|||
username = options.get('username') |
|||
|
|||
if password and not username: |
|||
raise CommandError('--username is required if specifying --password') |
|||
|
|||
super(Command, self).handle(*args, **options) |
|||
|
|||
if password: |
|||
database = options.get('database') |
|||
db = self.UserModel._default_manager.db_manager(database) |
|||
user = db.get(username=username) |
|||
user.set_password(password) |
|||
user.save() |
@ -0,0 +1,9 @@ |
|||
#!/usr/bin/env bash |
|||
|
|||
if [[ "$#" -ne 3 ]]; then echo "Usage: $0 <username> <email> <password>" >&2; exit 1; fi |
|||
|
|||
set -o errexit |
|||
|
|||
python app/manage.py wait_for_db |
|||
python app/manage.py migrate |
|||
python app/manage.py create_admin --noinput --username="$1" --email="$2" --password="$3" |
Write
Preview
Loading…
Cancel
Save