Files
jobboard/app/web/pages.py
T
WolfandClaude Opus 5.5 7a63311714 Rename the package roledesk to app
The boilerplate's rule: the deploy kit's Dockerfile, the APP_CONFIG,
APP_PASSWORD and APP_DATA variables and its commands all assume a package
called app, so a project renames its display title and nothing else. The
console script is `app`, and the launch entry runs `uv run app serve --port
8790`. The domain noun stays `role`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-23 12:30:10 +02:00

48 lines
1.6 KiB
Python

"""The one page. Everything under `/api` and `/_jobs` is JSON; this route
hands the browser an empty shell — the filter bar, the section headers, the
`<select>` options a plugin's vocabulary decides — and `static/app.js` fills
it and drives every action from there.
`FUNCTIONS` is `plugins.ats`'s, not `app`'s: the nine job functions are
the classifier's vocabulary, and this reaches `plugins/` the same way
`app.cli` already does, since a plugin is app-agnostic and never reaches
back into `app`.
"""
from __future__ import annotations
import sys
from pathlib import Path
from fastapi import APIRouter, Request
from fastapi.responses import HTMLResponse
from fastapi.templating import Jinja2Templates
from app.models import REMOTE, STATUSES
_ROOT = Path(__file__).resolve().parents[2]
if str(_ROOT) not in sys.path:
sys.path.insert(0, str(_ROOT))
from plugins.ats import FUNCTIONS # noqa: E402
WEB = Path(__file__).resolve().parent
templates = Jinja2Templates(directory=WEB / "templates")
router = APIRouter(tags=["pages"])
#: `value, label` for each function select option. `FUNCTIONS` is already the
#: value a role's `function` column holds; only the label is dressed up.
FUNCTION_OPTIONS = [(f, f.replace("/", " / ").capitalize()) for f in FUNCTIONS]
REMOTE_OPTIONS = [(r, r.capitalize()) for r in REMOTE if r]
STATUS_OPTIONS = [(s, s.capitalize()) for s in STATUSES]
@router.get("/", response_class=HTMLResponse)
def index(request: Request) -> HTMLResponse:
return templates.TemplateResponse(request, "index.html", {
"functions": FUNCTION_OPTIONS,
"remote_options": REMOTE_OPTIONS,
"status_options": STATUS_OPTIONS,
})