Files
boss_dp/update_urls.py

38 lines
1.4 KiB
Python
Raw Permalink Normal View History

2026-03-05 10:27:28 +08:00
# -*- coding: utf-8 -*-
"""临时脚本:更新 urls.py"""
# 读取文件
with open('server/urls.py', 'r', encoding='utf-8') as f:
content = f.read()
# 1. 更新导入
old_import = "from server.api import auth, accounts, tasks, workers, filters, scripts, contacts, stats, settings as api_settings"
new_import = """from server.api import (
auth, accounts, tasks, workers, filters, scripts, contacts, stats,
settings as api_settings, followup
)"""
if old_import in content:
content = content.replace(old_import, new_import)
# 2. 在联系记录后添加复聊配置路由
insert_point = ' path("api/contacts/<int:pk>", contacts.contact_detail),'
followup_routes = ''' path("api/contacts/<int:pk>", contacts.contact_detail),
# ─── 复聊配置 ───
path("api/followup-configs", followup.followup_config_list),
path("api/followup-configs/<int:pk>", followup.followup_config_detail),
path("api/followup-scripts", followup.followup_script_list),
path("api/followup-scripts/<int:pk>", followup.followup_script_detail),
path("api/followup-records", followup.followup_record_list),
path("api/followup-records/send", followup.followup_send_manual),'''
if insert_point in content and 'followup-configs' not in content:
content = content.replace(insert_point, followup_routes)
# 写入文件
with open('server/urls.py', 'w', encoding='utf-8') as f:
f.write(content)
print("URLs 更新完成!")