Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 后台接入通知中心 #1267

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions bin/post_compile
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@ python manage.py createcachetable django_cache

echo "init apigw public key"
python manage.py sync_saas_apigw

echo "register notice center"
python manage.py register_notice
2 changes: 2 additions & 0 deletions config/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
"itsm.trigger",
"itsm.task",
"itsm.openapi",
"itsm.notice",
"data_migration",
# 'silk',
"mptt",
Expand All @@ -107,6 +108,7 @@
"itsm.monitor",
"blueapps.opentelemetry.instrument_app",
"itsm.plugin_service",
"bk_notice_sdk",
)

INSTALLED_APPS = ("itsm.helper",) + INSTALLED_APPS
Expand Down
6 changes: 4 additions & 2 deletions itsm/iadmin/contants.py
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@
${message}"""

GENERAL_CONTENT_DONE = SMS_CONTENT_DONE = WEIXIN_CONTENT_DONE = """您的需求(${title})已经处理完成,现邀请您为我们的服务进行评价。您的反馈对我们非常重要!感谢回复与建议,祝您工作愉快!
${ticket_url}"""
${ticket_url}""" # noqa

GENERAL_CONTENT_FOLLOW = SMS_CONTENT_FOLLOW = WEIXIN_CONTENT_FOLLOW = """你有一条${service_type_name}工单需要关注
标题:${title}
Expand Down Expand Up @@ -554,7 +554,6 @@
[NOTIFY_TITLE_COMMON, SMS_CONTENT_FAILED, NODE_FAILED, GENERAL_NOTICE, "TICKET"],
]


NOTIFY_TEMPLATE = [
# title_template content_template action notify_type used_by
(NOTIFY_TITLE_COMMON, """ ${message}""", SUPERVISE_OPERATE, SMS, "TICKET"),
Expand Down Expand Up @@ -803,6 +802,7 @@
TABLE_FIELDS_SWITCH = "TABLE_FIELDS_SWITCH"
FIRST_STATE_SWITCH = "FIRST_STATE_SWITCH"
SMS_COMMENT_SWITCH = "SMS_COMMENT_SWITCH"
NOTICE_CENTER_SWITCH = "NOTICE_CENTER_SWITCH"

DEFAULT_SETTINGS = [
[SYS_FILE_PATH, "PATH", ""],
Expand All @@ -817,6 +817,8 @@
[TRIGGER_SWITCH, "FUNCTION", SWITCH_ON],
[TASK_SWITCH, "FUNCTION", SWITCH_OFF],
[SMS_COMMENT_SWITCH, "FUNCTION", SWITCH_OFF],
[SMS_COMMENT_SWITCH, "FUNCTION", SWITCH_OFF],
[NOTICE_CENTER_SWITCH, "FUNCTION", SWITCH_OFF],
]

PROJECT_SETTING = [
Expand Down
1 change: 1 addition & 0 deletions itsm/notice/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# -*- coding: utf-8 -*-
19 changes: 19 additions & 0 deletions itsm/notice/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# -*- coding: utf-8 -*-
"""
Tencent is pleased to support the open source community by making 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community
Edition) available.
Copyright (C) 2017 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 django.apps import AppConfig


class NoticeConfig(AppConfig):
name = "itsm.notice"
verbose_name = "Notice"
12 changes: 12 additions & 0 deletions itsm/notice/management/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# -*- coding: utf-8 -*-
"""
Tencent is pleased to support the open source community by making 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community
Edition) available.
Copyright (C) 2017 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.
"""
12 changes: 12 additions & 0 deletions itsm/notice/management/commands/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# -*- coding: utf-8 -*-
"""
Tencent is pleased to support the open source community by making 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community
Edition) available.
Copyright (C) 2017 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.
"""
38 changes: 38 additions & 0 deletions itsm/notice/management/commands/register_notice.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# -*- coding: utf-8 -*-
"""
Tencent is pleased to support the open source community by making 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community
Edition) available.
Copyright (C) 2017 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.
"""
import logging
from django.conf import settings
from django.core.management.base import BaseCommand
from django.core.management import call_command

from itsm.iadmin.contants import NOTICE_CENTER_SWITCH
from itsm.iadmin.models import SystemSettings

logger = logging.getLogger("root")


class Command(BaseCommand):
def handle(self, *args, **kwargs):
# 非PAAS v3 无法开启通知中心
if not settings.IS_PAAS_V3:
print(
"[bk_itsm]current version is not open v3,skip register_bk_itsm_notice"
)
return
try:
call_command("register_application")
SystemSettings.objects.update_or_create(
defaults={"value": "on"}, key=NOTICE_CENTER_SWITCH
)
except Exception as e:
logger.exception("[register_bk_itsm_notice] err: {}".format(e))
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,5 @@ apigw-manager[cryptography]==1.0.7
blueapps[opentelemetry,bkcrypto]==4.8.0

drf-yasg==1.20.0

bk-notice-sdk==1.2.0
1 change: 1 addition & 0 deletions urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
urlpatterns = [
# Django后台数据库管理®
url(r"^admin/", admin.site.urls),
url(r"^notice/", include("bk_notice_sdk.urls")),
# 用户登录鉴权
# url(r'^account/', include('account.urls')),
url(r"^account/", include("blueapps.account.urls")),
Expand Down
Loading