-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move create_debug_users into a management command
- Loading branch information
1 parent
ed80196
commit 212b674
Showing
4 changed files
with
31 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
from __future__ import annotations | ||
|
||
import contextlib | ||
from getpass import getpass | ||
|
||
from django.core.management.base import BaseCommand | ||
|
||
import tin.tests.create_users as users | ||
|
||
|
||
class Command(BaseCommand): | ||
help = "Create users for debugging" | ||
|
||
def add_arguments(self, parser): | ||
parser.add_argument("--noinput", action="store_true", help="Do not ask for password") | ||
parser.add_argument("--force", action="store_true", help="Force creation of users") | ||
|
||
def handle(self, *args, **options): | ||
if not options["noinput"]: | ||
pwd = getpass("Enter password for all users: ") | ||
else: | ||
pwd = "jasongrace" | ||
|
||
with ( | ||
contextlib.redirect_stdout(self.stdout), # type: ignore[misc] | ||
contextlib.redirect_stderr(self.stderr), # type: ignore[misc] | ||
): | ||
users.add_users_to_database(password=pwd, verbose=True, force=options["force"]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters