mirror of
https://github.com/zulip/zulip.git
synced 2025-11-12 09:58:06 +00:00
Make populate_db set the is_bot flag on bot accounts.
(imported from commit 93a507faa2b19fde05376fd73ed3a65149cfce68)
This commit is contained in:
@@ -15,7 +15,7 @@ def bulk_create_realms(realm_list):
|
|||||||
existing_realms.add(domain)
|
existing_realms.add(domain)
|
||||||
Realm.objects.bulk_create(realms_to_create)
|
Realm.objects.bulk_create(realms_to_create)
|
||||||
|
|
||||||
def bulk_create_users(realms, users_raw):
|
def bulk_create_users(realms, users_raw, bot=False):
|
||||||
"""
|
"""
|
||||||
Creates and saves a UserProfile with the given email.
|
Creates and saves a UserProfile with the given email.
|
||||||
Has some code based off of UserManage.create_user, but doesn't .save()
|
Has some code based off of UserManage.create_user, but doesn't .save()
|
||||||
@@ -33,7 +33,7 @@ def bulk_create_users(realms, users_raw):
|
|||||||
for (email, full_name, short_name, active) in users:
|
for (email, full_name, short_name, active) in users:
|
||||||
domain = email_to_domain(email)
|
domain = email_to_domain(email)
|
||||||
profile = create_user_profile(realms[domain], email,
|
profile = create_user_profile(realms[domain], email,
|
||||||
initial_password(email), active, False,
|
initial_password(email), active, bot,
|
||||||
full_name, short_name, None)
|
full_name, short_name, None)
|
||||||
profiles_to_create.append(profile)
|
profiles_to_create.append(profile)
|
||||||
UserProfile.objects.bulk_create(profiles_to_create)
|
UserProfile.objects.bulk_create(profiles_to_create)
|
||||||
|
|||||||
@@ -30,12 +30,12 @@ from optparse import make_option
|
|||||||
|
|
||||||
settings.TORNADO_SERVER = None
|
settings.TORNADO_SERVER = None
|
||||||
|
|
||||||
def create_users(realms, name_list):
|
def create_users(realms, name_list, bot=False):
|
||||||
user_set = set()
|
user_set = set()
|
||||||
for full_name, email in name_list:
|
for full_name, email in name_list:
|
||||||
short_name = email_to_username(email)
|
short_name = email_to_username(email)
|
||||||
user_set.add((email, full_name, short_name, True))
|
user_set.add((email, full_name, short_name, True))
|
||||||
bulk_create_users(realms, user_set)
|
bulk_create_users(realms, user_set, bot)
|
||||||
|
|
||||||
def create_streams(realms, realm, stream_list):
|
def create_streams(realms, realm, stream_list):
|
||||||
stream_set = set()
|
stream_set = set()
|
||||||
@@ -198,7 +198,7 @@ class Command(BaseCommand):
|
|||||||
("Zulip Tutorial Bot", "tutorial-bot@zulip.com"),
|
("Zulip Tutorial Bot", "tutorial-bot@zulip.com"),
|
||||||
("Zulip Email Gateway", "emailgateway@zulip.com"),
|
("Zulip Email Gateway", "emailgateway@zulip.com"),
|
||||||
]
|
]
|
||||||
create_users(realms, hardcoded_zulip_users_nosubs)
|
create_users(realms, hardcoded_zulip_users_nosubs, bot=True)
|
||||||
|
|
||||||
if not options["test_suite"]:
|
if not options["test_suite"]:
|
||||||
# To keep the messages.json fixtures file for the test
|
# To keep the messages.json fixtures file for the test
|
||||||
@@ -236,7 +236,7 @@ class Command(BaseCommand):
|
|||||||
("Zulip Nagios Bot", "nagios-bot@zulip.com"),
|
("Zulip Nagios Bot", "nagios-bot@zulip.com"),
|
||||||
("Zulip Feedback Bot", "feedback@zulip.com"),
|
("Zulip Feedback Bot", "feedback@zulip.com"),
|
||||||
]
|
]
|
||||||
create_users(realms, internal_zulip_users_nosubs)
|
create_users(realms, internal_zulip_users_nosubs, bot=True)
|
||||||
|
|
||||||
# Mark all messages as read
|
# Mark all messages as read
|
||||||
with transaction.commit_on_success():
|
with transaction.commit_on_success():
|
||||||
|
|||||||
Reference in New Issue
Block a user