refactor: make payments app a soft dependency (backport #33245) (#33677)

refactor: make payments app a soft dependency (#33245)

refactor: make payment app a soft dependency
(cherry picked from commit 0b86b1baca)

Co-authored-by: Ankush Menat <ankush@frappe.io>
This commit is contained in:
mergify[bot]
2023-01-18 21:11:37 +05:30
committed by GitHub
parent 0d46ec2640
commit 9bc2675493
14 changed files with 74 additions and 13 deletions

View File

@@ -1,6 +1,9 @@
## temp utility
from contextlib import contextmanager
import frappe
from frappe import _
from frappe.utils import cstr
from erpnext.utilities.activation import get_level
@@ -35,3 +38,16 @@ def get_site_info(site_info):
domain = frappe.get_cached_value("Company", cstr(company), "domain")
return {"company": company, "domain": domain, "activation": get_level()}
@contextmanager
def payment_app_import_guard():
marketplace_link = '<a href="https://frappecloud.com/marketplace/apps/payments">Marketplace</a>'
github_link = '<a href="https://github.com/frappe/payments/">GitHub</a>'
msg = _("payments app is not installed. Please install it from {} or {}").format(
marketplace_link, github_link
)
try:
yield
except ImportError:
frappe.throw(msg, title=_("Missing Payments App"))