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

@@ -164,7 +164,34 @@ class LoyaltyFeatureProvider:
db: Session,
store_id: int,
) -> list[FeatureUsage]:
return []
from sqlalchemy import func
from app.modules.loyalty.models import LoyaltyCard, StaffPin
active_cards = (
db.query(func.count(LoyaltyCard.id))
.filter(
LoyaltyCard.enrolled_at_store_id == store_id,
LoyaltyCard.is_active == True,
)
.scalar()
or 0
)
active_pins = (
db.query(func.count(StaffPin.id))
.filter(
StaffPin.store_id == store_id,
StaffPin.is_active == True,
)
.scalar()
or 0
)
return [
FeatureUsage(feature_code="loyalty_cards", current_usage=active_cards),
FeatureUsage(feature_code="loyalty_staff_pins", current_usage=active_pins),
]
def get_merchant_usage(
self,
@@ -172,7 +199,58 @@ class LoyaltyFeatureProvider:
merchant_id: int,
platform_id: int,
) -> list[FeatureUsage]:
return []
from sqlalchemy import func
from app.modules.loyalty.models import (
AppleDeviceRegistration,
LoyaltyCard,
StaffPin,
)
active_cards = (
db.query(func.count(LoyaltyCard.id))
.filter(
LoyaltyCard.merchant_id == merchant_id,
LoyaltyCard.is_active == True,
)
.scalar()
or 0
)
active_pins = (
db.query(func.count(StaffPin.id))
.filter(
StaffPin.merchant_id == merchant_id,
StaffPin.is_active == True,
)
.scalar()
or 0
)
apple_registrations = (
db.query(func.count(AppleDeviceRegistration.id))
.join(LoyaltyCard)
.filter(LoyaltyCard.merchant_id == merchant_id)
.scalar()
or 0
)
google_wallets = (
db.query(func.count(LoyaltyCard.id))
.filter(
LoyaltyCard.merchant_id == merchant_id,
LoyaltyCard.google_object_id.isnot(None),
)
.scalar()
or 0
)
return [
FeatureUsage(feature_code="loyalty_cards", current_usage=active_cards),
FeatureUsage(feature_code="loyalty_staff_pins", current_usage=active_pins),
FeatureUsage(feature_code="loyalty_apple_wallet", current_usage=apple_registrations),
FeatureUsage(feature_code="loyalty_google_wallet", current_usage=google_wallets),
]
# Singleton instance for module registration