stream-descriptions: Create wrapper for rendering stream descriptions.

In commit de65a04 we can see that if the need ever arises to modify
how stream descriptions are rendered, we would need to make changes
at 5 different call points which can be quite cumbersome. So this
functionality has been extracted to a new method called
'render_stream_descriptions'.
This commit is contained in:
Hemanth V. Alluri
2019-03-01 13:40:40 +05:30
committed by Tim Abbott
parent e0c6136ce1
commit ae126c452b
4 changed files with 14 additions and 12 deletions

View File

@@ -4,7 +4,6 @@ from zerver.lib.initial_password import initial_password
from zerver.models import Realm, Stream, UserProfile, \
Subscription, Recipient, RealmAuditLog
from zerver.lib.create_user import create_user_profile
from zerver.lib.bugdown import convert as bugdown_convert
def bulk_create_users(realm: Realm,
users_raw: Set[Tuple[str, str, str, bool]],
@@ -75,12 +74,13 @@ def bulk_create_streams(realm: Realm,
options['history_public_to_subscribers'] = (
not options.get("invite_only", False) and not realm.is_zephyr_mirror_realm)
if name.lower() not in existing_streams:
from zerver.lib.actions import render_stream_description
streams_to_create.append(
Stream(
realm=realm,
name=name,
description=options["description"],
rendered_description=bugdown_convert(options["description"], no_previews=True),
rendered_description=render_stream_description(options["description"]),
invite_only=options.get("invite_only", False),
is_announcement_only=options.get("is_announcement_only", False),
history_public_to_subscribers=options["history_public_to_subscribers"],