Редактор ачивок в админке + файловое хранилище ачивок (задел под титулы)
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
"""Публичное чтение ачивок: список и иконки (для отображения; выдача — на будущее)."""
|
||||
from __future__ import annotations
|
||||
|
||||
from fastapi import APIRouter, Depends
|
||||
from fastapi.responses import FileResponse
|
||||
|
||||
from app.auth.deps import get_current_user
|
||||
from app.models import User
|
||||
from app.schemas import api as s
|
||||
from app.services import achievement_service
|
||||
|
||||
router = APIRouter(prefix="/achievements", tags=["achievements"])
|
||||
|
||||
|
||||
@router.get("", response_model=list[s.AchievementRead])
|
||||
def list_achievements(_user: User = Depends(get_current_user)) -> list[dict]:
|
||||
return achievement_service.list_achievements()
|
||||
|
||||
|
||||
# Иконка — без auth: косметический ассет, нужен и игроку, и в админ-панели (cookie
|
||||
# админа scoped на /api/admin и сюда не отправляется). Отдаётся по известному slug.
|
||||
@router.get("/{slug}/icon")
|
||||
def get_icon(slug: str) -> FileResponse:
|
||||
path, media_type = achievement_service.icon_file(slug)
|
||||
return FileResponse(
|
||||
path, media_type=media_type, headers={"Cache-Control": "public, max-age=3600"}
|
||||
)
|
||||
Reference in New Issue
Block a user