actions: Remove unnecessary do_create_stream function.

This commit is contained in:
Tim Abbott 2017-01-29 21:28:33 -08:00
parent 700089f386
commit 4d3e97f304
3 changed files with 3 additions and 17 deletions

View File

@ -1049,19 +1049,6 @@ def check_typing_notification(sender, notification_to, operator):
raise ValueError('Forbidden recipient type')
return {'sender': sender, 'recipient': recipient, 'op': operator}
def do_create_stream(realm, stream_name):
# type: (Realm, Text) -> None
# This is used by a management command now, mostly to facilitate testing. It
# doesn't simulate every single aspect of creating a subscription; for example,
# we don't send Zulips to users to tell them they have been subscribed.
stream = Stream()
stream.realm = realm
stream.name = stream_name
stream.save()
Recipient.objects.create(type_id=stream.id, type=Recipient.STREAM)
subscribers = UserProfile.objects.filter(realm=realm, is_active=True, is_bot=False)
bulk_add_subscriptions([stream], subscribers)
def create_stream_if_needed(realm, stream_name, invite_only=False, stream_description = ""):
# type: (Realm, Text, bool, Text) -> Tuple[Stream, bool]
(stream, created) = Stream.objects.get_or_create(

View File

@ -5,7 +5,7 @@ from typing import Any
from django.core.management.base import BaseCommand
from zerver.lib.actions import do_create_stream
from zerver.lib.actions import create_stream_if_needed
from zerver.lib.str_utils import force_text
from zerver.models import Realm, get_realm
@ -35,5 +35,5 @@ the command."""
if realm is None:
print("Unknown string_id %s" % (string_id,))
exit(1)
else:
do_create_stream(realm, force_text(stream_name, encoding))
create_stream_if_needed(realm, force_text(stream_name, encoding))

View File

@ -8,7 +8,6 @@ from django.core.management.base import BaseCommand, CommandParser
from django.db import connection
from django.conf import settings
from zerver.lib.actions import do_create_stream
from zerver.models import Realm, Stream, UserProfile, Recipient, Subscription, \
Message, UserMessage, Huddle, DefaultStream, RealmAlias, RealmFilter, Client
from zerver.lib.export import do_import_realm