feat: add SQL query tool, platform debug, loyalty settings, and multi-module improvements
Some checks failed
Some checks failed
- 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:
@@ -46,7 +46,7 @@ def get_subscription_status(
|
||||
):
|
||||
"""Get current subscription status."""
|
||||
store_id = current_user.token_store_id
|
||||
merchant_id, platform_id = subscription_service.resolve_store_to_merchant(db, store_id)
|
||||
merchant_id, platform_id = subscription_service.resolve_store_to_merchant(db, store_id, current_user.token_platform_id)
|
||||
|
||||
subscription, tier = billing_service.get_subscription_with_tier(db, merchant_id, platform_id)
|
||||
|
||||
@@ -83,7 +83,7 @@ def get_available_tiers(
|
||||
):
|
||||
"""Get available subscription tiers for upgrade/downgrade."""
|
||||
store_id = current_user.token_store_id
|
||||
merchant_id, platform_id = subscription_service.resolve_store_to_merchant(db, store_id)
|
||||
merchant_id, platform_id = subscription_service.resolve_store_to_merchant(db, store_id, current_user.token_platform_id)
|
||||
|
||||
subscription = subscription_service.get_or_create_subscription(db, merchant_id, platform_id)
|
||||
current_tier_id = subscription.tier_id
|
||||
@@ -105,7 +105,7 @@ def get_invoices(
|
||||
):
|
||||
"""Get invoice history."""
|
||||
store_id = current_user.token_store_id
|
||||
merchant_id, platform_id = subscription_service.resolve_store_to_merchant(db, store_id)
|
||||
merchant_id, platform_id = subscription_service.resolve_store_to_merchant(db, store_id, current_user.token_platform_id)
|
||||
|
||||
invoices, total = billing_service.get_invoices(db, merchant_id, skip=skip, limit=limit)
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ def create_checkout_session(
|
||||
):
|
||||
"""Create a Stripe checkout session for subscription."""
|
||||
store_id = current_user.token_store_id
|
||||
merchant_id, platform_id = subscription_service.resolve_store_to_merchant(db, store_id)
|
||||
merchant_id, platform_id = subscription_service.resolve_store_to_merchant(db, store_id, current_user.token_platform_id)
|
||||
|
||||
store_code = subscription_service.get_store_code(db, store_id)
|
||||
|
||||
@@ -84,7 +84,7 @@ def create_portal_session(
|
||||
):
|
||||
"""Create a Stripe customer portal session."""
|
||||
store_id = current_user.token_store_id
|
||||
merchant_id, platform_id = subscription_service.resolve_store_to_merchant(db, store_id)
|
||||
merchant_id, platform_id = subscription_service.resolve_store_to_merchant(db, store_id, current_user.token_platform_id)
|
||||
|
||||
store_code = subscription_service.get_store_code(db, store_id)
|
||||
return_url = f"https://{settings.platform_domain}/store/{store_code}/billing"
|
||||
@@ -102,7 +102,7 @@ def cancel_subscription(
|
||||
):
|
||||
"""Cancel subscription."""
|
||||
store_id = current_user.token_store_id
|
||||
merchant_id, platform_id = subscription_service.resolve_store_to_merchant(db, store_id)
|
||||
merchant_id, platform_id = subscription_service.resolve_store_to_merchant(db, store_id, current_user.token_platform_id)
|
||||
|
||||
result = billing_service.cancel_subscription(
|
||||
db=db,
|
||||
@@ -126,7 +126,7 @@ def reactivate_subscription(
|
||||
):
|
||||
"""Reactivate a cancelled subscription."""
|
||||
store_id = current_user.token_store_id
|
||||
merchant_id, platform_id = subscription_service.resolve_store_to_merchant(db, store_id)
|
||||
merchant_id, platform_id = subscription_service.resolve_store_to_merchant(db, store_id, current_user.token_platform_id)
|
||||
|
||||
result = billing_service.reactivate_subscription(db, merchant_id, platform_id)
|
||||
db.commit()
|
||||
@@ -141,7 +141,7 @@ def get_upcoming_invoice(
|
||||
):
|
||||
"""Preview the upcoming invoice."""
|
||||
store_id = current_user.token_store_id
|
||||
merchant_id, platform_id = subscription_service.resolve_store_to_merchant(db, store_id)
|
||||
merchant_id, platform_id = subscription_service.resolve_store_to_merchant(db, store_id, current_user.token_platform_id)
|
||||
|
||||
result = billing_service.get_upcoming_invoice(db, merchant_id, platform_id)
|
||||
|
||||
@@ -161,7 +161,7 @@ def change_tier(
|
||||
):
|
||||
"""Change subscription tier (upgrade/downgrade)."""
|
||||
store_id = current_user.token_store_id
|
||||
merchant_id, platform_id = subscription_service.resolve_store_to_merchant(db, store_id)
|
||||
merchant_id, platform_id = subscription_service.resolve_store_to_merchant(db, store_id, current_user.token_platform_id)
|
||||
|
||||
result = billing_service.change_tier(
|
||||
db=db,
|
||||
|
||||
@@ -95,7 +95,7 @@ def get_available_features(
|
||||
List of feature codes the store has access to
|
||||
"""
|
||||
store_id = current_user.token_store_id
|
||||
merchant_id, platform_id = subscription_service.resolve_store_to_merchant(db, store_id)
|
||||
merchant_id, platform_id = subscription_service.resolve_store_to_merchant(db, store_id, current_user.token_platform_id)
|
||||
|
||||
# Get available feature codes
|
||||
feature_codes = feature_service.get_merchant_feature_codes(db, merchant_id, platform_id)
|
||||
@@ -134,7 +134,7 @@ def get_features(
|
||||
List of features with metadata and availability
|
||||
"""
|
||||
store_id = current_user.token_store_id
|
||||
merchant_id, platform_id = subscription_service.resolve_store_to_merchant(db, store_id)
|
||||
merchant_id, platform_id = subscription_service.resolve_store_to_merchant(db, store_id, current_user.token_platform_id)
|
||||
|
||||
# Get all declarations and available codes
|
||||
all_declarations = feature_aggregator.get_all_declarations()
|
||||
@@ -197,7 +197,7 @@ def get_features_grouped(
|
||||
Useful for rendering feature comparison tables or settings pages.
|
||||
"""
|
||||
store_id = current_user.token_store_id
|
||||
merchant_id, platform_id = subscription_service.resolve_store_to_merchant(db, store_id)
|
||||
merchant_id, platform_id = subscription_service.resolve_store_to_merchant(db, store_id, current_user.token_platform_id)
|
||||
|
||||
# Get declarations grouped by category and available codes
|
||||
by_category = feature_aggregator.get_declarations_by_category()
|
||||
@@ -246,7 +246,9 @@ def check_feature(
|
||||
has_feature and feature_code
|
||||
"""
|
||||
store_id = current_user.token_store_id
|
||||
has = feature_service.has_feature_for_store(db, store_id, feature_code)
|
||||
has = feature_service.has_feature_for_store(
|
||||
db, store_id, feature_code, platform_id=current_user.token_platform_id
|
||||
)
|
||||
|
||||
return StoreFeatureCheckResponse(has_feature=has, feature_code=feature_code)
|
||||
|
||||
@@ -270,7 +272,7 @@ def get_feature_detail(
|
||||
Feature details with upgrade info if locked
|
||||
"""
|
||||
store_id = current_user.token_store_id
|
||||
merchant_id, platform_id = subscription_service.resolve_store_to_merchant(db, store_id)
|
||||
merchant_id, platform_id = subscription_service.resolve_store_to_merchant(db, store_id, current_user.token_platform_id)
|
||||
|
||||
# Get feature declaration
|
||||
decl = feature_aggregator.get_declaration(feature_code)
|
||||
|
||||
Reference in New Issue
Block a user