Refactored plugin architecture to allow custom script reports

This commit is contained in:
Anand Doshi 2013-11-06 14:19:09 +05:30
parent 3bed5abc76
commit 8728f26442
3 changed files with 27 additions and 2 deletions

View File

@ -0,0 +1,24 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import webnotes, os, shutil
def execute():
# changed cache key for plugin code files
for doctype in webnotes.conn.sql_list("""select name from `tabDocType`"""):
webnotes.cache().delete_value("_server_script:"+doctype)
# move custom script reports to plugins folder
for name in webnotes.conn.sql_list("""select name from `tabReport`
where report_type="Script Report" and is_standard="No" """):
bean = webnotes.bean("Report", name)
bean.save()
module = webnotes.conn.get_value("DocType", bean.doc.ref_doctype, "module")
path = webnotes.modules.get_doc_path(module, "Report", name)
for extn in ["py", "js"]:
file_path = os.path.join(path, name + "." + extn)
plugins_file_path = webnotes.plugins.get_path(module, "Report", name, extn=extn)
if not os.path.exists(plugins_file_path) and os.path.exists(file_path):
shutil.copyfile(file_path, plugins_file_path)

View File

@ -237,4 +237,5 @@ patch_list = [
"patches.october_2013.p07_rename_for_territory", "patches.october_2013.p07_rename_for_territory",
"patches.june_2013.p07_taxes_price_list_for_territory", "patches.june_2013.p07_taxes_price_list_for_territory",
"patches.october_2013.p08_cleanup_after_item_price_module_change", "patches.october_2013.p08_cleanup_after_item_price_module_change",
"patches.october_2013.p10_plugins_refactor",
] ]

View File

@ -106,8 +106,8 @@ def make_demo_login_page():
def make_demo_on_login_script(): def make_demo_on_login_script():
import shutil import shutil
from core.doctype.custom_script.custom_script import get_custom_server_script_path import webnotes.plugins
custom_script_path = get_custom_server_script_path("Control Panel") custom_script_path = webnotes.plugins.get_path("Core", "DocType", "Control Panel")
webnotes.create_folder(os.path.dirname(custom_script_path)) webnotes.create_folder(os.path.dirname(custom_script_path))
shutil.copyfile(os.path.join(os.path.dirname(__file__), "demo_control_panel.py"), custom_script_path) shutil.copyfile(os.path.join(os.path.dirname(__file__), "demo_control_panel.py"), custom_script_path)