Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

streams: Set creator for some initial streams in populate_db.

tnmkr51635c81fcb5
diff --git a/zerver/lib/bulk_create.py b/zerver/lib/bulk_create.py
index 3bc7af44239..03be8210d4f 100644
--- a/zerver/lib/bulk_create.py
+++ b/zerver/lib/bulk_create.py
@@ -222,6 +222,7 @@ def bulk_create_streams(realm: Realm, stream_dict: Dict[str, Dict[str, Any]]) ->
is_web_public=options.get("is_web_public", False),
is_in_zephyr_realm=realm.is_zephyr_mirror_realm,
can_remove_subscribers_group=administrators_user_group,
+ creator=options.get("creator", None),
),
)
# Sort streams by name before creating them so that we can have a
diff --git a/zerver/tests/test_subs.py b/zerver/tests/test_subs.py
index d1c20b4856c..03ea8149cac 100644
--- a/zerver/tests/test_subs.py
+++ b/zerver/tests/test_subs.py
@@ -4470,7 +4470,20 @@ class SubscriptionAPITest(ZulipTestCase):
self.assertEqual(stream["creator_id"], iago.id)
continue
- # Streams that aren't created using the api should have no creator
+ # We assign creator to some streams in populate_db.
+ if stream["name"] == "Venice":
+ self.assertEqual(stream["creator_id"], self.example_user("polonius").id)
+ continue
+
+ if stream["name"] == "Scotland":
+ self.assertEqual(stream["creator_id"], self.example_user("iago").id)
+ continue
+
+ if stream["name"] == "core team":
+ self.assertEqual(stream["creator_id"], self.example_user("desdemona").id)
+ continue
+
+ # Other streams that weren't created using the api should have no creator.
self.assertIsNone(stream["creator_id"])
def test_private_stream_policies(self) -> None:
diff --git a/zilencer/management/commands/populate_db.py b/zilencer/management/commands/populate_db.py
index 6d0c87ebd13..1b6b762403d 100644
--- a/zilencer/management/commands/populate_db.py
+++ b/zilencer/management/commands/populate_db.py
@@ -637,12 +637,13 @@ class Command(BaseCommand):
]
stream_dict: Dict[str, Dict[str, Any]] = {
"Denmark": {"description": "A Scandinavian country"},
- "Scotland": {"description": "Located in the United Kingdom"},
- "Venice": {"description": "A northeastern Italian city"},
+ "Scotland": {"description": "Located in the United Kingdom", "creator": iago},
+ "Venice": {"description": "A northeastern Italian city", "creator": polonius},
"Rome": {"description": "Yet another Italian city", "is_web_public": True},
"core team": {
"description": "A private channel for core team members",
"invite_only": True,
+ "creator": desdemona,
},
}
@@ -1001,13 +1002,14 @@ class Command(BaseCommand):
"devel": {"description": "For developing"},
# ビデオゲーム - VideoGames (japanese)
"ビデオゲーム": {
- "description": f"Share your favorite video games! {raw_emojis[2]}"
+ "description": f"Share your favorite video games! {raw_emojis[2]}",
+ "creator": shiva,
},
"announce": {
"description": "For announcements",
"stream_post_policy": Stream.STREAM_POST_POLICY_ADMINS,
},
- "design": {"description": "For design"},
+ "design": {"description": "For design", "creator": hamlet},
"support": {"description": "For support"},
"social": {"description": "For socializing"},
"test": {"description": "For testing `code`"},