ForgeFix и новые фичи в интерфейсе
This commit is contained in:
@@ -9,6 +9,8 @@ import hashlib
|
||||
from datetime import datetime
|
||||
from pathlib import Path
|
||||
|
||||
from pack_manager import PACKS_DIR, load_packs_config, get_pack_presets, toggle_pack_disabled
|
||||
|
||||
from auth import get_db, require_role, log_audit, get_current_user, hash_password
|
||||
from roles import (
|
||||
ROLE_PERMISSIONS, UserRole, ROLE_NAMES, has_permission, Permissions,
|
||||
@@ -877,6 +879,58 @@ async def admin_delete_news(
|
||||
return {"success": True, "id": target.stem}
|
||||
|
||||
|
||||
# ====================== PACK MANAGEMENT (ELDER+) ======================
|
||||
|
||||
@router.get("/packs")
|
||||
async def admin_list_packs(
|
||||
current_user: dict = Depends(require_role(ROLE_ELDER)),
|
||||
):
|
||||
"""List all packs with disabled status"""
|
||||
packs = []
|
||||
packs_config = load_packs_config()
|
||||
|
||||
packs_dir = Path("packs")
|
||||
if packs_dir.exists():
|
||||
for pack_dir in packs_dir.iterdir():
|
||||
if pack_dir.is_dir():
|
||||
entry = packs_config.get(pack_dir.name, {})
|
||||
packs.append({
|
||||
"name": pack_dir.name,
|
||||
"disabled": entry.get("disabled", False),
|
||||
"presets": get_pack_presets(pack_dir.name)
|
||||
})
|
||||
|
||||
return {"packs": packs}
|
||||
|
||||
|
||||
@router.post("/packs/{pack_name}/toggle")
|
||||
async def admin_toggle_pack(
|
||||
pack_name: str,
|
||||
current_user: dict = Depends(require_role(ROLE_ELDER)),
|
||||
request: Request = None,
|
||||
):
|
||||
"""Toggle pack disabled/enabled status"""
|
||||
pack_path = PACKS_DIR / pack_name
|
||||
if not pack_path.exists() or not pack_path.is_dir():
|
||||
raise HTTPException(404, "Pack not found")
|
||||
|
||||
new_state = toggle_pack_disabled(pack_name)
|
||||
|
||||
ip = request.client.host if request.client else "unknown"
|
||||
log_audit(
|
||||
current_user["id"],
|
||||
"pack_toggle",
|
||||
f"{'Disabled' if new_state else 'Enabled'} pack {pack_name}",
|
||||
ip
|
||||
)
|
||||
|
||||
return {
|
||||
"success": True,
|
||||
"pack_name": pack_name,
|
||||
"disabled": new_state
|
||||
}
|
||||
|
||||
|
||||
@router.get("/me")
|
||||
async def get_my_info(current_user: dict = Depends(get_current_user)):
|
||||
"""Информация о текущем пользователе с правами"""
|
||||
|
||||
Reference in New Issue
Block a user