feat: add SQL query tool, platform debug, loyalty settings, and multi-module improvements
Some checks failed
CI / ruff (push) Successful in 14s
CI / pytest (push) Failing after 50m12s
CI / validate (push) Successful in 25s
CI / dependency-scanning (push) Successful in 32s
CI / docs (push) Has been skipped
CI / deploy (push) Has been skipped

- Add admin SQL query tool with saved queries, schema explorer presets,
  and collapsible category sections (dev_tools module)
- Add platform debug tool for admin diagnostics
- Add loyalty settings page with owner-only access control
- Fix loyalty settings owner check (use currentUser instead of window.__userData)
- Replace HTTPException with AuthorizationException in loyalty routes
- Expand loyalty module with PIN service, Apple Wallet, program management
- Improve store login with platform detection and multi-platform support
- Update billing feature gates and subscription services
- Add store platform sync improvements and remove is_primary column
- Add unit tests for loyalty (PIN, points, stamps, program services)
- Update i18n translations across dev_tools locales

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-10 20:08:07 +01:00
parent a77a8a3a98
commit 319900623a
77 changed files with 5341 additions and 401 deletions

View File

@@ -64,20 +64,36 @@ async def store_login_page(
"""
Render store login page.
If user is already authenticated as store, redirect to dashboard.
Otherwise, show login form.
If user is already authenticated on the SAME platform, redirect to dashboard.
If authenticated on a DIFFERENT platform, show login form so the user can
re-login with the correct platform context.
"""
if current_user:
return RedirectResponse(
url=f"/store/{store_code}/dashboard", status_code=302
)
language = getattr(request.state, "language", "fr")
platform = getattr(request.state, "platform", None)
platform_code = platform.code if platform else None
if current_user:
# If the URL's platform matches the JWT's platform (or no platform in URL),
# redirect to dashboard. Otherwise, show login form for platform switch.
jwt_platform = current_user.token_platform_code
same_platform = (
platform_code is None
or jwt_platform is None
or platform_code == jwt_platform
)
if same_platform:
if platform_code:
redirect_url = f"/platforms/{platform_code}/store/{store_code}/dashboard"
else:
redirect_url = f"/store/{store_code}/dashboard"
return RedirectResponse(url=redirect_url, status_code=302)
return templates.TemplateResponse(
"tenancy/store/login.html",
{
"request": request,
"store_code": store_code,
"platform_code": platform_code,
**get_jinja2_globals(language),
},
)