chore: rename timezone keys
This commit is contained in:
parent
87b1e9af00
commit
1f70c27e9f
6 changed files with 26 additions and 28 deletions
|
|
@ -329,6 +329,6 @@ def get_notification_settings():
|
|||
|
||||
def set_time_zone(bootinfo):
|
||||
bootinfo.time_zone = {
|
||||
"system_time_zone": get_time_zone(),
|
||||
"user_time_zone": bootinfo.get("user_info", {}).get(frappe.session.user, {}).get("time_zone", None) or get_time_zone()
|
||||
"system": get_time_zone(),
|
||||
"user": bootinfo.get("user_info", {}).get(frappe.session.user, {}).get("time_zone", None) or get_time_zone()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,9 +34,7 @@ frappe.ui.form.on("System Settings", {
|
|||
}
|
||||
},
|
||||
after_save: function(frm) {
|
||||
if (frappe.boot.time_zone && frappe.boot.time_zone.system_time_zone !== frm.doc.time_zone) {
|
||||
// Clear cache after saving to refresh the values of time_zone
|
||||
frappe.ui.toolbar.clear_cache();
|
||||
}
|
||||
// Clear cache after saving to refresh the values of boot.
|
||||
frappe.ui.toolbar.clear_cache();
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -274,10 +274,8 @@ frappe.ui.form.on('User', {
|
|||
});
|
||||
},
|
||||
after_save: function(frm) {
|
||||
if (frappe.boot.time_zone && frappe.boot.time_zone.user_time_zone !== frm.doc.time_zone) {
|
||||
// Clear cache after saving to refresh the values of time_zone
|
||||
frappe.ui.toolbar.clear_cache();
|
||||
}
|
||||
// Clear cache after saving to refresh the values of boot.
|
||||
frappe.ui.toolbar.clear_cache();
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import frappe.defaults
|
|||
import frappe.permissions
|
||||
from frappe.model.document import Document
|
||||
from frappe.utils import (cint, flt, has_gravatar, escape_html, format_datetime,
|
||||
now_datetime, get_formatted_email, today)
|
||||
now_datetime, get_formatted_email, today, get_time_zone)
|
||||
from frappe import throw, msgprint, _
|
||||
from frappe.utils.password import update_password as _update_password, check_password, get_password_reset_limit
|
||||
from frappe.desk.notifications import clear_notifications
|
||||
|
|
@ -231,11 +231,11 @@ class User(Document):
|
|||
def validate_share(self, docshare):
|
||||
pass
|
||||
# if docshare.user == self.name:
|
||||
# if self.user_type=="System User":
|
||||
# if docshare.share != 1:
|
||||
# frappe.throw(_("Sorry! User should have complete access to their own record."))
|
||||
# else:
|
||||
# frappe.throw(_("Sorry! Sharing with Website User is prohibited."))
|
||||
# if self.user_type=="System User":
|
||||
# if docshare.share != 1:
|
||||
# frappe.throw(_("Sorry! User should have complete access to their own record."))
|
||||
# else:
|
||||
# frappe.throw(_("Sorry! Sharing with Website User is prohibited."))
|
||||
|
||||
def send_password_notification(self, new_password):
|
||||
try:
|
||||
|
|
@ -592,8 +592,6 @@ class User(Document):
|
|||
return user
|
||||
|
||||
def set_time_zone(self):
|
||||
from frappe.utils import get_time_zone
|
||||
|
||||
if not self.time_zone:
|
||||
self.time_zone = get_time_zone()
|
||||
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ frappe.ui.form.ControlDatetime = class ControlDatetime extends frappe.ui.form.Co
|
|||
super.set_description();
|
||||
}
|
||||
get_user_time_zone() {
|
||||
return frappe.boot.time_zone ? frappe.boot.time_zone.user_time_zone : frappe.sys_defaults.time_zone;
|
||||
return frappe.boot.time_zone ? frappe.boot.time_zone.user : frappe.sys_defaults.time_zone;
|
||||
}
|
||||
set_datepicker() {
|
||||
super.set_datepicker();
|
||||
|
|
|
|||
|
|
@ -16,10 +16,10 @@ $.extend(frappe.datetime, {
|
|||
// Converts the datetime string to system time zone first since the database only stores datetime in
|
||||
// system time zone and then convert the string to user time zone(from User doctype).
|
||||
let date_obj = null;
|
||||
if (frappe.boot.time_zone && frappe.boot.time_zone.system_time_zone && frappe.boot.time_zone.user_time_zone) {
|
||||
date_obj = moment.tz(date, frappe.boot.time_zone.system_time_zone)
|
||||
if (frappe.boot.time_zone && frappe.boot.time_zone.system && frappe.boot.time_zone.user) {
|
||||
date_obj = moment.tz(date, frappe.boot.time_zone.system)
|
||||
.clone()
|
||||
.tz(frappe.boot.time_zone.user_time_zone);
|
||||
.tz(frappe.boot.time_zone.user);
|
||||
} else {
|
||||
date_obj = moment(date);
|
||||
}
|
||||
|
|
@ -34,10 +34,10 @@ $.extend(frappe.datetime, {
|
|||
// This is done so that only one timezone is present in database and we do not end up storing local timezone since it changes
|
||||
// as per the location of user.
|
||||
let date_obj = null;
|
||||
if (frappe.boot.time_zone && frappe.boot.time_zone.system_time_zone && frappe.boot.time_zone.user_time_zone) {
|
||||
date_obj = moment.tz(date, frappe.boot.time_zone.user_time_zone)
|
||||
if (frappe.boot.time_zone && frappe.boot.time_zone.system && frappe.boot.time_zone.user) {
|
||||
date_obj = moment.tz(date, frappe.boot.time_zone.user)
|
||||
.clone()
|
||||
.tz(frappe.boot.time_zone.system_time_zone);
|
||||
.tz(frappe.boot.time_zone.system);
|
||||
} else {
|
||||
date_obj = moment(date);
|
||||
}
|
||||
|
|
@ -46,13 +46,17 @@ $.extend(frappe.datetime, {
|
|||
},
|
||||
|
||||
is_system_time_zone: function() {
|
||||
if (frappe.boot.time_zone && frappe.boot.time_zone.system_time_zone && frappe.boot.time_zone.user_time_zone) {
|
||||
return moment().tz(frappe.boot.time_zone.system_time_zone).utcOffset() === moment().tz(frappe.boot.time_zone.user_time_zone).utcOffset();
|
||||
if (frappe.boot.time_zone && frappe.boot.time_zone.system && frappe.boot.time_zone.user) {
|
||||
return moment().tz(frappe.boot.time_zone.system).utcOffset() === moment().tz(frappe.boot.time_zone.user).utcOffset();
|
||||
}
|
||||
|
||||
return true;
|
||||
},
|
||||
|
||||
is_timezone_same: function() {
|
||||
return frappe.datetime.is_system_time_zone();
|
||||
},
|
||||
|
||||
str_to_obj: function(d) {
|
||||
return moment(d, frappe.defaultDatetimeFormat)._d;
|
||||
},
|
||||
|
|
@ -204,7 +208,7 @@ $.extend(frappe.datetime, {
|
|||
* This will make sure that at any point we know which timezone the user if following and not have random timezone
|
||||
* when the timezone of the local machine changes.
|
||||
*/
|
||||
let time_zone = frappe.boot.time_zone ? frappe.boot.time_zone.user_time_zone || frappe.boot.time_zone.system_time_zone : frappe.sys_defaults.time_zone;
|
||||
let time_zone = frappe.boot.time_zone ? frappe.boot.time_zone.user || frappe.boot.time_zone.system : frappe.sys_defaults.time_zone;
|
||||
let date = moment.tz(time_zone);
|
||||
|
||||
return as_obj ? frappe.datetime.moment_to_date_obj(date) : date.format(format);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue