feat(loyalty): add dedicated program edit page with full CRUD and tests
Some checks failed
CI / ruff (push) Successful in 9s
CI / validate (push) Has been cancelled
CI / dependency-scanning (push) Has been cancelled
CI / docs (push) Has been cancelled
CI / deploy (push) Has been cancelled
CI / pytest (push) Has started running

Add /admin/loyalty/merchants/{id}/program route for program configuration
with a dedicated Alpine.js edit page supporting create/edit/delete flows.
Restructure programs dashboard with create modal (merchant search +
duplicate detection) and delete confirmation. Rename "Loyalty Settings"
to "Admin Policy" for clearer separation of concerns.

Add integration tests for all admin page routes (12 tests) and program
list search/filter/pagination endpoints (9 tests).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-25 23:25:22 +01:00
parent 6b46a78e72
commit f1e7baaa6c
9 changed files with 1056 additions and 13 deletions

View File

@@ -99,6 +99,31 @@ async def admin_loyalty_merchant_detail(
)
@router.get(
"/merchants/{merchant_id}/program",
response_class=HTMLResponse,
include_in_schema=False,
)
async def admin_loyalty_program_edit(
request: Request,
merchant_id: int = Path(..., description="Merchant ID"),
current_user: User = Depends(require_menu_access("loyalty-programs", FrontendType.ADMIN)),
db: Session = Depends(get_db),
):
"""
Render program configuration edit page for a merchant.
Allows admin to create or edit the merchant's loyalty program settings.
"""
return templates.TemplateResponse(
"loyalty/admin/program-edit.html",
{
"request": request,
"user": current_user,
"merchant_id": merchant_id,
},
)
@router.get(
"/merchants/{merchant_id}/settings",
response_class=HTMLResponse,