6-sub sprint: Dokumenti+HNS profil+Admin+ERP+CRM+PGŽ filter
SUB1 Dokumenti: pgz:dokumenti SECTIONS handler u app.html (klikabilan grid 19 godišnjaka, PDF stream) SUB2 HNS profil: sport2.html drill-down — bio-chips (visina/težina/noga/poz/dres) + HNS deep + Google + Wiki + 🏆 Karijera/📅 Utakmice tabovi (Josip Zec id=449: 257 nast/182 gol/15 sez) SUB3 Admin Users: sidebar.js href fix /admin/users → /sport/admin/users + razriješen audit ID konflikt SUB4 ERP Full: 5 novih endpointa (invoice-uploads, racuni/ulazni/{rid}/uploads, expense-reports, putni-nalog-racuni, payments) + 3 nova taba (📎 Uploads/OCR, ✈ Putni, 💰 Plaćanja) + inline stavke drill-down + sidebar entry SUB5 CRM Salesforce-Lite: dodan crm_v2 sidebar entry (router 956 linija već mounted) SUB6 PGŽ filter: 2 nova endpointa /api/v2/savezi/priority-sort + /api/v2/clanovi/priority-sort; togglePGZFilter wired u Klubovi/Savezi/Sportaši (sport2.html + app.html); ⭐💰📖 badge prefix; klubovi 1536/1641, savezi 35/246, sportaši 4979/5499 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -5708,3 +5708,53 @@ def v2_sportasi_by_kategorija(
|
||||
out = sorted(groups.values(), key=lambda x: x["kategorija"])
|
||||
return {"ok": True, "groups": out, "total_kategorija": len(out)}
|
||||
|
||||
|
||||
# ──────────────────────────────────────────────────────────────────
|
||||
# PGŽ-financed (priority) thin wrappers for savezi & clanovi (SUB6)
|
||||
# ──────────────────────────────────────────────────────────────────
|
||||
@router.get("/savezi/priority-sort")
|
||||
def v2_savezi_priority_sort(only: bool = False, limit: int = 500):
|
||||
"""Savezi sa pgz_relevant=true prvi (ili samo oni ako only=true)."""
|
||||
where = "WHERE COALESCE(s.aktivan,true)"
|
||||
if only:
|
||||
where += " AND COALESCE(s.pgz_relevant,false) = TRUE"
|
||||
rows = db_query(f"""
|
||||
SELECT s.*,
|
||||
COALESCE(s.pgz_relevant,false) AS priority,
|
||||
(SELECT COUNT(*) FROM pgz_sport.klubovi WHERE savez_id=s.id) AS broj_klubova
|
||||
FROM pgz_sport.savezi s
|
||||
{where}
|
||||
ORDER BY COALESCE(s.pgz_relevant,false) DESC, s.naziv COLLATE "hr-HR-x-icu"
|
||||
LIMIT %s
|
||||
""", (limit,))
|
||||
return {"count": len(rows), "rows": rows}
|
||||
|
||||
|
||||
@router.get("/clanovi/priority-sort")
|
||||
def v2_clanovi_priority_sort(only: bool = False, limit: int = 500):
|
||||
"""Sportaši čiji klub je PGŽ-financiran ili u godišnjaku — prioritetni prvi."""
|
||||
priority_expr = ("(COALESCE(k.pgz_sufinanciran,false) "
|
||||
"OR (k.godisnjak_godine IS NOT NULL "
|
||||
"AND array_length(k.godisnjak_godine,1) > 0))")
|
||||
where = "WHERE c.aktivan = TRUE"
|
||||
if only:
|
||||
where += f" AND {priority_expr}"
|
||||
rows = db_query(f"""
|
||||
SELECT c.id, c.ime, c.prezime, c.oib, c.datum_rodenja, c.spol, c.sport,
|
||||
c.pozicija, c.reprezentativac, c.kategoriziran, c.stipendiran,
|
||||
c.kategorija, c.kategorije, c.kategorija_hoo, c.hoo_kategorija,
|
||||
c.aktivan, c.klub_id, c.klub_naziv_godisnjak, c.slika_url,
|
||||
c.broj_dresa, c.uloga,
|
||||
k.naziv AS klub_naziv,
|
||||
COALESCE(k.pgz_sufinanciran,false) AS klub_financiran,
|
||||
(k.godisnjak_godine IS NOT NULL
|
||||
AND array_length(k.godisnjak_godine,1) > 0) AS klub_godisnjak,
|
||||
{priority_expr} AS priority
|
||||
FROM pgz_sport.clanovi c
|
||||
LEFT JOIN pgz_sport.klubovi k ON k.id = c.klub_id
|
||||
{where}
|
||||
ORDER BY {priority_expr} DESC, c.prezime, c.ime
|
||||
LIMIT %s
|
||||
""", (limit,))
|
||||
return {"count": len(rows), "rows": rows}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user