From 422f5c4e1aec58ba4dd61a6f75666b513d0c73cd Mon Sep 17 00:00:00 2001 From: Prakhar Pratyush Date: Mon, 6 May 2024 17:10:27 +0530 Subject: [PATCH] help: Rename unarchive_stream management command to unarchive_channel. --- docs/production/management-commands.md | 4 +- help/archive-a-channel.md | 2 +- ...archive_stream.py => unarchive_channel.py} | 68 +++++++++---------- 3 files changed, 37 insertions(+), 37 deletions(-) rename zerver/management/commands/{unarchive_stream.py => unarchive_channel.py} (50%) diff --git a/docs/production/management-commands.md b/docs/production/management-commands.md index f7259a3994..debcf82116 100644 --- a/docs/production/management-commands.md +++ b/docs/production/management-commands.md @@ -125,9 +125,9 @@ There are dozens of useful management commands under - `./manage.py export_single_user`: does a limited version of the [main export tools](export-and-import.md) containing just the messages accessible by a single user. -- `./manage.py unarchive_stream`: +- `./manage.py unarchive_channel`: [Reactivates](https://zulip.com/help/archive-a-stream#unarchiving-archived-streams) - an archived stream. + an archived channel. - `./manage.py reactivate_realm`: Reactivates a realm. - `./manage.py deactivate_user`: Deactivates a user. This can be done more easily in Zulip's organization administrator UI. diff --git a/help/archive-a-channel.md b/help/archive-a-channel.md index f6231d08bb..75d0743beb 100644 --- a/help/archive-a-channel.md +++ b/help/archive-a-channel.md @@ -44,7 +44,7 @@ than archiving them. ## Unarchiving archived channels If you are self-hosting, you can unarchive an archived channel using the -`unarchive_stream` [management command][management-command]. This will restore +`unarchive_channel` [management command][management-command]. This will restore it as a private channel with shared history, and subscribe all organization owners to it. If you are using Zulip Cloud, you can [contact us](/help/contact-support) for help. diff --git a/zerver/management/commands/unarchive_stream.py b/zerver/management/commands/unarchive_channel.py similarity index 50% rename from zerver/management/commands/unarchive_stream.py rename to zerver/management/commands/unarchive_channel.py index 0a553c3fe8..6a10a0807c 100644 --- a/zerver/management/commands/unarchive_stream.py +++ b/zerver/management/commands/unarchive_channel.py @@ -10,19 +10,19 @@ from zerver.models import RealmAuditLog, Stream class Command(ZulipBaseCommand): - help = """Reactivate a stream that was deactivated.""" + help = """Reactivate a channel that was deactivated.""" @override def add_arguments(self, parser: ArgumentParser) -> None: - specify_stream = parser.add_mutually_exclusive_group(required=True) - specify_stream.add_argument( - "-s", - "--stream", - help="Name of a deactivated stream in the realm.", + specify_channel = parser.add_mutually_exclusive_group(required=True) + specify_channel.add_argument( + "-c", + "--channel", + help="Name of a deactivated channel in the realm.", ) - specify_stream.add_argument( - "--stream-id", - help="ID of a deactivated stream in the realm.", + specify_channel.add_argument( + "--channel-id", + help="ID of a deactivated channel in the realm.", ) parser.add_argument( "-n", @@ -37,39 +37,39 @@ class Command(ZulipBaseCommand): realm = self.get_realm(options) assert realm is not None # Should be ensured by parser - # Looking up the stream is complicated, since they get renamed + # Looking up the channel is complicated, since they get renamed # when they are deactivated, in a transformation which may be # lossy. - if options["stream_id"] is not None: - stream = Stream.objects.get(id=options["stream_id"]) - if stream.realm_id != realm.id: + if options["channel_id"] is not None: + channel = Stream.objects.get(id=options["channel_id"]) + if channel.realm_id != realm.id: raise CommandError( - f"Stream id {stream.id}, named '{stream.name}', is in realm '{stream.realm.string_id}', not '{realm.string_id}'" + f"Channel id {channel.id}, named '{channel.name}', is in realm '{channel.realm.string_id}', not '{realm.string_id}'" ) - if not stream.deactivated: + if not channel.deactivated: raise CommandError( - f"Stream id {stream.id}, named '{stream.name}', is not deactivated" + f"Channel id {channel.id}, named '{channel.name}', is not deactivated" ) if options["new_name"] is None: - raise CommandError("--new-name flag is required with --stream-id") + raise CommandError("--new-name flag is required with --channel-id") new_name = options["new_name"] else: - stream_name = options["stream"] - assert stream_name is not None + channel_name = options["channel"] + assert channel_name is not None - possible_streams = deactivated_streams_by_old_name(realm, stream_name) - if len(possible_streams) == 0: - raise CommandError("No matching deactivated streams found!") + possible_channels = deactivated_streams_by_old_name(realm, channel_name) + if len(possible_channels) == 0: + raise CommandError("No matching deactivated channels found!") - if len(possible_streams) > 1: - # Print ids of all possible streams, support passing by id - print("Matching streams:") - for stream in possible_streams: + if len(possible_channels) > 1: + # Print ids of all possible channels, support passing by id + print("Matching channels:") + for channel in possible_channels: last_deactivation = ( RealmAuditLog.objects.filter( realm=realm, - modified_stream=stream, + modified_stream=channel, event_type=RealmAuditLog.STREAM_DEACTIVATED, ) .order_by("-id") @@ -77,22 +77,22 @@ class Command(ZulipBaseCommand): ) assert last_deactivation is not None print( - f" ({stream.id}) {stream.name}, deactivated on {last_deactivation.event_time}" + f" ({channel.id}) {channel.name}, deactivated on {last_deactivation.event_time}" ) raise CommandError( - "More than one matching stream found! Specify which with --stream-id" + "More than one matching channel found! Specify which with --channel-id" ) - stream = possible_streams[0] + channel = possible_channels[0] if options["new_name"] is not None: new_name = options["new_name"] else: - new_name = stream_name + new_name = channel_name if Stream.objects.filter(realm=realm, name=new_name).exists(): raise CommandError( - f"Stream with name '{new_name}' already exists; pass a different --new-name" + f"Channel with name '{new_name}' already exists; pass a different --new-name" ) - assert stream is not None - do_unarchive_stream(stream, new_name, acting_user=None) + assert channel is not None + do_unarchive_stream(channel, new_name, acting_user=None)