diff --git a/__pycache__/database.cpython-312.pyc b/__pycache__/database.cpython-312.pyc index 051e771..ad6d588 100644 Binary files a/__pycache__/database.cpython-312.pyc and b/__pycache__/database.cpython-312.pyc differ diff --git a/__pycache__/main.cpython-312.pyc b/__pycache__/main.cpython-312.pyc index 0935591..a3a8d62 100644 Binary files a/__pycache__/main.cpython-312.pyc and b/__pycache__/main.cpython-312.pyc differ diff --git a/database.py b/database.py index a3bb733..1a813f2 100644 --- a/database.py +++ b/database.py @@ -197,6 +197,8 @@ CREATE TABLE IF NOT EXISTS cv_batches ( -- JSON array of positions extracted from the document -- [{job_title, num_positions, required_skills, required_years, required_certs, description}] positions JSONB DEFAULT '[]', + -- Selected Carbone template ID for CV generation + template_id TEXT, -- draft = still working, active = matching done, exported = CVs generated status VARCHAR(50) DEFAULT 'draft', created_at TIMESTAMPTZ DEFAULT NOW(), diff --git a/main.py b/main.py index 1da0b1a..d90e572 100644 --- a/main.py +++ b/main.py @@ -913,12 +913,12 @@ async def get_batch(batch_id: str): @app.put("/api/batches/{batch_id}") async def update_batch(batch_id: str, request: Request): - """Update batch name/description.""" + """Update batch name/description/template.""" body = await request.json() row = db.execute( - """UPDATE cv_batches SET name = %s, description = %s, updated_at = NOW() + """UPDATE cv_batches SET name = %s, description = %s, template_id = %s, updated_at = NOW() WHERE id = %s RETURNING *""", - (body.get("name"), body.get("description"), batch_id) + (body.get("name"), body.get("description"), body.get("template_id"), batch_id) ) if not row: raise HTTPException(404, "Batch not found") diff --git a/static/batches.js b/static/batches.js index c3e9af7..8d98069 100644 --- a/static/batches.js +++ b/static/batches.js @@ -143,6 +143,17 @@ async function uploadBatchDoc(file) { // BATCH DETAIL VIEW // ============================================================ let currentBatch = null; +let batchTemplates = []; + +async function loadBatchTemplates() { + try { + const resp = await fetch('http://' + location.hostname + ':8771/api/carbone/templates'); + const data = await resp.json(); + batchTemplates = data.templates || []; + } catch (e) { + batchTemplates = []; + } +} async function openBatch(batchId) { currentBatchId = batchId; @@ -151,6 +162,8 @@ async function openBatch(batchId) { detail.style.display = 'block'; detail.innerHTML = '