mirror of https://github.com/zulip/zulip.git
management: Rename command reactivate_stream -> unarchive_stream.
This commit is contained in:
parent
696287b0eb
commit
cb123d4f15
|
@ -158,7 +158,7 @@ def deactivated_streams_by_old_name(realm: Realm, stream_name: str) -> QuerySet[
|
||||||
|
|
||||||
|
|
||||||
@transaction.atomic(savepoint=False)
|
@transaction.atomic(savepoint=False)
|
||||||
def do_reactivate_stream(
|
def do_unarchive_stream(
|
||||||
stream: Stream, new_name: str, *, acting_user: Optional[UserProfile]
|
stream: Stream, new_name: str, *, acting_user: Optional[UserProfile]
|
||||||
) -> None:
|
) -> None:
|
||||||
realm = stream.realm
|
realm = stream.realm
|
||||||
|
|
|
@ -3,7 +3,7 @@ from typing import Any, Optional
|
||||||
|
|
||||||
from django.core.management.base import CommandError
|
from django.core.management.base import CommandError
|
||||||
|
|
||||||
from zerver.actions.streams import deactivated_streams_by_old_name, do_reactivate_stream
|
from zerver.actions.streams import deactivated_streams_by_old_name, do_unarchive_stream
|
||||||
from zerver.lib.management import ZulipBaseCommand
|
from zerver.lib.management import ZulipBaseCommand
|
||||||
from zerver.models import RealmAuditLog, Stream
|
from zerver.models import RealmAuditLog, Stream
|
||||||
|
|
||||||
|
@ -88,4 +88,4 @@ class Command(ZulipBaseCommand):
|
||||||
)
|
)
|
||||||
|
|
||||||
assert stream is not None
|
assert stream is not None
|
||||||
do_reactivate_stream(stream, new_name, acting_user=None)
|
do_unarchive_stream(stream, new_name, acting_user=None)
|
|
@ -32,7 +32,7 @@ from zerver.actions.streams import (
|
||||||
do_change_stream_group_based_setting,
|
do_change_stream_group_based_setting,
|
||||||
do_change_stream_post_policy,
|
do_change_stream_post_policy,
|
||||||
do_deactivate_stream,
|
do_deactivate_stream,
|
||||||
do_reactivate_stream,
|
do_unarchive_stream,
|
||||||
)
|
)
|
||||||
from zerver.actions.user_groups import add_subgroups_to_user_group, check_add_user_group
|
from zerver.actions.user_groups import add_subgroups_to_user_group, check_add_user_group
|
||||||
from zerver.actions.users import do_change_user_role, do_deactivate_user
|
from zerver.actions.users import do_change_user_role, do_deactivate_user
|
||||||
|
@ -1444,19 +1444,19 @@ class StreamAdminTest(ZulipTestCase):
|
||||||
old_style.save()
|
old_style.save()
|
||||||
self.assertEqual(set(deactivated_streams_by_old_name(realm, "old_style")), {old_style})
|
self.assertEqual(set(deactivated_streams_by_old_name(realm, "old_style")), {old_style})
|
||||||
|
|
||||||
def test_reactivate_stream_active_stream(self) -> None:
|
def test_unarchive_stream_active_stream(self) -> None:
|
||||||
stream = self.make_stream("new_stream")
|
stream = self.make_stream("new_stream")
|
||||||
with self.assertRaisesRegex(JsonableError, "Stream is not currently deactivated"):
|
with self.assertRaisesRegex(JsonableError, "Stream is not currently deactivated"):
|
||||||
do_reactivate_stream(stream, new_name="new_stream", acting_user=None)
|
do_unarchive_stream(stream, new_name="new_stream", acting_user=None)
|
||||||
|
|
||||||
def test_reactivate_stream_existing_name(self) -> None:
|
def test_unarchive_stream_existing_name(self) -> None:
|
||||||
stream = self.make_stream("new_stream")
|
stream = self.make_stream("new_stream")
|
||||||
self.make_stream("existing")
|
self.make_stream("existing")
|
||||||
do_deactivate_stream(stream, acting_user=None)
|
do_deactivate_stream(stream, acting_user=None)
|
||||||
with self.assertRaisesRegex(JsonableError, "Stream named existing already exists"):
|
with self.assertRaisesRegex(JsonableError, "Stream named existing already exists"):
|
||||||
do_reactivate_stream(stream, new_name="existing", acting_user=None)
|
do_unarchive_stream(stream, new_name="existing", acting_user=None)
|
||||||
|
|
||||||
def test_reactivate_stream(self) -> None:
|
def test_unarchive_stream(self) -> None:
|
||||||
desdemona = self.example_user("desdemona")
|
desdemona = self.example_user("desdemona")
|
||||||
iago = self.example_user("iago")
|
iago = self.example_user("iago")
|
||||||
hamlet = self.example_user("hamlet")
|
hamlet = self.example_user("hamlet")
|
||||||
|
@ -1467,7 +1467,7 @@ class StreamAdminTest(ZulipTestCase):
|
||||||
self.subscribe(cordelia, stream.name)
|
self.subscribe(cordelia, stream.name)
|
||||||
do_deactivate_stream(stream, acting_user=None)
|
do_deactivate_stream(stream, acting_user=None)
|
||||||
with self.capture_send_event_calls(expected_num_events=4) as events:
|
with self.capture_send_event_calls(expected_num_events=4) as events:
|
||||||
do_reactivate_stream(stream, new_name="new_stream", acting_user=None)
|
do_unarchive_stream(stream, new_name="new_stream", acting_user=None)
|
||||||
|
|
||||||
# Tell all admins and owners that the stream exists
|
# Tell all admins and owners that the stream exists
|
||||||
self.assertEqual(events[0]["event"]["op"], "create")
|
self.assertEqual(events[0]["event"]["op"], "create")
|
||||||
|
|
Loading…
Reference in New Issue