Explorar el Código

added number format, sent country info in boot, link options not extracted from cache

version-14
Rushabh Mehta hace 12 años
padre
commit
42be20de56
Se han modificado 6 ficheros con 894 adiciones y 575 borrados
  1. +2
    -1
      core/doctype/customize_form/customize_form.js
  2. +7
    -0
      webnotes/boot.py
  3. +852
    -567
      webnotes/country_info.json
  4. +14
    -0
      webnotes/country_info.py
  5. +12
    -5
      webnotes/db.py
  6. +7
    -2
      webnotes/model/doctype.py

+ 2
- 1
core/doctype/customize_form/customize_form.js Ver fichero

@@ -35,7 +35,8 @@ cur_frm.fields_dict.doc_type.get_query = function(doc, dt, dn) {
return 'SELECT name FROM `tabDocType` \
WHERE IFNULL(issingle,0)=0 AND \
IFNULL(in_create, 0)=0 AND \
module != "Core" AND \
name not in ("DocType", "DocField", "DocPerm", "Profile", "Role", "UserRole", "Page", \
"Page Role", "Module Def", "Print Format", "Report", "Search Criteria") AND \
name LIKE "%s%%" ORDER BY name ASC LIMIT 50';
}



+ 7
- 0
webnotes/boot.py Ver fichero

@@ -55,6 +55,7 @@ def get_bootinfo():
add_home_page(bootinfo, doclist)
add_allowed_pages(bootinfo)
load_translations(bootinfo)
load_country_and_currency(bootinfo, doclist)

# ipinfo
if webnotes.session['data'].get('ipinfo'):
@@ -77,6 +78,12 @@ def get_bootinfo():
return bootinfo

def load_country_and_currency(bootinfo, doclist):
country_doc = webnotes.doc("Country", bootinfo.sysdefaults.country)
doclist += [country_doc]
if country_doc.currency:
doclist += [webnotes.doc("Currency", country_doc.currency)]

def add_allowed_pages(bootinfo):
bootinfo.allowed_pages = [p[0] for p in webnotes.conn.sql("""select distinct parent from `tabPage Role`
where role in ('%s')""" % "', '".join(webnotes.get_roles()))]


+ 852
- 567
webnotes/country_info.json
La diferencia del archivo ha sido suprimido porque es demasiado grande
Ver fichero


+ 14
- 0
webnotes/country_info.py Ver fichero

@@ -17,4 +17,18 @@ def get_all():
all_data = json.loads(local_info.read())
return all_data

def update():
with open(os.path.join(os.path.dirname(__file__), "currency_info.json"), "r") as nformats:
nformats = json.loads(nformats.read())
all_data = get_all()
for country in all_data:
data = all_data[country]
data["number_format"] = nformats.get(data.get("currency", "default"),
nformats.get("default"))["display"]
print all_data
with open(os.path.join(os.path.dirname(__file__), "country_info.json"), "w") as local_info:
local_info.write(json.dumps(all_data, indent=1))

+ 12
- 5
webnotes/db.py Ver fichero

@@ -339,11 +339,18 @@ class Database:
return self.get_default(key, parent)
else:
res = self.sql("""select defkey, defvalue from `tabDefaultValue`
where parent = %s""", parent)
d = {}
for rec in res:
d[rec[0]] = rec[1] or ''
return d
where parent = %s""", parent, as_dict=1)
defaults = webnotes._dict({})
for d in res:
if d.defkey in defaults:
# listify
if isinstance(defaults[d.defkey], basestring):
defaults[d.defkey] = [defaults[d.defkey]]
defaults[d.defkey].append(d.defvalue)
else:
defaults[d.defkey] = d.defvalue

return defaults

def begin(self):
if not self.in_transaction:


+ 7
- 2
webnotes/model/doctype.py Ver fichero

@@ -46,7 +46,10 @@ def get(doctype, processed=False, cached=True):
"""return doclist"""
if cached:
doclist = from_cache(doctype, processed)
if doclist: return DocTypeDocList(doclist)
if doclist:
if processed:
add_linked_with(doclist)
return DocTypeDocList(doclist)
load_docfield_types()
@@ -65,7 +68,6 @@ def get(doctype, processed=False, cached=True):
expand_selects(doclist)
add_print_formats(doclist)
add_search_fields(doclist)
add_linked_with(doclist)
add_workflows(doclist)
update_language(doclist)

@@ -76,6 +78,9 @@ def get(doctype, processed=False, cached=True):
add_precision(doctype, doclist)

to_cache(doctype, processed, doclist)

if processed:
add_linked_with(doclist)
return DocTypeDocList(doclist)



Cargando…
Cancelar
Guardar