Sfoglia il codice sorgente

refactor: Move get_build_version to utils.py

version-14
Suraj Shetty 4 anni fa
parent
commit
01312889f8
2 ha cambiato i file con 9 aggiunte e 9 eliminazioni
  1. +8
    -0
      frappe/utils/__init__.py
  2. +1
    -9
      frappe/www/desk.py

+ 8
- 0
frappe/utils/__init__.py Vedi File

@@ -721,3 +721,11 @@ def get_file_size(path, format=False):
num /= 1024 num /= 1024


return "{0:.1f}{1}{2}".format(num, 'Yi', suffix) return "{0:.1f}{1}{2}".format(num, 'Yi', suffix)

def get_build_version():
try:
return str(os.path.getmtime(os.path.join(frappe.local.sites_path, '.build')))
except OSError:
# .build can sometimes not exist
# this is not a major problem so send fallback
return frappe.utils.random_string(8)

+ 1
- 9
frappe/www/desk.py Vedi File

@@ -36,7 +36,7 @@ def get_context(context):


context.update({ context.update({
"no_cache": 1, "no_cache": 1,
"build_version": get_build_version(),
"build_version": frappe.utils.get_build_version(),
"include_js": hooks["app_include_js"], "include_js": hooks["app_include_js"],
"include_css": hooks["app_include_css"], "include_css": hooks["app_include_css"],
"sounds": hooks["sounds"], "sounds": hooks["sounds"],
@@ -82,11 +82,3 @@ def get_desk_assets(build_version):
"boot": data["boot"], "boot": data["boot"],
"assets": assets "assets": assets
} }

def get_build_version():
try:
return str(os.path.getmtime(os.path.join(frappe.local.sites_path, '.build')))
except OSError:
# .build can sometimes not exist
# this is not a major problem so send fallback
return frappe.utils.random_string(8)

Caricamento…
Annulla
Salva