Files
jobboard/roledesk/web/pages.py
T
WolfandClaude Sonnet 5 b44f78ca7e Serve one alpha page: filters, roles, the tracker, and Jobs
/, GET /api/roles|companies|applications, POST /api/companies/{key}/affinity
and /api/applications[/{id}/status]. The Jinja2 template renders an empty
shell; static/app.js fills it and drives Save, affinity and status changes.
<desk-jobs> from pipeline.web mounts at the bottom so Pull can be started
from the page.

Store.roles gains q, function, remote, days and hide_muted, and company/
place move from a key match to a substring on the text a board wrote.
hide_muted filters in SQL before LIMIT: filtering after it shipped first and
broke immediately on real data, since Databricks' freshly pulled 884 roles
were the newest 200-plus rows in the table and muting it left nothing to
show.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-23 11:56:10 +02:00

48 lines
1.7 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 `roledesk`'s: the nine job functions are
the classifier's vocabulary, and this reaches `plugins/` the same way
`roledesk.cli` already does, since a plugin is app-agnostic and never reaches
back into `roledesk`.
"""
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 roledesk.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,
})