Wire freehire, Jobnet and Akademikernes Jobbank into the CLI, the Sources form, dupes and the docs
Provider names, the CLI's choices and the dupes rule's search hosts now come from readers.PROVIDERS, and the regions, work modes and remote words from the modules' REGIONS, MODES and REMOTE, read with getattr so main works before and after the readers merge. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
018a1ad895
commit
6e6e655203
16 files changed
+422
-39
No files matched your search
+28
-3
@@ -27,8 +27,11 @@ keeps working.
|
||||
functions are the classifier's vocabulary and the hosts are what it parses,
|
||||
and this reaches `plugins/` the same way `app.cli` does, since a plugin is
|
||||
app-agnostic and never reaches back into `app`. The
|
||||
Jobindex areas, Adzuna countries and Platsbanken regions on the Sources page
|
||||
come from the search readers in `plugins/readers/` for the same reason.
|
||||
Jobindex areas, Adzuna countries, the regions of Platsbanken, Jobnet and
|
||||
Jobbank, freehire's work modes and Jobbank's remote words on the Sources page
|
||||
come from the search readers in `plugins/readers/` for the same reason. The
|
||||
last four and the select's other providers are read from `readers.PROVIDERS`,
|
||||
so the page works whether or not a provider's module is loaded.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
@@ -41,6 +44,7 @@ from fastapi import APIRouter, HTTPException, Request
|
||||
from fastapi.responses import HTMLResponse, RedirectResponse
|
||||
from fastapi.templating import Jinja2Templates
|
||||
|
||||
from app import jobs
|
||||
from app.models import LADDER, REMOTE, RUNGS, STATUSES
|
||||
from app.web.deps import StoreDep
|
||||
|
||||
@@ -48,6 +52,7 @@ _ROOT = Path(__file__).resolve().parents[2]
|
||||
if str(_ROOT) not in sys.path:
|
||||
sys.path.insert(0, str(_ROOT))
|
||||
|
||||
from plugins import readers # noqa: E402
|
||||
from plugins.ats import FUNCTIONS, HOSTS # noqa: E402
|
||||
from plugins.readers.adzuna import COUNTRIES as ADZUNA_COUNTRIES # noqa: E402
|
||||
from plugins.readers.jobindex import AREAS as JOBINDEX_AREAS # noqa: E402
|
||||
@@ -110,6 +115,25 @@ HOST_OPTIONS = list(HOSTS.items())
|
||||
LADDER_JSON = {"rungs": list(RUNGS), "levels": {k: list(v) for k, v in LADDER.items()}}
|
||||
|
||||
|
||||
def search_options() -> dict[str, list[tuple[str, str]]]:
|
||||
"""The `value, label` options the Sources form's providers add to its
|
||||
selects, read from `readers.PROVIDERS` on each request: the providers the
|
||||
template does not name itself, and the regions of Jobnet and Jobbank,
|
||||
freehire's work modes and Jobbank's remote words, each in the reader's
|
||||
order and without its empty value, which the form puts first as "all". All
|
||||
empty for a provider whose module is not loaded."""
|
||||
def options(provider: str, table: str) -> list[tuple[str, str]]:
|
||||
return [(value, label) for value, label in jobs.sources.provider_table(provider, table).items()
|
||||
if value]
|
||||
|
||||
return {"providers": [(n, m.LABEL) for n, m in readers.PROVIDERS.items()
|
||||
if n not in ("jobindex", "adzuna", "platsbanken")],
|
||||
"jobnet_regions": options("jobnet", "REGIONS"),
|
||||
"jobbank_regions": options("jobbank", "REGIONS"),
|
||||
"modes": options("freehire", "MODES"),
|
||||
"jobbank_remote": options("jobbank", "REMOTE")}
|
||||
|
||||
|
||||
def asset(path: str) -> str:
|
||||
"""A static URL stamped with the file's modification time, so a changed
|
||||
file is a different URL and a cached stale copy is never the answer."""
|
||||
@@ -180,7 +204,8 @@ def agents(request: Request) -> HTMLResponse:
|
||||
@router.get("/settings/sources", response_class=HTMLResponse)
|
||||
def sources(request: Request) -> HTMLResponse:
|
||||
return page(request, "settings/sources.html", areas=AREA_OPTIONS,
|
||||
countries=COUNTRY_OPTIONS, regions=REGION_OPTIONS, hosts=HOST_OPTIONS)
|
||||
countries=COUNTRY_OPTIONS, regions=REGION_OPTIONS, hosts=HOST_OPTIONS,
|
||||
**search_options())
|
||||
|
||||
|
||||
@router.get("/settings/account", response_class=HTMLResponse)
|
||||
|
||||
Reference in new issue
Block a user