fix: check country from ip for multicurrency

This commit is contained in:
Jannat Patel
2023-12-21 14:22:58 +05:30
parent 4973386dd0
commit f40fbaed3e
2 changed files with 16 additions and 15 deletions

View File

@@ -5,7 +5,7 @@ from frappe import _
from frappe.core.doctype.user.user import User
from frappe.utils import cint, escape_html, random_string
from frappe.website.utils import is_signup_disabled
from lms.lms.utils import get_average_rating
from lms.lms.utils import get_average_rating, get_country_code
from frappe.website.utils import cleanup_page_name
from frappe.model.naming import append_number_if_name_exists
from lms.widgets import Widgets
@@ -260,19 +260,6 @@ def set_country_from_ip(login_manager=None, user=None):
return
def get_country_code():
ip = frappe.local.request_ip
res = requests.get(f"http://ip-api.com/json/{ip}")
try:
data = res.json()
if data.get("status") != "fail":
return frappe.db.get_value("Country", {"code": data.get("countryCode")}, "name")
except Exception:
pass
return
def on_session_creation(login_manager):
if frappe.db.get_single_value(
"System Settings", "setup_complete"