Skip to content

Commit

Permalink
feat: 支持获取 footer 信息 #7495
Browse files Browse the repository at this point in the history
  • Loading branch information
normal-wls committed Jun 18, 2024
1 parent 89aafea commit 2072d23
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 14 deletions.
2 changes: 2 additions & 0 deletions env.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@
# 获取 PaaS 注入的蓝鲸域名
BKPAAS_BK_DOMAIN = os.getenv("BKPAAS_BK_DOMAIN", "") or os.getenv("BK_DOMAIN", "")

# PaaS 注入的蓝鲸共享资源域名
BKPAAS_SHARED_RES_URL = os.getenv("BKPAAS_SHARED_RES_URL", "")

# 获取加密类型
BKPAAS_BK_CRYPTO_TYPE = (
Expand Down
39 changes: 27 additions & 12 deletions gcloud/core/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,23 @@
import re
from datetime import datetime

from django.http import JsonResponse
from blueapps.account.decorators import login_exempt
from django.contrib.auth.models import Group
from django.views.decorators.http import require_POST, require_GET
from django.http import JsonResponse
from django.utils.translation import ugettext_lazy as _
from django.views.decorators.http import require_GET, require_POST
from drf_yasg.utils import swagger_auto_schema

from mako.template import Template
from rest_framework.decorators import api_view

from blueapps.account.decorators import login_exempt
from gcloud.core import roles
import env
from gcloud.conf import settings
from gcloud.core.footer import FOOTER
from gcloud.constants import TASK_CATEGORY, TASK_FLOW_TYPE, NOTIFY_TYPE
from gcloud.core.models import (
UserDefaultProject,
ProjectCounter,
)
from gcloud.core.utils import convert_group_name
from gcloud.constants import NOTIFY_TYPE, TASK_CATEGORY, TASK_FLOW_TYPE
from gcloud.core import roles
from gcloud.core.api_adapter import get_all_users
from gcloud.core.footer import FOOTER, FOOTER_INFO
from gcloud.core.models import ProjectCounter, UserDefaultProject
from gcloud.core.utils import convert_group_name
from gcloud.openapi.schema import AnnotationAutoSchema

logger = logging.getLogger("root")
Expand Down Expand Up @@ -141,6 +138,24 @@ def get_footer(request):
)


@require_GET
def get_footer_info(request):
"""
@summary: 获取当前环境的页面 footer 信息
"""
return JsonResponse(
{
"result": True,
"data": {
"env": env.RUN_VER,
"sops_version": settings.STATIC_VERSION,
"year": datetime.now().year,
**FOOTER_INFO,
},
}
)


@require_GET
def get_msg_types(request):
client = get_client_by_user(request.user.username)
Expand Down
1 change: 1 addition & 0 deletions gcloud/core/context_processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ def mysetting(request):
"BK_DOMAIN": env.BKPAAS_BK_DOMAIN,
# 是否开启通知中心
"ENABLE_NOTICE_CENTER": enable_notice_center,
"BK_PAAS_SHARED_RES_URL": env.BKPAAS_SHARED_RES_URL,
"TASK_LIST_STATUS_FILTER_DAYS": settings.TASK_LIST_STATUS_FILTER_DAYS,
}

Expand Down
2 changes: 2 additions & 0 deletions gcloud/core/footer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,5 @@
footer_module = importlib.import_module("gcloud.core.footer.sites.{}.footer".format(settings.RUN_VER))

FOOTER = footer_module.FOOTER # noqa

FOOTER_INFO = footer_module.FOOTER_INFO # noqa
6 changes: 6 additions & 0 deletions gcloud/core/footer/sites/open/footer.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,10 @@ def i18n_footer(language):
return EnvironmentVariables.objects.get_var(footer_key, default)


FOOTER_INFO = {
"tech_support_url": "https://wpa1.qq.com/KziXGWJs?_type=wpa&qidian=true",
"smart_url": "http://bk.tencent.com/s-mart/community/",
"bk_tencent_url": "http://bk.tencent.com/index",
}

FOOTER = i18n_footer
5 changes: 3 additions & 2 deletions gcloud/core/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@
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 blueapps.account.decorators import login_exempt
from django.apps import apps
from django.conf.urls import include, url
from django.views.i18n import JavaScriptCatalog
from version_log import config as version_log_config

from blueapps.account.decorators import login_exempt
from gcloud.core import api, views
from gcloud.iam_auth.resource_api import dispatcher
from version_log import config as version_log_config

javascript_catalog = JavaScriptCatalog.as_view(
packages=[app_config.name for app_config in apps.get_app_configs() if app_config.name.startswith("gcloud")]
Expand All @@ -31,6 +31,7 @@
url(r"^core/api/get_roles_and_personnel/(?P<biz_cc_id>\d+)/$", api.get_roles_and_personnel),
url(r"^core/api/get_basic_info/$", api.get_basic_info),
url(r"^core/footer/$", api.get_footer),
url(r"^core/footer_info/$", api.get_footer_info),
url(r"^core/api/get_user_list/$", api.get_user_list),
url(r"^core/api/get_msg_types/$", api.get_msg_types),
url(r"^core/healthz", api.healthz),
Expand Down

0 comments on commit 2072d23

Please sign in to comment.