seitime-frappe/frappe/utils/subscription.py
Aditya Hase 6f8a087c5f
fix(subscription): Allow remote_login even if subscription.expiry is not set
remote_login is used for the "Subscribe" banner as well as the Manage Subscription button.
2022-12-26 14:18:58 +05:30

35 lines
701 B
Python

import json
import requests
import frappe
@frappe.whitelist()
def remote_login():
try:
login_url = frappe.conf.subscription["login_url"]
if login_url:
resp = requests.post(login_url)
if resp.status_code != 200:
return
return json.loads(resp.text)["message"]
except Exception:
return False
return False
def enable_manage_subscription():
if not frappe.db.exists("Navbar Item", {"item_label": "Manage Subscriptions"}):
return
navbar_item, hidden = frappe.db.get_value(
"Navbar Item", {"item_label": "Manage Subscriptions"}, ["name", "hidden"]
)
if navbar_item and hidden:
doc = frappe.get_cached_doc("Navbar Item", navbar_item)
doc.hidden = False
doc.save()