diff --git a/admin-panel-guests-harness.js b/admin-panel-guests-harness.js index 6d4b1e8..c46c6bf 100644 --- a/admin-panel-guests-harness.js +++ b/admin-panel-guests-harness.js @@ -1,9 +1,9 @@ -// Harness for the admin panel's GUESTS list (gift accounts), run through the +// Harness for the admin panel's GUESTS list (guest accounts), run through the // skill's checker alongside the chart harness: // ~/.hermes/skills/research/inference-cooperative/scripts/check-page-js.sh \ // app/main.py admin-panel-guests-harness.js // Exercises load() against both payload shapes — the portal's split payload -// (guests[]) and an older payload that still tags rows account_type='gift' +// (guests[]) and an older payload that still tags rows account_type='guest' // inside members[] — and asserts the invariants that matter: // * guests NEVER count as members, in either shape; // * guests never render in the members table; @@ -36,9 +36,9 @@ await runLoad({ members: [memberRow("alice@example.com", 2), memberRow("bob@example.com", 1)], guests: [{ email: "friend@example.com", username: "friend", active: true, - account_type: "gift", gift_inviter: "alice@example.com", + account_type: "guest", guest_inviter: "alice@example.com", credit_balance: 5, credits_remaining: 3.5, - gift_expires_at: "2027-01-07T02:00:00", gift_status: "active", + guest_expires_at: "2027-01-07T02:00:00", guest_status: "active", spend: 1.5, all_time_spend: 1.5, }], totals: { members: 2, total_spend: 4.5, total_all_time_spend: 45, @@ -71,21 +71,21 @@ switchView("members"); assert(document.getElementById("guests-section").style.display === "", "guests section returns on the Members view"); -// ---- Shape 2: older payload — gifts tagged inside members[] ---- +// ---- Shape 2: older payload — guests tagged inside members[] ---- await runLoad({ members: [ memberRow("alice@example.com", 2), memberRow("bob@example.com", 1), { email: "friend@example.com", username: "friend", active: true, - account_type: "gift", gift_inviter: "alice@example.com", - credit_balance: 5, credits_remaining: 3.5, gift_expires_at: "2027-01-07T02:00:00", - gift_status: "active", spend: 0.5, all_time_spend: 5 }, + account_type: "guest", guest_inviter: "alice@example.com", + credit_balance: 5, credits_remaining: 3.5, guest_expires_at: "2027-01-07T02:00:00", + guest_status: "active", spend: 0.5, all_time_spend: 5 }, ], totals: { members: 3, total_spend: 3.5, total_all_time_spend: 35, operator_spend: 0, operator_all_time_spend: 0 }, }); assert(txt("tot-members") === "2", - "old payload: gift row subtracted from the member count (got " + txt("tot-members") + ")"); + "old payload: guest row subtracted from the member count (got " + txt("tot-members") + ")"); assert(txt("tot-guests") === "1", "old payload: guest derived and counted"); assert(txt("tot-spend-cycle") === "$3.00", "old payload: guest spend excluded from the spend total (3.5 - 0.5)"); @@ -98,12 +98,12 @@ assert(document.getElementById("guest-rows").innerHTML.indexOf("friend@example.c await runLoad({ members: [memberRow("alice@example.com", 2)], guests: [ - { email: "lapsed@example.com", username: null, active: false, account_type: "gift", - gift_inviter: "alice@example.com", credit_balance: 2, credits_remaining: 2, - gift_expires_at: "2026-12-01T00:00:00", gift_status: "expired", spend: 3, all_time_spend: 3 }, - { email: "joined@example.com", username: "joined", active: true, account_type: "gift", - gift_inviter: "alice@example.com", credit_balance: 1, credits_remaining: 1, - gift_expires_at: null, gift_status: "converted", spend: 4, all_time_spend: 4 }, + { email: "lapsed@example.com", username: null, active: false, account_type: "guest", + guest_inviter: "alice@example.com", credit_balance: 2, credits_remaining: 2, + guest_expires_at: "2026-12-01T00:00:00", guest_status: "expired", spend: 3, all_time_spend: 3 }, + { email: "joined@example.com", username: "joined", active: true, account_type: "guest", + guest_inviter: "alice@example.com", credit_balance: 1, credits_remaining: 1, + guest_expires_at: null, guest_status: "converted", spend: 4, all_time_spend: 4 }, ], totals: { members: 1, total_spend: 2, total_all_time_spend: 20, operator_spend: 0, operator_all_time_spend: 0 }, diff --git a/app/main.py b/app/main.py index 373a33b..0e8699a 100644 --- a/app/main.py +++ b/app/main.py @@ -197,11 +197,11 @@ async def api_set_credits(request: Request): return JSONResponse({"error": e.detail}, status_code=e.status_code) -@app.post("/api/provision-gift") -async def api_provision_gift(request: Request): - """Provision a gift account via the portal's /admin/provision-gift. +@app.post("/api/provision-guest") +async def api_provision_guest(request: Request): + """Provision a guest account via the portal's /admin/provision-guest. - The portal enforces the abuse rules (one gift per inviter per 30 days, + The portal enforces the abuse rules (one guest access per inviter per 30 days, one per recipient ever, active-member inviter) and returns a clear refusal — surfaced to the operator as-is. """ @@ -216,7 +216,7 @@ async def api_provision_gift(request: Request): if not inviter or "@" not in inviter: return JSONResponse({"error": "The inviting member's email is required"}, status_code=400) try: - return await portal_post("/admin/provision-gift", + return await portal_post("/admin/provision-guest", {"email": email, "name": name, "inviter": inviter}) except HTTPException as e: return JSONResponse({"error": e.detail}, status_code=e.status_code) @@ -315,9 +315,9 @@ PAGE_HTML = """ .pill.manual { background: #f1e8da; color: #a97a4a; } .pill.org { background: #e7edf5; color: #4a6a8a; } .pill.grace { background: #fdf3e3; color: #a97a2a; } - .pill.gift { background: #efe7f2; color: #7a5a92; } - #gift-group input { padding: 5px 8px; border: 1px solid var(--border); border-radius: 6px; font-size: 12px; width: 170px; } - #gift-group input#gift-name { width: 120px; } + .pill.guest { background: #efe7f2; color: #7a5a92; } + #guest-group input { padding: 5px 8px; border: 1px solid var(--border); border-radius: 6px; font-size: 12px; width: 170px; } + #guest-group input#guest-name { width: 120px; } /* Trends tab (charts). Colours come from the same vars as the rest of the panel; the SVG is inline so there is no chart library and no CDN. */ .trend-controls { display: flex; gap: 22px; flex-wrap: wrap; margin: 14px 0 0; } @@ -383,7 +383,7 @@ PAGE_HTML = """