forked from retoor/devplacepy
- Fix StatisticsOut to match the real admin_statistics page context (active_tab/tabs/window_hours/initial), which was raising a ValidationError and 500ing GET /admin/statistics with Accept: application/json. - Add missing *Out fields dropped from JSON responses: IsslopSourceOut (source_lines, marked_lines, focus_line, report_url), IsslopReportOut (report_url, badge_url, events_url, topic), IssuesOut (viewer_is_admin), GameStateOut/GameFarmViewOut (game_error), QuizAttemptPageOut (answer_max_chars, quiz_error), QuizBuilderOut (quiz_error). - Convert GET /admin/issues/planning to respond() with a new AdminIssuesPlanningOut schema so it serves JSON like every sibling admin dashboard, and document it in docs_api. - Document previously-undocumented admin endpoint families in docs_api: services page routes, gateway provider/model CRUD, admin workspaces (11 routes), and trash list/restore/purge. - Correct stale references to services/devii/actions/catalog.py as a single file; it is the actions/catalog/ package. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VL9Xn57W5UR3HZbbuuzxdK
70 lines
2.2 KiB
Python
70 lines
2.2 KiB
Python
# retoor <retoor@molodetz.nl>
|
|
|
|
import logging
|
|
|
|
from fastapi import APIRouter, Request
|
|
from fastapi.responses import HTMLResponse
|
|
|
|
from devplacepy.responses import respond
|
|
from devplacepy.schemas import AdminIssuesPlanningOut
|
|
from devplacepy.seo import base_seo_context
|
|
from devplacepy.services.gitea import runtime
|
|
from devplacepy.services.gitea.config import gitea_config
|
|
from devplacepy.services.gitea.planning import collect_open_issues
|
|
from devplacepy.utils import require_admin
|
|
|
|
logger = logging.getLogger(__name__)
|
|
router = APIRouter()
|
|
|
|
|
|
async def _open_tickets() -> tuple[list[dict], bool]:
|
|
try:
|
|
issues = await collect_open_issues(runtime.get_client())
|
|
except Exception as exc:
|
|
logger.warning("Could not load open tickets for planning: %s", exc)
|
|
return [], True
|
|
tickets = [
|
|
{
|
|
"number": int(issue.get("number", 0)),
|
|
"title": str(issue.get("title", "")).strip() or "Untitled",
|
|
"labels": [
|
|
str(label.get("name", "")).strip()
|
|
for label in (issue.get("labels") or [])
|
|
if isinstance(label, dict) and label.get("name")
|
|
],
|
|
}
|
|
for issue in issues
|
|
]
|
|
return tickets, False
|
|
|
|
|
|
@router.get("/issues/planning", response_class=HTMLResponse)
|
|
async def admin_issues_planning(request: Request):
|
|
admin = require_admin(request)
|
|
seo_ctx = base_seo_context(
|
|
request,
|
|
title="Ticket Planning - Admin",
|
|
description="Generate a grouped, ordered planning report of all open tickets.",
|
|
robots="noindex,nofollow",
|
|
breadcrumbs=[
|
|
{"name": "Home", "url": "/feed"},
|
|
{"name": "Admin", "url": "/admin"},
|
|
{"name": "Issues", "url": "/issues"},
|
|
],
|
|
)
|
|
configured = gitea_config().is_configured
|
|
tickets: list[dict] = []
|
|
tickets_error = False
|
|
if configured:
|
|
tickets, tickets_error = await _open_tickets()
|
|
context = {
|
|
**seo_ctx,
|
|
"request": request,
|
|
"user": admin,
|
|
"admin_section": "issues",
|
|
"configured": configured,
|
|
"tickets": tickets,
|
|
"tickets_error": tickets_error,
|
|
}
|
|
return respond(request, "admin_issues_planning.html", context, model=AdminIssuesPlanningOut)
|