chore: remove scripts and export_i18n.py from git, add to .gitignore
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -6,3 +6,4 @@ uploads/*
|
||||
*.db
|
||||
.env
|
||||
server.log
|
||||
scripts/
|
||||
|
||||
@@ -17,6 +17,11 @@
|
||||
"admin.copyright_label": "Copyright Text",
|
||||
"admin.copyright_hint": "Displayed at the bottom of all pages. Leave empty to hide.",
|
||||
"admin.save_config": "Save",
|
||||
"admin.invite_length_error": "Invite code must be 8 characters",
|
||||
"admin.invite_exists_error": "Invite code already exists",
|
||||
"admin.invite_created": "Invite code {code} created",
|
||||
"admin.invite_updated": "Invite code {code} updated",
|
||||
"admin.config_saved": "Settings saved",
|
||||
"login.title": "Login",
|
||||
"login.username": "Username",
|
||||
"login.password": "Password",
|
||||
|
||||
@@ -17,6 +17,11 @@
|
||||
"admin.copyright_label": "Copyright 文本",
|
||||
"admin.copyright_hint": "将显示在所有页面底部,留空则不显示。",
|
||||
"admin.save_config": "保存设置",
|
||||
"admin.invite_length_error": "邀请码必须为8个字符",
|
||||
"admin.invite_exists_error": "邀请码已存在",
|
||||
"admin.invite_created": "邀请码 {code} 已创建",
|
||||
"admin.invite_updated": "邀请码 {code} 已更新",
|
||||
"admin.config_saved": "设置已保存",
|
||||
"login.title": "登录",
|
||||
"login.username": "用户名",
|
||||
"login.password": "密码",
|
||||
|
||||
@@ -102,7 +102,7 @@ def _get_copyright() -> str:
|
||||
return ""
|
||||
|
||||
|
||||
templates.env.globals["copyright_text"] = _get_copyright()
|
||||
templates.env.globals["get_copyright"] = _get_copyright
|
||||
|
||||
|
||||
def _redirect(url: str) -> RedirectResponse:
|
||||
@@ -270,7 +270,7 @@ def admin_save_config(
|
||||
cfg = SystemConfig(key="copyright_text", value=copyright_text.strip())
|
||||
db.add(cfg)
|
||||
db.commit()
|
||||
return _admin_render(request, user, db, "config", success="Saved")
|
||||
return _admin_render(request, user, db, "config", success=_t("admin.config_saved", user.language))
|
||||
|
||||
|
||||
@router.post("/admin/invites/add")
|
||||
@@ -291,9 +291,9 @@ def admin_add_invite(
|
||||
else:
|
||||
code = code.strip()
|
||||
if len(code) != 8:
|
||||
return _admin_render(request, user, db, "invites", error="邀请码必须为8个字符")
|
||||
return _admin_render(request, user, db, "invites", error=_t("admin.invite_length_error", user.language))
|
||||
if db.query(InviteCode).filter(InviteCode.code == code).first():
|
||||
return _admin_render(request, user, db, "invites", error="邀请码已存在")
|
||||
return _admin_render(request, user, db, "invites", error=_t("admin.invite_exists_error", user.language))
|
||||
# Parse limits
|
||||
m_uses = None
|
||||
exp_at = None
|
||||
@@ -307,7 +307,7 @@ def admin_add_invite(
|
||||
)
|
||||
db.add(new_code)
|
||||
db.commit()
|
||||
return _admin_render(request, user, db, "invites", success=f"邀请码 {code} 已创建")
|
||||
return _admin_render(request, user, db, "invites", success=_t("admin.invite_created", user.language).format(code=code))
|
||||
|
||||
|
||||
@router.post("/admin/invites/{code_id}/edit")
|
||||
@@ -335,7 +335,7 @@ def admin_edit_invite(
|
||||
code_obj.max_uses = None
|
||||
code_obj.expires_at = None
|
||||
db.commit()
|
||||
return _admin_render(request, user, db, "invites", success=f"邀请码 {code_obj.code} 已更新")
|
||||
return _admin_render(request, user, db, "invites", success=_t("admin.invite_updated", user.language).format(code=code_obj.code))
|
||||
|
||||
|
||||
@router.post("/admin/invites/{code_id}/delete")
|
||||
|
||||
@@ -39,9 +39,10 @@
|
||||
<main class="container">
|
||||
{% block content %}{% endblock %}
|
||||
</main>
|
||||
{% if copyright_text %}
|
||||
{% set _c = get_copyright() %}
|
||||
{% if _c %}
|
||||
<footer style="text-align:center;padding:2rem 1rem;color:var(--text-muted);font-size:.8rem;border-top:1px solid var(--border);margin-top:2rem">
|
||||
{{ copyright_text }}
|
||||
{{ _c }}
|
||||
</footer>
|
||||
{% endif %}
|
||||
</body>
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
"""Migrate: add permissions column to api_keys table."""
|
||||
import sqlite3
|
||||
from pathlib import Path
|
||||
|
||||
DB_PATH = Path(__file__).parent.parent / "postcard.db"
|
||||
|
||||
conn = sqlite3.connect(str(DB_PATH))
|
||||
cur = conn.cursor()
|
||||
|
||||
cur.execute("PRAGMA table_info(api_keys)")
|
||||
cols = [r[1] for r in cur.fetchall()]
|
||||
|
||||
if "permissions" not in cols:
|
||||
cur.execute('ALTER TABLE api_keys ADD COLUMN permissions TEXT NOT NULL DEFAULT "[]"')
|
||||
conn.commit()
|
||||
print("OK: column 'permissions' added to api_keys")
|
||||
else:
|
||||
print("SKIP: column 'permissions' already exists")
|
||||
|
||||
conn.close()
|
||||
@@ -1,24 +0,0 @@
|
||||
"""Migrate: create system_config table."""
|
||||
import sqlite3
|
||||
from pathlib import Path
|
||||
|
||||
DB_PATH = Path(__file__).parent.parent / "postcard.db"
|
||||
|
||||
conn = sqlite3.connect(str(DB_PATH))
|
||||
cur = conn.cursor()
|
||||
|
||||
cur.execute("SELECT name FROM sqlite_master WHERE type='table' AND name='system_config'")
|
||||
if not cur.fetchone():
|
||||
cur.execute(
|
||||
"CREATE TABLE system_config ("
|
||||
"key TEXT PRIMARY KEY, "
|
||||
"value TEXT NOT NULL DEFAULT '', "
|
||||
"updated_at TIMESTAMP"
|
||||
")"
|
||||
)
|
||||
conn.commit()
|
||||
print("OK: system_config table created")
|
||||
else:
|
||||
print("SKIP: system_config table exists")
|
||||
|
||||
conn.close()
|
||||
Reference in New Issue
Block a user