Skip to content

Commit

Permalink
Merge pull request frappe#480 from shariquerik/get_sysdefaults
Browse files Browse the repository at this point in the history
fix: get all system defaults
  • Loading branch information
shariquerik authored Dec 19, 2024
2 parents d62850b + 908299d commit f27d4ba
Showing 1 changed file with 27 additions and 40 deletions.
67 changes: 27 additions & 40 deletions crm/www/crm.py
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"

0 comments on commit f27d4ba

Please sign in to comment.