forked from TencentBlueKing/bk-user
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(recycle_bin, categories, audit, period_task, login): 回收站目录项:新增删除… (
TencentBlueKing#962) * feat(recycle_bin, categories, audit, period_task, login): 回收站目录项:新增删除,还原功能 回收站内删除等同对象硬删除(相关资源一并删除),还原为对象恢复正常状态,操作计入审计日志;阻止异常状态目录用户登录; feat TencentBlueKing#901 TencentBlueKing#960
- Loading branch information
Showing
24 changed files
with
534 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# -*- coding: utf-8 -*- | ||
""" | ||
TencentBlueKing is pleased to support the open source community by making 蓝鲸智云-用户管理(Bk-User) available. | ||
Copyright (C) 2017-2021 THL A29 Limited, a Tencent company. All rights reserved. | ||
Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at http://opensource.org/licenses/MIT | ||
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on | ||
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
specific language governing permissions and limitations under the License. | ||
""" | ||
from typing import List | ||
|
||
from django.utils.translation import ugettext_lazy as _ | ||
|
||
from bkuser_core.categories.models import ProfileCategory | ||
from bkuser_core.common.error_codes import error_codes | ||
|
||
|
||
def list_conflict_before_revert_category(category: ProfileCategory) -> List[str]: | ||
""" | ||
在还原目录前,查询display_name和domain冲突 | ||
param category: 即将被还原的目录 | ||
return: 冲突列表 | ||
""" | ||
conflicts: List[str] = [] | ||
|
||
if ProfileCategory.objects.filter(enabled=True, display_name=category.display_name).exists(): | ||
conflicts.append(_("目录名称重复")) | ||
|
||
if ProfileCategory.objects.filter(enabled=True, domain=category.domain).exists(): | ||
conflicts.append(_("目录登录域重复")) | ||
|
||
return conflicts | ||
|
||
|
||
def check_conflict_before_revert_category(category: ProfileCategory): | ||
""" | ||
在还原目录前,检查是否存在冲突,主要是检查display_name和domain | ||
param category: 即将被还原的目录 | ||
return: raise Exception | ||
""" | ||
conflicts = list_conflict_before_revert_category(category) | ||
if conflicts: | ||
raise error_codes.REVERT_CATEGORY_CONFLICT.f(",".join(conflicts), replace=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.