Skip to content

Commit

Permalink
fix: django4.2替换url()为path()、re_patch() TencentBlueKing#1464
Browse files Browse the repository at this point in the history
  • Loading branch information
huangpixu committed Jan 3, 2025
1 parent 0a43bd2 commit ce6f1a6
Show file tree
Hide file tree
Showing 18 changed files with 155 additions and 140 deletions.
34 changes: 17 additions & 17 deletions itsm/api/v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"""


from django.conf.urls import include, url
from django.urls import include, re_path


__author__ = "蓝鲸智云"
Expand All @@ -38,35 +38,35 @@

urlpatterns = [
# 流程管理模块
url(r"^workflow/", include("itsm.workflow.urls")),
re_path(r"^workflow/", include("itsm.workflow.urls")),
# 单据模块
url(r"^ticket/", include("itsm.ticket.urls")),
re_path(r"^ticket/", include("itsm.ticket.urls")),
# 任务模块
url(r"^task/", include("itsm.task.urls")),
re_path(r"^task/", include("itsm.task.urls")),
# 服务模块
url(r"^service/", include("itsm.service.urls")),
re_path(r"^service/", include("itsm.service.urls")),
# sla模块
url(r"^sla/", include("itsm.sla.urls")),
re_path(r"^sla/", include("itsm.sla.urls")),
# postman
url(r"^postman/", include("itsm.postman.urls")),
re_path(r"^postman/", include("itsm.postman.urls")),
# 角色模块
url(r"^role/", include("itsm.role.urls")),
re_path(r"^role/", include("itsm.role.urls")),
# iadmin
url(r"^iadmin/", include("itsm.iadmin.urls")),
re_path(r"^iadmin/", include("itsm.iadmin.urls")),
# 网关转发模块,目前主要用于转发esb侧的接口调用
url(r"^gateway/", include("itsm.gateway.urls")),
re_path(r"^gateway/", include("itsm.gateway.urls")),
# "杂种"模块,没有model,且不知道放哪里合适,就放到这个模块吧!
url(r"^misc/", include("itsm.misc.urls")),
re_path(r"^misc/", include("itsm.misc.urls")),
# 单据状态模块
url(r"^ticket_status/", include("itsm.ticket_status.urls")),
re_path(r"^ticket_status/", include("itsm.ticket_status.urls")),
# Trigger Module
url(r"^trigger/", include("itsm.trigger.urls")),
re_path(r"^trigger/", include("itsm.trigger.urls")),
# iam
url(r"^iam/", include("itsm.auth_iam.urls")),
re_path(r"^iam/", include("itsm.auth_iam.urls")),
# iam
url(r"^project/", include("itsm.project.urls")),
re_path(r"^project/", include("itsm.project.urls")),
# 人员选择器
url(r"^c/compapi/v2/usermanage/fs_list_users/$", get_batch_users),
re_path(r"^c/compapi/v2/usermanage/fs_list_users/$", get_batch_users),
# 蓝鲸插件服务
url(r"^plugin_service/", include("itsm.plugin_service.urls")),
re_path(r"^plugin_service/", include("itsm.plugin_service.urls")),
]
11 changes: 8 additions & 3 deletions itsm/auth_iam/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"""

from django.conf import settings
from django.conf.urls import url
from django.urls import re_path
from rest_framework.routers import DefaultRouter

from iam import IAM
Expand All @@ -46,7 +46,12 @@
from itsm.auth_iam.views import ResourceViewSet, PermissionViewSet
from itsm.auth_iam.resources import ProjectResourceProvider

iam = IAM(settings.APP_CODE, settings.SECRET_KEY, settings.BK_IAM_INNER_HOST, settings.BK_PAAS_HOST)
iam = IAM(
settings.APP_CODE,
settings.SECRET_KEY,
settings.BK_IAM_INNER_HOST,
settings.BK_PAAS_HOST,
)

routers = DefaultRouter(trailing_slash=True)

Expand All @@ -70,5 +75,5 @@
dispatcher.register("task_template", TaskSchemaResourceProvider())
dispatcher.register("public_api", PublicApiResourceProvider())
urlpatterns = routers.urls + [
url(r'^resources/v1/$', dispatcher.as_view([login_exempt])),
re_path(r"^resources/v1/$", dispatcher.as_view([login_exempt])),
]
62 changes: 32 additions & 30 deletions itsm/gateway/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,56 +26,58 @@
__author__ = "蓝鲸智云"
__copyright__ = "Copyright © 2012-2020 Tencent BlueKing. All Rights Reserved."

from django.conf.urls import url
from django.urls import re_path

from itsm.gateway import views

