fix(site): 精简站点配置,移除名称/Banner/相关链接 (#15)
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
608afb88ea
commit
460cfdc78a
8 files changed
+24
-238
No files matched your search
@@ -1,4 +1,3 @@
|
||||
import json
|
||||
from datetime import datetime, timezone
|
||||
|
||||
from sqlalchemy import DateTime, Integer, String, Text, select
|
||||
@@ -11,12 +10,9 @@ def _mysql_args() -> dict:
|
||||
return {"mysql_charset": "utf8mb4", "mysql_collate": "utf8mb4_unicode_ci"}
|
||||
|
||||
DEFAULTS: dict[str, str] = {
|
||||
"site_name": "甘肃省房地产价格评估行业协会",
|
||||
"logo_file_id": "",
|
||||
"banner_file_ids": "[]",
|
||||
"icp_text": "陇ICP备19001227号",
|
||||
"police_text": "甘公网安备62010202001984号",
|
||||
"friend_links": "[]",
|
||||
"link_cirea": "",
|
||||
"link_housing": "",
|
||||
"complaint_workdays": "",
|
||||
@@ -27,7 +23,6 @@ DEFAULTS: dict[str, str] = {
|
||||
}
|
||||
|
||||
SETTING_KEYS = tuple(DEFAULTS)
|
||||
_JSON_KEYS = {"banner_file_ids", "friend_links"}
|
||||
_NUMBER_KEYS = {"upload_max_bytes", "login_max_failures", "login_lock_minutes"}
|
||||
_OPTIONAL_NUMBER_KEYS = {"complaint_workdays", "expert_reply_workdays"}
|
||||
|
||||
@@ -109,14 +104,6 @@ def save_settings(db, values: dict[str, str]) -> None:
|
||||
|
||||
|
||||
def _present(key: str, raw: str):
|
||||
if key in _JSON_KEYS:
|
||||
if not raw:
|
||||
return []
|
||||
try:
|
||||
parsed = json.loads(raw)
|
||||
except json.JSONDecodeError:
|
||||
return []
|
||||
return parsed if isinstance(parsed, list) else []
|
||||
if key in _NUMBER_KEYS:
|
||||
text = str(raw).strip()
|
||||
if text.isdigit():
|
||||
@@ -160,6 +147,4 @@ def settings_view(db) -> dict:
|
||||
logo_id = raw.get("logo_file_id", "")
|
||||
logo_urls = _public_urls(db, [logo_id]) if str(logo_id).strip() else []
|
||||
view["logoUrl"] = logo_urls[0] if logo_urls else ""
|
||||
banners = view["banner_file_ids"] if isinstance(view["banner_file_ids"], list) else []
|
||||
view["bannerUrls"] = _public_urls(db, banners)
|
||||
return view
|
||||
Reference in new issue
Block a user