示例#1
0
def get_js(src):
	contentpath = os.path.join(webnotes.local.sites_path, src)
	with open(contentpath, "r") as srcfile:
		code = srcfile.read()
	
	if webnotes.local.lang != "en":
		code += "\n\n$.extend(wn._messages, {})".format(json.dumps(\
			webnotes.get_lang_dict("jsfile", contentpath)))
	return code
	
示例#2
0
def getpage():
	"""
	   Load the page from `webnotes.form` and send it via `webnotes.response`
	"""
	page = webnotes.form_dict.get('name')
	doclist = get(page)

	if has_permission(doclist):
		# load translations
		if webnotes.lang != "en":
			webnotes.response["__messages"] = webnotes.get_lang_dict("page", page)

		webnotes.response['docs'] = doclist
	else:
		webnotes.response['403'] = 1
		raise webnotes.PermissionError, 'No read permission for Page %s' % \
			(doclist[0].title or page, )
示例#3
0
def get_script(report_name):
	report = get_report_doc(report_name)
	
	module = webnotes.conn.get_value("DocType", report.ref_doctype, "module")
	module_path = get_module_path(module)
	report_folder = os.path.join(module_path, "report", scrub(report.name))
	script_path = os.path.join(report_folder, scrub(report.name) + ".js")
	
	script = None
	if os.path.exists(script_path):
		with open(script_path, "r") as script:
			script = script.read()
	
	if not script and report.javascript:
		script = report.javascript
	
	if not script:
		script = "wn.query_reports['%s']={}" % report_name
		
	# load translations
	if webnotes.lang != "en":
		webnotes.response["__messages"] = webnotes.get_lang_dict("report", report_name)
		
	return script
示例#4
0
def update_language(doclist):
	"""update language"""
	if webnotes.local.lang != 'en':
		doclist[0].fields["__messages"] = webnotes.get_lang_dict("doctype", doclist[0].name)
示例#5
0
def load_translations(bootinfo):
	webnotes.set_user_lang(webnotes.session.user)
	
	if webnotes.lang != 'en':
		bootinfo["__messages"] = webnotes.get_lang_dict("include")
		bootinfo["lang"] = webnotes.lang