urlpatterns = [
url(r"^test/token/$", views.get_token),
url(r"^bk_login/get_batch_users/$", views.get_batch_users),
url(r"^bk_login/get_all_users/$", views.get_all_users),
url(r"^cmdb/get_app_list/$", views.get_app_list),
url(r"^usermanage/get_departments/$", views.get_departments),
url(
re_path(r"^test/token/$", views.get_token),
re_path(r"^bk_login/get_batch_users/$", views.get_batch_users),
re_path(r"^bk_login/get_all_users/$", views.get_all_users),
re_path(r"^cmdb/get_app_list/$", views.get_app_list),
re_path(r"^usermanage/get_departments/$", views.get_departments),
re_path(
r"^usermanage/get_first_level_departments/$", views.get_first_level_departments
),
url(r"^usermanage/get_department_info/$", views.get_department_info),
url(r"^usermanage/get_department_users/$", views.get_department_users),
url(r"^usermanage/get_department_users_count/$", views.get_department_users_count),
url(r"^usermanage/get_user_info/$", views.get_user_info),
url(r"^sops/get_user_project_list/$", views.get_user_project_list),
url(r"^sops/get_template_list/$", views.get_template_list),
url(r"^sops/get_template_detail/$", views.get_template_detail),
url(r"^sops/get_unfinished_sops_tasks/$", views.get_unfinished_sops_tasks),
url(r"^sops/get_sops_tasks/$", views.get_sops_tasks),
url(r"^sops/get_sops_tasks_detail/$", views.get_sops_tasks_detail),
url(r"^sops/get_sops_template_schemes/$", views.get_sops_template_schemes),
url(r"^sops/get_sops_preview_task_tree/$", views.get_sops_preview_task_tree),
url(
re_path(r"^usermanage/get_department_info/$", views.get_department_info),
re_path(r"^usermanage/get_department_users/$", views.get_department_users),
re_path(
r"^usermanage/get_department_users_count/$", views.get_department_users_count
),
re_path(r"^usermanage/get_user_info/$", views.get_user_info),
re_path(r"^sops/get_user_project_list/$", views.get_user_project_list),
re_path(r"^sops/get_template_list/$", views.get_template_list),
re_path(r"^sops/get_template_detail/$", views.get_template_detail),
re_path(r"^sops/get_unfinished_sops_tasks/$", views.get_unfinished_sops_tasks),
re_path(r"^sops/get_sops_tasks/$", views.get_sops_tasks),
re_path(r"^sops/get_sops_tasks_detail/$", views.get_sops_tasks_detail),
re_path(r"^sops/get_sops_template_schemes/$", views.get_sops_template_schemes),
re_path(r"^sops/get_sops_preview_task_tree/$", views.get_sops_preview_task_tree),
re_path(
r"^sops/get_sops_preview_common_task_tree/$",
views.get_sops_preview_common_task_tree,
),
url(r"^devops/get_user_pipeline_list/$", views.get_user_pipeline_list),
url(r"^devops/get_user_projects/$", views.get_user_projects),
url(
re_path(r"^devops/get_user_pipeline_list/$", views.get_user_pipeline_list),
re_path(r"^devops/get_user_projects/$", views.get_user_projects),
re_path(
r"^devops/get_pipeline_build_start_info/$", views.get_pipeline_build_start_info
),
url(r"^devops/get_user_pipeline_detail/$", views.get_user_pipeline_detail),
url(r"^devops/get_pipeline_build_list/$", views.get_pipeline_build_list),
url(r"^devops/start_user_pipeline/$", views.start_user_pipeline),
url(
re_path(r"^devops/get_user_pipeline_detail/$", views.get_user_pipeline_detail),
re_path(r"^devops/get_pipeline_build_list/$", views.get_pipeline_build_list),
re_path(r"^devops/start_user_pipeline/$", views.start_user_pipeline),
re_path(
r"^devops/get_user_pipeline_build_status/$",
views.get_user_pipeline_build_status,
),
url(
re_path(
r"^devops/get_user_pipeline_build_detail/$",
views.get_user_pipeline_build_detail,
),
url(
re_path(
r"^devops/get_pipeline_build_artifactory/$",
views.get_pipeline_build_artifactory,
),
url(
re_path(
r"^devops/get_pipeline_build_artifactory_download_url/$",
views.get_pipeline_build_artifactory_download_url,
),
Expand Down
56 changes: 31 additions & 25 deletions itsm/helper/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,39 +26,45 @@
__author__ = "蓝鲸智云"
__copyright__ = "Copyright © 2012-2020 Tencent BlueKing. All Rights Reserved."

from django.conf.urls import url
from django.urls import re_path

from itsm.helper import views

urlpatterns = [
# 统一的升级接口
url(r'^db_fix_from_1_1_22_to_2_1_16/$', views.db_fix_from_1_1_22_to_2_1_16),
url(r'^db_fix_from_2_1_x_to_2_2_1/$', views.db_fix_from_2_1_x_to_2_2_1),
url(r'^db_fix_after_2_2_17/$', views.db_fix_after_2_2_17),
url(r'^db_fix_after_2_3_1/$', views.db_fix_after_2_3_1),
re_path(r"^db_fix_from_1_1_22_to_2_1_16/$", views.db_fix_from_1_1_22_to_2_1_16),
re_path(r"^db_fix_from_2_1_x_to_2_2_1/$", views.db_fix_from_2_1_x_to_2_2_1),
re_path(r"^db_fix_after_2_2_17/$", views.db_fix_after_2_2_17),
re_path(r"^db_fix_after_2_3_1/$", views.db_fix_after_2_3_1),
# 杂乱的升级接口
url(r'^fix_ticket_title/$', views.fix_ticket_title),
url(r'^update_logs_type/$', views.update_logs_type),
url(r'^db_fix_after_2_0_3/$', views.db_fix_after_2_0_3),
url(r'^db_fix_ticket_end_at_after_2_0_5/$', views.db_fix_ticket_end_at_after_2_0_5),
url(r'^db_fix_deal_time_after_2_0_5/$', views.db_fix_deal_time_after_2_0_5),
url(r'^db_fix_after_2_0_7/$', views.db_fix_after_2_0_7),
url(r'^db_fix_after_2_0_9/$', views.db_fix_after_2_0_9),
url(r'^db_fix_after_2_0_14/$', views.db_fix_after_2_0_14),
url(r'^db_fix_after_2_1_x/$', views.db_fix_after_2_1_x),
url(r'^db_fix_after_2_1_1/$', views.db_fix_after_2_1_1),
url(r'^db_fix_sla/$', views.db_fix_sla),
url(r'^db_fix_after_2_1_9/$', views.db_fix_after_2_1_9),
url(r'^export_api_system/$', views.export_api_system),
url(r'^db_fix_for_attachments/$', views.db_fix_for_attachments),
url(r'^db_fix_for_service_catalog/$', views.db_fix_for_service_catalog),
url(r'^weekly_statical/$', views.weekly_statical),
url(r'^db_fix_for_workflow_after_2_5_9/$', views.db_fix_for_workflow_after_2_5_9),
url(r'^db_fix_for_blueapps_after_2_6_0/$', views.db_fix_for_blueapps_after_2_6_0),
re_path(r"^fix_ticket_title/$", views.fix_ticket_title),
re_path(r"^update_logs_type/$", views.update_logs_type),
re_path(r"^db_fix_after_2_0_3/$", views.db_fix_after_2_0_3),
re_path(
r"^db_fix_ticket_end_at_after_2_0_5/$", views.db_fix_ticket_end_at_after_2_0_5
),
re_path(r"^db_fix_deal_time_after_2_0_5/$", views.db_fix_deal_time_after_2_0_5),
re_path(r"^db_fix_after_2_0_7/$", views.db_fix_after_2_0_7),
re_path(r"^db_fix_after_2_0_9/$", views.db_fix_after_2_0_9),
re_path(r"^db_fix_after_2_0_14/$", views.db_fix_after_2_0_14),
re_path(r"^db_fix_after_2_1_x/$", views.db_fix_after_2_1_x),
re_path(r"^db_fix_after_2_1_1/$", views.db_fix_after_2_1_1),
re_path(r"^db_fix_sla/$", views.db_fix_sla),
re_path(r"^db_fix_after_2_1_9/$", views.db_fix_after_2_1_9),
re_path(r"^export_api_system/$", views.export_api_system),
re_path(r"^db_fix_for_attachments/$", views.db_fix_for_attachments),
re_path(r"^db_fix_for_service_catalog/$", views.db_fix_for_service_catalog),
re_path(r"^weekly_statical/$", views.weekly_statical),
re_path(
r"^db_fix_for_workflow_after_2_5_9/$", views.db_fix_for_workflow_after_2_5_9
),
re_path(
r"^db_fix_for_blueapps_after_2_6_0/$", views.db_fix_for_blueapps_after_2_6_0
),
# 获取settings内容
]

# urlpatterns += [
# url(r'^dump_db/$', views_common.dump_db),
# url(r'^drop_table/$', views_common.drop_table),
# re_path(r'^dump_db/$', views_common.dump_db),
# re_path(r'^drop_table/$', views_common.drop_table),
# ]
8 changes: 4 additions & 4 deletions itsm/misc/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
"""

from django.conf.urls import url
from django.urls import re_path

from itsm.misc import views

urlpatterns = [
url(r"^upload_file/$", views.upload),
url(r"^download_file/$", views.download),
url(r"^clean_cache/$", views.clean_cache),
re_path(r"^upload_file/$", views.upload),
re_path(r"^download_file/$", views.download),
re_path(r"^clean_cache/$", views.clean_cache),
]
6 changes: 3 additions & 3 deletions itsm/monitor/urls.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# -*- coding: utf-8 -*-
from django.conf.urls import url
from django.urls import re_path, path

from itsm.monitor.views import healthz, ping

urlpatterns = [
# main
url(r"^healthz/$", healthz),
url(r"ping/$", ping),
re_path(r"^healthz/$", healthz),
path(r"ping/$", ping),
]
6 changes: 3 additions & 3 deletions itsm/openapi/devops_plugin/urls.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# -*- coding: utf-8 -*-
from django.conf.urls import url
from django.urls import re_path

from itsm.openapi.devops_plugin import views

urlpatterns = [
# main
url(r"^devops_plugin/services/$", views.services),
url(r"^devops_plugin/fields/$", views.service_fields),
re_path(r"^devops_plugin/services/$", views.services),
re_path(r"^devops_plugin/fields/$", views.service_fields),
]
2 changes: 1 addition & 1 deletion itsm/plugin_service/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ INSTALLED_APPS += (
``` python
urlpatterns = [
...,
url(r"^plugin_service/", include("plugin_service.urls")),
re_path(r"^plugin_service/", include("plugin_service.urls")),
...,
]
```
Expand Down
6 changes: 3 additions & 3 deletions itsm/plugin_service/docs/openapi_config.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
)

urlpatterns += [
url(r"^swagger(?P<format>\.json|\.yaml)$", schema_view.without_ui(cache_timeout=0), name="schema-json"),
url(r"^swagger/$", schema_view.with_ui("swagger", cache_timeout=0), name="schema-swagger-ui"),
url(r"^redoc/$", schema_view.with_ui("redoc", cache_timeout=0), name="schema-redoc"),
re_path(r"^swagger(?P<format>\.json|\.yaml)$", schema_view.without_ui(cache_timeout=0), name="schema-json"),
re_path(r"^swagger/$", schema_view.with_ui("swagger", cache_timeout=0), name="schema-swagger-ui"),
re_path(r"^redoc/$", schema_view.with_ui("redoc", cache_timeout=0), name="schema-redoc"),
]
```

Expand Down
16 changes: 8 additions & 8 deletions itsm/plugin_service/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@
specific language governing permissions and limitations under the License.
"""

from django.conf.urls import url
from django.urls import re_path

from . import api


urlpatterns = [
url(r"^list/$", api.get_plugin_list),
url(r"^detail_list/$", api.get_plugin_detail_list),
url(r"^meta/$", api.get_meta),
url(r"^detail/$", api.get_plugin_detail),
url(r"^logs/$", api.get_logs),
url(r"^app_detail/$", api.get_plugin_app_detail),
url(
re_path(r"^list/$", api.get_plugin_list),
re_path(r"^detail_list/$", api.get_plugin_detail_list),
re_path(r"^meta/$", api.get_meta),
re_path(r"^detail/$", api.get_plugin_detail),
re_path(r"^logs/$", api.get_logs),
re_path(r"^app_detail/$", api.get_plugin_app_detail),
re_path(
r"^data_api/(?P<plugin_code>.+?)/(?P<data_api_path>.+)$",
api.get_plugin_api_data,
),
Expand Down
10 changes: 5 additions & 5 deletions itsm/postman/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
"""

from django.conf.urls import url
from django.urls import re_path
from rest_framework.routers import DefaultRouter

from itsm.postman.views import (
Expand All @@ -36,13 +36,13 @@

routers = DefaultRouter(trailing_slash=True)

routers.register(r'api_instance', ApiInstanceViewsSet, basename="api_instance")
routers.register(r"api_instance", ApiInstanceViewsSet, basename="api_instance")

routers.register(r'remote_system', RemoteSystemViewSet, basename='remote_system')
routers.register(r"remote_system", RemoteSystemViewSet, basename="remote_system")

routers.register(r'remote_api', RemoteApiViewSet, basename='remote_api')
routers.register(r"remote_api", RemoteApiViewSet, basename="remote_api")

# APIView不能通过routers.register()的方式注入路由
urlpatterns = routers.urls + [
url(r'^rpc_api/$', RpcApiViewSet.as_view()),
re_path(r"^rpc_api/$", RpcApiViewSet.as_view()),
]
Loading

0 comments on commit ce6f1a6

Please sign in to comment.