@@ -1,10 +0,0 @@ | |||
cur_frm.cscript.refresh = function(doc, dt, dn) { | |||
if (doc.script_type == 'Server' && user!="Administrator") { | |||
cur_frm.set_df_property('script', 'read_only', 1); | |||
cur_frm.set_df_property('dt', 'read_only', 1); | |||
} | |||
if(user=="Administrator") { | |||
cur_frm.set_df_property('script_type', 'read_only', 0); | |||
} | |||
} |
@@ -61,8 +61,8 @@ class CustomDocType(DocType): | |||
f.write(custom_script) | |||
def get_custom_server_script_path(doctype, plugin=None): | |||
from webnotes.modules import scrub | |||
from webnotes.utils import get_site_base_path, get_site_path | |||
from webnotes.modules import scrub, get_plugin_module_path | |||
from webnotes.utils import get_site_base_path | |||
import os | |||
# check if doctype exists | |||
@@ -75,7 +75,7 @@ def get_custom_server_script_path(doctype, plugin=None): | |||
plugin = doctype_plugin or os.path.basename(get_site_base_path()) | |||
# site_abs_path/plugin_name/module_name/doctype/doctype_name/doctype_name.py | |||
path = get_site_path(webnotes.conf.get("plugins_path"), scrub(plugin), | |||
scrub(module), "doctype", scrub(doctype), scrub(doctype) + ".py") | |||
path = os.path.join(get_plugin_module_path(scrub(plugin), scrub(module)), "doctype", | |||
scrub(doctype), scrub(doctype) + ".py") | |||
return path |
@@ -2,7 +2,7 @@ | |||
{ | |||
"creation": "2013-01-10 16:34:01", | |||
"docstatus": 0, | |||
"modified": "2013-10-14 15:50:29", | |||
"modified": "2013-10-16 16:56:41", | |||
"modified_by": "Administrator", | |||
"owner": "Administrator" | |||
}, | |||
@@ -23,14 +23,18 @@ | |||
"permlevel": 0 | |||
}, | |||
{ | |||
"cancel": 1, | |||
"create": 1, | |||
"doctype": "DocPerm", | |||
"name": "__common__", | |||
"parent": "Custom Script", | |||
"parentfield": "permissions", | |||
"parenttype": "DocType", | |||
"permlevel": 0, | |||
"read": 1, | |||
"report": 1, | |||
"submit": 0 | |||
"submit": 0, | |||
"write": 1 | |||
}, | |||
{ | |||
"doctype": "DocType", | |||
@@ -50,6 +54,7 @@ | |||
"doctype": "DocField", | |||
"fieldname": "script_type", | |||
"fieldtype": "Select", | |||
"hidden": 1, | |||
"label": "Script Type", | |||
"oldfieldname": "script_type", | |||
"oldfieldtype": "Select", | |||
@@ -66,19 +71,11 @@ | |||
"options": "Script" | |||
}, | |||
{ | |||
"cancel": 1, | |||
"create": 1, | |||
"doctype": "DocPerm", | |||
"permlevel": 0, | |||
"role": "System Manager", | |||
"write": 1 | |||
"role": "System Manager" | |||
}, | |||
{ | |||
"cancel": 1, | |||
"create": 1, | |||
"doctype": "DocPerm", | |||
"permlevel": 0, | |||
"role": "Administrator", | |||
"write": 1 | |||
"role": "Administrator" | |||
} | |||
] |
@@ -32,6 +32,10 @@ def get_module_path(module): | |||
return os.path.join(app_path, 'lib', m) | |||
else: | |||
return os.path.join(app_path, 'app', m) | |||
def get_plugin_module_path(plugin, module): | |||
from webnotes.utils import get_site_path | |||
return get_site_path(webnotes.conf.get("plugins_path"), scrub(plugin), scrub(module)) | |||
def get_doc_path(module, doctype, name): | |||
dt, dn = scrub_dt_dn(doctype, name) | |||
@@ -41,13 +45,13 @@ def reload_doc(module, dt=None, dn=None, force=True): | |||
from webnotes.modules.import_file import import_files | |||
return import_files(module, dt, dn, force) | |||
def export_doc(doctype, name, module=None): | |||
def export_doc(doctype, name, module=None, plugin=None): | |||
"""write out a doc""" | |||
from webnotes.modules.export_file import write_document_file | |||
import webnotes.model.doc | |||
if not module: module = webnotes.conn.get_value(doctype, name, 'module') | |||
write_document_file(webnotes.model.doc.get(doctype, name), module) | |||
write_document_file(webnotes.model.doc.get(doctype, name), module, plugin=plugin) | |||
def get_doctype_module(doctype): | |||
return webnotes.conn.get_value('DocType', doctype, 'module') |
@@ -5,25 +5,25 @@ from __future__ import unicode_literals | |||
import webnotes, os | |||
import webnotes.model.doc | |||
from webnotes.modules import scrub, get_module_path, lower_case_files_for, scrub_dt_dn | |||
from webnotes.modules import scrub, get_module_path, lower_case_files_for, scrub_dt_dn, get_plugin_module_path | |||
def export_doc(doc): | |||
export_to_files([[doc.doctype, doc.name]]) | |||
def export_to_files(record_list=[], record_module=None, verbose=0): | |||
def export_to_files(record_list=None, record_module=None, verbose=0, plugin=None): | |||
""" | |||
Export record_list to files. record_list is a list of lists ([doctype],[docname] ) , | |||
""" | |||
if webnotes.flags.in_import: | |||
return | |||
module_doclist =[] | |||
if record_list: | |||
for record in record_list: | |||
write_document_file(webnotes.model.doc.get(record[0], record[1]), | |||
record_module) | |||
record_module, plugin=plugin) | |||
def write_document_file(doclist, record_module=None): | |||
def write_document_file(doclist, record_module=None, plugin=None): | |||
from webnotes.modules.utils import pprint_doclist | |||
doclist = [filter_fields(d.fields) for d in doclist] | |||
@@ -32,7 +32,7 @@ def write_document_file(doclist, record_module=None): | |||
code_type = doclist[0]['doctype'] in lower_case_files_for | |||
# create folder | |||
folder = create_folder(module, doclist[0]['doctype'], doclist[0]['name'], code_type) | |||
folder = create_folder(module, doclist[0]['doctype'], doclist[0]['name'], code_type, plugin=plugin) | |||
# write the data file | |||
fname = (code_type and scrub(doclist[0]['name'])) or doclist[0]['name'] | |||
@@ -71,9 +71,11 @@ def get_module_name(doclist): | |||
return module | |||
def create_folder(module, dt, dn, code_type): | |||
# get module path by importing the module | |||
module_path = get_module_path(module) | |||
def create_folder(module, dt, dn, code_type, plugin=None): | |||
if plugin: | |||
module_path = get_plugin_module_path(plugin, module) | |||
else: | |||
module_path = get_module_path(module) | |||
dt, dn = scrub_dt_dn(dt, dn) | |||