#!/usr/bin/env python3 """Render the internal ops dashboard (static HTML) from queue.json. Deployed to an unlisted path on the Pages project. Internal only: shows costs/margins (never customer-facing). Customers have no access. """ import os, json, datetime, html as htmllib BASE = os.path.dirname(os.path.abspath(__file__)) QUEUE = os.path.join(BASE, "dashboard", "queue.json") STATUS_STYLE = { "draft_ready": ("background:#d4edda;color:#155724", "Draft ready for Sean"), "engaged": ("background:#cce5ff;color:#004085", "Customer engaged"), "needs_review": ("background:#fff3cd;color:#856404", "Needs review"), "draft_failed": ("background:#f8d7da;color:#721c24", "Draft failed"), } def render(): queue = json.load(open(QUEUE)) if os.path.exists(QUEUE) else [] cards = [] for q in queue: c = q.get("customer", {}) status = q.get("status", "?") style, label = STATUS_STYLE.get( status, STATUS_STYLE.get(q.get("draft_status", ""), ("background:#eee;color:#555", status))) gaps = "".join("
Review carefully:
[%s lead] %s
' % ( lc, lead["tier"], htmllib.escape("; ".join(lead.get("reasons", []))))) prop = q.get("proposal_pdf", "") prop_html = ("Proposal PDF: %s
No proposal yet.
") live = q.get("live_url") live_html = ('Live link: %s
' % (htmllib.escape(live), htmllib.escape(live)) if live else "Live link pending Cloudflare connector (HTML attached to draft).
") draft = q.get("draft_id") draft_html = ("Customer draft: %s (in Sean's Gmail drafts, ready to review and send)
" % htmllib.escape(q.get("draft_status", "")) if draft else "No customer draft.
") eng = q.get("engaged_config") or {} eng_html = "" if eng.get("model"): eng_html = "Engaged: %s · %s · %s%s
" % ( htmllib.escape(eng.get("model", "")), htmllib.escape(eng.get("term", "")), htmllib.escape(eng.get("monthly", "")), (" · also interested in " + htmllib.escape(eng.get("addons", "")) if eng.get("addons") else "")) tm = ("$%s / month" % format(q["total_monthly"], ",.2f")) if q.get("total_monthly") else "-" model_line = htmllib.escape(str(q.get("model") or "?")) if q.get("model_recommended"): model_line += ' (engine-recommended)' cards.append("""%(contact)s · %(phone)s · %(email)s
Model: %(model)s · Total: %(total)s · Lease: %(lease)s
Valid until: %(valid)s · Built: %(built)s
id: %(id)s
No quote requests yet.
" page = """Updated %s · Pricing: 25%% margin, 63-mo FMV Universal lease, B&W $0.014 / color $0.08 per page.
%sWorkflow: request → priced → PDF + interactive built → customer draft created for Sean's review → Sean sends. Costs and margins never leave this page.
""" % (datetime.datetime.now().strftime("%Y-%m-%d %H:%M ET"), body) out = os.path.join(BASE, "dashboard", "index.html") open(out, "w").write(page) return out if __name__ == "__main__": print(render())