mirror of
https://github.com/zulip/zulip.git
synced 2025-11-02 13:03:29 +00:00
folders: Don't allow archiving a folder if it contains channels.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
from typing import Annotated
|
||||
|
||||
from django.http import HttpRequest, HttpResponse
|
||||
from django.utils.translation import gettext as _
|
||||
from pydantic import Json, StringConstraints
|
||||
|
||||
from zerver.actions.channel_folders import (
|
||||
@@ -12,10 +13,12 @@ from zerver.actions.channel_folders import (
|
||||
)
|
||||
from zerver.decorator import require_realm_admin
|
||||
from zerver.lib.channel_folders import (
|
||||
check_channel_folder_in_use,
|
||||
check_channel_folder_name,
|
||||
get_channel_folder_by_id,
|
||||
get_channel_folders_in_realm,
|
||||
)
|
||||
from zerver.lib.exceptions import JsonableError
|
||||
from zerver.lib.response import json_success
|
||||
from zerver.lib.typed_endpoint import PathOnly, typed_endpoint
|
||||
from zerver.models.channel_folders import ChannelFolder
|
||||
@@ -71,6 +74,11 @@ def update_channel_folder(
|
||||
|
||||
if is_archived is not None and channel_folder.is_archived != is_archived:
|
||||
if is_archived:
|
||||
if check_channel_folder_in_use(channel_folder):
|
||||
raise JsonableError(
|
||||
_("You need to remove all the channels from this folder to archive it.")
|
||||
)
|
||||
|
||||
do_archive_channel_folder(channel_folder, acting_user=user_profile)
|
||||
else:
|
||||
do_unarchive_channel_folder(channel_folder, acting_user=user_profile)
|
||||
|
||||
Reference in New Issue
Block a user