devtools: Remove development-only user creation management commands.

We now have nicer version available not only to developers, and it's
definitely better to deduplicate these.
This commit is contained in:
Tim Abbott 2022-03-20 21:53:35 -07:00 committed by Tim Abbott
parent e16043547b
commit 2328a81f55
3 changed files with 2 additions and 62 deletions

View File

@ -85,8 +85,8 @@
<ul> <ul>
<li><code>./manage.py populate_db</code>: Rebuilds database. Has options to e.g. create 3K users for testing.</li> <li><code>./manage.py populate_db</code>: Rebuilds database. Has options to e.g. create 3K users for testing.</li>
<li><code>./manage.py mark_all_messages_unread</code>: Useful for testing reading messages.</li> <li><code>./manage.py mark_all_messages_unread</code>: Useful for testing reading messages.</li>
<li><code>./manage.py add_new_realm</code>: Add a new realm. Useful for testing onboarding.</li> <li><code>./manage.py create_realm</code>: Add a new realm. Useful for testing onboarding.</li>
<li><code>./manage.py add_new_user</code>: Add a new user. Useful for testing onboarding.</li> <li><code>./manage.py create_user</code>: Add a new user. Useful for testing onboarding.</li>
<li><code>./manage.py add_mock_conversation</code>: Add test messages, streams, images, emoji, etc. <li><code>./manage.py add_mock_conversation</code>: Add test messages, streams, images, emoji, etc.
into the dev environment. First edit zilencer/management/commands/add_mock_conversation.py into the dev environment. First edit zilencer/management/commands/add_mock_conversation.py
to add the data you're testing. to add the data you're testing.

View File

@ -1,24 +0,0 @@
from typing import Any
from zerver.lib.actions import do_create_realm, do_create_user
from zerver.lib.management import ZulipBaseCommand
from zerver.models import Realm, UserProfile
class Command(ZulipBaseCommand):
help = """Add a new realm and initial user for manual testing of the onboarding process."""
def handle(self, *args: Any, **options: Any) -> None:
string_id = "realm{:02}".format(Realm.objects.filter(string_id__startswith="realm").count())
realm = do_create_realm(string_id, string_id)
name = "{:02}-user".format(UserProfile.objects.filter(email__contains="user@").count())
do_create_user(
f"{name}@{string_id}.zulip.com",
"password",
realm,
name,
role=UserProfile.ROLE_REALM_ADMINISTRATOR,
realm_creation=True,
acting_user=None,
)

View File

@ -1,36 +0,0 @@
from typing import Any
from django.core.management.base import CommandParser
from zerver.lib.actions import do_create_user
from zerver.lib.management import ZulipBaseCommand
from zerver.models import Realm, UserProfile
class Command(ZulipBaseCommand):
help = """Add a new user for manual testing of the onboarding process.
If realm is unspecified, will try to use a realm created by add_new_realm,
and will otherwise fall back to the zulip realm."""
def add_arguments(self, parser: CommandParser) -> None:
self.add_realm_args(parser)
def handle(self, *args: Any, **options: Any) -> None:
realm = self.get_realm(options)
if realm is None:
realm = (
Realm.objects.filter(string_id__startswith="realm").order_by("-string_id").first()
)
if realm is None:
print(
"Warning: Using default zulip realm, which has an unusual configuration.\n"
"Try running `manage.py add_new_realm`, and then running this again."
)
valid_realm = Realm.objects.get(string_id="zulip")
domain = "zulip.com"
else:
valid_realm = realm
domain = realm.string_id + ".zulip.com"
name = "{:02}-user".format(UserProfile.objects.filter(email__contains="user@").count())
do_create_user(f"{name}@{domain}", "password", valid_realm, name, acting_user=None)