<s> from __future__ import unicode_literals <EOL> import frappe <EOL> from frappe import _ <EOL> from frappe . model . document import Document <EOL> from frappe . model import no_value_fields <EOL> from frappe . translate import set_default_language <EOL> from frappe . utils import cint <EOL> from frappe . utils . momentjs import get_all_timezones <EOL> class SystemSettings ( Document ) : <EOL> def validate ( self ) : <EOL> for key in ( "<STR_LIT>" , "<STR_LIT>" ) : <EOL> if self . get ( key ) : <EOL> parts = self . get ( key ) . split ( "<STR_LIT::>" ) <EOL> if len ( parts ) != <NUM_LIT:2> or not ( cint ( parts [ <NUM_LIT:0> ] ) or cint ( parts [ <NUM_LIT:1> ] ) ) : <EOL> frappe . throw ( _ ( "<STR_LIT>" ) . format ( "<STR_LIT>" ) ) <EOL> def on_update ( self ) : <EOL> for df in self . meta . get ( "<STR_LIT>" ) : <EOL> if df . fieldtype not in no_value_fields : <EOL> frappe . db . set_default ( df . fieldname , self . get ( df . fieldname ) ) <EOL> if self . language : <EOL> set_default_language ( self . language ) <EOL> @ frappe . whitelist ( ) <EOL> def load ( ) : <EOL> if not "<STR_LIT>" in frappe . get_roles ( ) : <EOL> frappe . throw ( _ ( "<STR_LIT>" ) , frappe . PermissionError ) <EOL> all_defaults = frappe . db . get_defaults ( ) <EOL> defaults = { } <EOL> for df in frappe . get_meta ( "<STR_LIT>" ) . get ( "<STR_LIT>" ) : <EOL> if df . fieldtype in ( "<STR_LIT>" , "<STR_LIT>" ) : <EOL> defaults [ df . fieldname ] = all_defaults . get ( df . fieldname ) <EOL> return { <EOL> "<STR_LIT>" : get_all_timezones ( ) , <EOL> "<STR_LIT>" : defaults <EOL> } </s>
