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: 通知中心代码迁移 #7309 #7310

Merged
Merged
Show file tree
Hide file tree
Changes from 2 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: 2 additions & 1 deletion bin/pre_release
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ python manage.py migrate
python manage.py createcachetable django_cache
python manage.py update_component_models
python manage.py update_variable_models
python manage.py sync_saas_apigw
python manage.py sync_saas_apigw
python manage.py register_bksops_notice
2 changes: 2 additions & 0 deletions config/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
"gcloud.contrib.appmaker",
"gcloud.contrib.function",
"gcloud.contrib.audit",
"gcloud.contrib.notice",
"gcloud.contrib.develop",
"gcloud.contrib.collection",
"gcloud.contrib.operate_record",
Expand Down Expand Up @@ -113,6 +114,7 @@
"django_dbconn_retry",
"blueapps.opentelemetry.instrument_app",
"apigw_manager.apigw",
"bk_notice_sdk"
)

# 这里是默认的中间件,大部分情况下,不需要改动
Expand Down
12 changes: 12 additions & 0 deletions gcloud/contrib/notice/__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.
"""
19 changes: 19 additions & 0 deletions gcloud/contrib/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 = "gcloud.contrib.notice"
verbose_name = "Notice"
12 changes: 12 additions & 0 deletions gcloud/contrib/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 gcloud/contrib/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.
"""
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# -*- 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.core.management import call_command
from django.core.management.base import BaseCommand

import env
from gcloud.core.models import EnvironmentVariables

logger = logging.getLogger("root")


class Command(BaseCommand):
def handle(self, *args, **kwargs):
# 非PAAS v3 无法开启通知中心
if not env.IS_PAAS_V3:
EnvironmentVariables.objects.update_or_create(
defaults={"value": 0}, key="ENABLE_NOTICE_CENTER"
)
print("[bk-sops]current version is not open v3,skip register_bksops_notice")
return
try:
call_command("register_application")
EnvironmentVariables.objects.update_or_create(
defaults={"value": 1}, key="ENABLE_NOTICE_CENTER"
)
except Exception as e:
logger.exception("[register_bksops_notice] err: {}".format(e))
EnvironmentVariables.objects.update_or_create(
defaults={"value": 0}, key="ENABLE_NOTICE_CENTER"
)
7 changes: 7 additions & 0 deletions gcloud/core/context_processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ def mysetting(request):
default_asymmetric_key_config: AsymmetricKeyConfig = get_default_asymmetric_key_config(
settings.BKCRYPTO_ASYMMETRIC_CIPHER_TYPE
)
try:
enable_notice_center = int(EnvironmentVariables.objects.get_var("ENABLE_NOTICE_CENTER", 0))
except Exception:
enable_notice_center = 0

ctx = {
"MEDIA_URL": settings.MEDIA_URL, # MEDIA_URL
"STATIC_URL": settings.STATIC_URL, # 本地静态文件访问
Expand Down Expand Up @@ -118,6 +123,8 @@ def mysetting(request):
"BK_PLUGIN_DEVELOP_URL": settings.BK_PLUGIN_DEVELOP_URL,
"ENABLE_IPV6": settings.ENABLE_IPV6,
"BK_DOMAIN": env.BKPAAS_BK_DOMAIN,
# 是否开启通知中心
"ENABLE_NOTICE_CENTER": enable_notice_center,
"TASK_LIST_STATUS_FILTER_DAYS": settings.TASK_LIST_STATUS_FILTER_DAYS,
"MESSAGE_HELPER_URL": settings.MESSAGE_HELPER_URL,
}
Expand Down
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,5 @@ opentelemetry-instrumentation-dbapi==0.30b1
opentelemetry-instrumentation-redis==0.30b1
opentelemetry-instrumentation-logging==0.30b1
opentelemetry-instrumentation-requests==0.30b1

bk-notice-sdk==1.2.0
3 changes: 2 additions & 1 deletion urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,15 @@
from django.conf import settings
from django.conf.urls import include, url
from django.contrib import admin
from django.views import static

from config.urls_custom import urlpatterns_custom
from gcloud.core.views import page_not_found
from django.views import static

urlpatterns = [
url(r"^django_admin/", admin.site.urls),
url(r"^account/", include("blueapps.account.urls")),
url(r"^notice/", include("bk_notice_sdk.urls")),
]

# app自定义路径
Expand Down
Loading