mirror of https://github.com/zulip/zulip.git
Move get_stream to models.py and accept an id for the realm argument.
(imported from commit 7ce09b7ed450cfa3ddf1de22bbb0b19abfc4a2a2)
This commit is contained in:
parent
b6345e6c3d
commit
8cb8c0065c
|
@ -159,6 +159,17 @@ def get_client(name):
|
|||
return Client.objects.get(name=name)
|
||||
return client
|
||||
|
||||
# get_stream takes either a realm id or a realm
|
||||
def get_stream(stream_name, realm):
|
||||
if isinstance(realm, Realm):
|
||||
realm_id = realm.id
|
||||
else:
|
||||
realm_id = realm
|
||||
try:
|
||||
return Stream.objects.get(name__iexact=stream_name, realm_id=realm_id)
|
||||
except Stream.DoesNotExist:
|
||||
return None
|
||||
|
||||
def linebreak(string):
|
||||
return string.replace('\n\n', '<p/>').replace('\n', '<br/>')
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ from django.core.mail import send_mail
|
|||
from zephyr.models import Message, UserProfile, Stream, Subscription, \
|
||||
Recipient, get_display_recipient, get_huddle, Realm, UserMessage, \
|
||||
StreamColor, PreregistrationUser, get_client, MitUser, User, UserActivity, \
|
||||
MAX_SUBJECT_LENGTH, MAX_MESSAGE_LENGTH
|
||||
MAX_SUBJECT_LENGTH, MAX_MESSAGE_LENGTH, get_stream
|
||||
from zephyr.lib.actions import do_add_subscription, do_remove_subscription, \
|
||||
do_change_password, create_mit_user_if_needed, \
|
||||
do_change_full_name, do_change_enable_desktop_notifications, \
|
||||
|
@ -48,12 +48,6 @@ import base64
|
|||
|
||||
SERVER_GENERATION = int(time.time())
|
||||
|
||||
def get_stream(stream_name, realm):
|
||||
try:
|
||||
return Stream.objects.get(name__iexact=stream_name, realm=realm)
|
||||
except Stream.DoesNotExist:
|
||||
return None
|
||||
|
||||
def send_signup_message(sender, signups_stream, user_profile, internal=False):
|
||||
if internal:
|
||||
# When this is done using manage.py vs. the web interface
|
||||
|
|
Loading…
Reference in New Issue