mirror of https://github.com/zulip/zulip.git
parent
638eb7a8e4
commit
8c4651d716
|
@ -2948,14 +2948,16 @@ def do_create_default_stream_group(realm: Realm, group_name: Text,
|
||||||
default_streams = get_default_streams_for_realm(realm.id)
|
default_streams = get_default_streams_for_realm(realm.id)
|
||||||
for stream in streams:
|
for stream in streams:
|
||||||
if stream in default_streams:
|
if stream in default_streams:
|
||||||
raise JsonableError(_("'%s' is a default stream and cannot be added to '%s'") % (
|
raise JsonableError(_(
|
||||||
stream.name, group_name))
|
"'%(stream_name)s' is a default stream and cannot be added to '%(group_name)s'")
|
||||||
|
% {'stream_name': stream.name, 'group_name': group_name})
|
||||||
|
|
||||||
check_default_stream_group_name(group_name)
|
check_default_stream_group_name(group_name)
|
||||||
(group, created) = DefaultStreamGroup.objects.get_or_create(
|
(group, created) = DefaultStreamGroup.objects.get_or_create(
|
||||||
name=group_name, realm=realm, description=description)
|
name=group_name, realm=realm, description=description)
|
||||||
if not created:
|
if not created:
|
||||||
raise JsonableError(_("Default stream group '%s' already exists") % (group_name,))
|
raise JsonableError(_("Default stream group '%(group_name)s' already exists")
|
||||||
|
% {'group_name': group_name})
|
||||||
|
|
||||||
group.streams = streams
|
group.streams = streams
|
||||||
group.save()
|
group.save()
|
||||||
|
@ -2966,11 +2968,13 @@ def do_add_streams_to_default_stream_group(realm: Realm, group: DefaultStreamGro
|
||||||
default_streams = get_default_streams_for_realm(realm.id)
|
default_streams = get_default_streams_for_realm(realm.id)
|
||||||
for stream in streams:
|
for stream in streams:
|
||||||
if stream in default_streams:
|
if stream in default_streams:
|
||||||
raise JsonableError(_("'%s' is a default stream and cannot be added to '%s'") % (
|
raise JsonableError(_(
|
||||||
stream.name, group.name))
|
"'%(stream_name)s' is a default stream and cannot be added to '%(group.name)s'")
|
||||||
|
% {'stream_name': stream.name, 'group.name': group.name})
|
||||||
if stream in group.streams.all():
|
if stream in group.streams.all():
|
||||||
raise JsonableError(_("Stream '%s' is already present in default stream group '%s'")
|
raise JsonableError(_(
|
||||||
% (stream.name, group.name))
|
"Stream '%(stream_name)s' is already present in default stream group '%(group.name)s'")
|
||||||
|
% {'stream_name': stream.name, 'group.name': group.name})
|
||||||
group.streams.add(stream)
|
group.streams.add(stream)
|
||||||
|
|
||||||
group.save()
|
group.save()
|
||||||
|
@ -2980,8 +2984,9 @@ def do_remove_streams_from_default_stream_group(realm: Realm, group: DefaultStre
|
||||||
streams: List[Stream]) -> None:
|
streams: List[Stream]) -> None:
|
||||||
for stream in streams:
|
for stream in streams:
|
||||||
if stream not in group.streams.all():
|
if stream not in group.streams.all():
|
||||||
raise JsonableError(_("Stream '%s' is not present in default stream group '%s'")
|
raise JsonableError(_(
|
||||||
% (stream.name, group.name))
|
"Stream '%(stream_name)s' is not present in default stream group '%(group.name)s'")
|
||||||
|
% {'stream_name': stream.name, 'group.name': group.name})
|
||||||
group.streams.remove(stream)
|
group.streams.remove(stream)
|
||||||
|
|
||||||
group.save()
|
group.save()
|
||||||
|
|
Loading…
Reference in New Issue