forked from frappe/crm
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request frappe#480 from shariquerik/get_sysdefaults
fix: get all system defaults
- Loading branch information
Showing
1 changed file
with
27 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,61 +1,48 @@ | ||
# Copyright (c) 2022, Frappe Technologies Pvt. Ltd. and Contributors | ||
# GNU GPLv3 License. See license.txt | ||
|
||
from __future__ import unicode_literals | ||
|
||
import frappe | ||
from frappe.utils import cint, get_system_timezone | ||
from frappe.utils.telemetry import capture | ||
from frappe.locale import ( | ||
get_date_format, | ||
get_first_day_of_the_week, | ||
get_number_format, | ||
get_time_format, | ||
) | ||
|
||
no_cache = 1 | ||
|
||
|
||
def get_context(): | ||
frappe.db.commit() | ||
context = frappe._dict() | ||
context.boot = get_boot() | ||
if frappe.session.user != "Guest": | ||
capture("active_site", "crm") | ||
return context | ||
frappe.db.commit() | ||
context = frappe._dict() | ||
context.boot = get_boot() | ||
if frappe.session.user != "Guest": | ||
capture("active_site", "crm") | ||
return context | ||
|
||
|
||
@frappe.whitelist(methods=["POST"], allow_guest=True) | ||
def get_context_for_dev(): | ||
if not frappe.conf.developer_mode: | ||
frappe.throw("This method is only meant for developer mode") | ||
return get_boot() | ||
if not frappe.conf.developer_mode: | ||
frappe.throw("This method is only meant for developer mode") | ||
return get_boot() | ||
|
||
|
||
def get_boot(): | ||
return frappe._dict( | ||
{ | ||
"frappe_version": frappe.__version__, | ||
"default_route": get_default_route(), | ||
"site_name": frappe.local.site, | ||
"read_only_mode": frappe.flags.read_only, | ||
"csrf_token": frappe.sessions.get_csrf_token(), | ||
"setup_complete": cint(frappe.get_system_settings("setup_complete")), | ||
"sysdefaults": { | ||
"float_precision": cint(frappe.get_system_settings("float_precision")) | ||
or 3, | ||
"date_format": get_date_format(), | ||
"time_format": get_time_format(), | ||
"first_day_of_the_week": get_first_day_of_the_week(), | ||
"number_format": get_number_format().string, | ||
}, | ||
"timezone": { | ||
"system": get_system_timezone(), | ||
"user": frappe.db.get_value("User", frappe.session.user, "time_zone") | ||
or get_system_timezone(), | ||
}, | ||
} | ||
) | ||
return frappe._dict( | ||
{ | ||
"frappe_version": frappe.__version__, | ||
"default_route": get_default_route(), | ||
"site_name": frappe.local.site, | ||
"read_only_mode": frappe.flags.read_only, | ||
"csrf_token": frappe.sessions.get_csrf_token(), | ||
"setup_complete": cint(frappe.get_system_settings("setup_complete")), | ||
"sysdefaults": frappe.defaults.get_defaults(), | ||
"timezone": { | ||
"system": get_system_timezone(), | ||
"user": frappe.db.get_value("User", frappe.session.user, "time_zone") | ||
or get_system_timezone(), | ||
}, | ||
} | ||
) | ||
|
||
|
||
def get_default_route(): | ||
return "/crm" | ||
return "/crm" |