Respect disabled payments in launch validation
This commit is contained in:
@@ -44,12 +44,23 @@ def get_checkout_apps() -> list[str]:
|
|||||||
return [app for app in settings.INSTALLED_APPS if "checkout" in app.lower()]
|
return [app for app in settings.INSTALLED_APPS if "checkout" in app.lower()]
|
||||||
|
|
||||||
|
|
||||||
|
def idea_marketplace_payments_enabled() -> bool:
|
||||||
|
return bool(getattr(settings, "IDEA_MARKETPLACE_PAYMENTS_ENABLED", False))
|
||||||
|
|
||||||
|
|
||||||
def validate_payment_provider_config() -> None:
|
def validate_payment_provider_config() -> None:
|
||||||
installed_apps = list(settings.INSTALLED_APPS)
|
installed_apps = list(settings.INSTALLED_APPS)
|
||||||
payment_apps = get_declared_payment_apps(installed_apps)
|
payment_apps = get_declared_payment_apps(installed_apps)
|
||||||
checkout_apps = get_checkout_apps()
|
checkout_apps = get_checkout_apps()
|
||||||
config_plugins = get_declared_plugins()
|
config_plugins = get_declared_plugins()
|
||||||
|
|
||||||
|
if not idea_marketplace_payments_enabled():
|
||||||
|
if any(_is_dummy_payment_app(app) for app in config_plugins):
|
||||||
|
raise CommandError(
|
||||||
|
"Dummy payment app is declared in ocyan.json. Remove it even when payments are disabled."
|
||||||
|
)
|
||||||
|
return
|
||||||
|
|
||||||
if not payment_apps:
|
if not payment_apps:
|
||||||
raise CommandError("No payment app declared for this project.")
|
raise CommandError("No payment app declared for this project.")
|
||||||
if not checkout_apps:
|
if not checkout_apps:
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ from mandelstudio.idea_marketplace import (
|
|||||||
from mandelstudio.launch_validation import (
|
from mandelstudio.launch_validation import (
|
||||||
get_checkout_apps,
|
get_checkout_apps,
|
||||||
get_declared_payment_apps,
|
get_declared_payment_apps,
|
||||||
|
idea_marketplace_payments_enabled,
|
||||||
validate_payment_provider_config,
|
validate_payment_provider_config,
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -39,6 +40,7 @@ class Command(BaseCommand):
|
|||||||
validate_payment_provider_config()
|
validate_payment_provider_config()
|
||||||
|
|
||||||
installed_apps = list(settings.INSTALLED_APPS)
|
installed_apps = list(settings.INSTALLED_APPS)
|
||||||
|
payments_enabled = idea_marketplace_payments_enabled()
|
||||||
payment_apps = get_declared_payment_apps(installed_apps)
|
payment_apps = get_declared_payment_apps(installed_apps)
|
||||||
checkout_apps = get_checkout_apps()
|
checkout_apps = get_checkout_apps()
|
||||||
config_path = Path(__file__).resolve().parents[2] / "ocyan.json"
|
config_path = Path(__file__).resolve().parents[2] / "ocyan.json"
|
||||||
@@ -195,6 +197,6 @@ class Command(BaseCommand):
|
|||||||
self.style.SUCCESS(
|
self.style.SUCCESS(
|
||||||
"Idea marketplace launch validation passed: "
|
"Idea marketplace launch validation passed: "
|
||||||
f"{len(found_titles)} products, EUR currency, checkout apps={checkout_apps}, "
|
f"{len(found_titles)} products, EUR currency, checkout apps={checkout_apps}, "
|
||||||
f"payment apps={payment_apps}."
|
f"payment apps={payment_apps}, payments_enabled={payments_enabled}."
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user