From 72ba2b41d57a7534e8ee27cfcdce1e5133189d7d Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Wed, 24 May 2017 17:52:01 +0530 Subject: [PATCH 1/5] Global search patch: Ignore checking is_website_published, if controller does not exists (#3379) --- frappe/utils/global_search.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/frappe/utils/global_search.py b/frappe/utils/global_search.py index 9d2aa0f51c..713b8dc152 100644 --- a/frappe/utils/global_search.py +++ b/frappe/utils/global_search.py @@ -104,11 +104,15 @@ def rebuild_for_doctype(doctype): # if doctype published in website, push title, route etc. published = 0 title, route = "", "" - if hasattr(get_controller(doctype), "is_website_published") and meta.allow_guest_to_view: - d = frappe.get_doc(doctype, doc.name) - published = 1 if d.is_website_published() else 0 - title = d.get_title() - route = d.get("route") + try: + if hasattr(get_controller(doctype), "is_website_published") and meta.allow_guest_to_view: + d = frappe.get_doc(doctype, doc.name) + published = 1 if d.is_website_published() else 0 + title = d.get_title() + route = d.get("route") + except ImportError: + # some doctypes has been deleted via future patch, hence controller does not exists + pass all_contents.append({ "doctype": frappe.db.escape(doctype), From dba2f4e8f0b9a60fba65d8c7cd3135ab3873fb06 Mon Sep 17 00:00:00 2001 From: Faris Ansari Date: Wed, 24 May 2017 17:53:52 +0530 Subject: [PATCH 2/5] Fix upload.js existing attachment (#3376) --- frappe/public/js/frappe/upload.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/frappe/public/js/frappe/upload.js b/frappe/public/js/frappe/upload.js index 40d9794f8b..d83bc5d4a0 100644 --- a/frappe/public/js/frappe/upload.js +++ b/frappe/public/js/frappe/upload.js @@ -194,15 +194,17 @@ frappe.upload = { $(document).on('upload_complete', on_upload); function upload_next() { - i += 1; - var file = files[i]; - args.is_private = file.is_private; + if(files) { + i += 1; + var file = files[i]; + args.is_private = file.is_private; + frappe.show_progress(__('Uploading'), i+1, files.length); + } frappe.upload.upload_file(file, args, opts); - frappe.show_progress(__('Uploading'), i+1, files.length); } function on_upload(e, attachment) { - if (i === files.length - 1) { + if (!files || i === files.length - 1) { $(document).off('upload_complete', on_upload); frappe.hide_progress(); return; From 5adc4d2d2441d60d9ba3856247bcfc506f9c4ed9 Mon Sep 17 00:00:00 2001 From: Faris Ansari Date: Wed, 24 May 2017 17:57:55 +0530 Subject: [PATCH 3/5] Add file_watcher_port in common_site_config.json (#3375) * Add file_watcher_port in common_site_config.json * minor --- frappe/boot.py | 2 +- frappe/build.js | 59 ++++++++++++++-------- frappe/public/js/frappe/socketio_client.js | 2 +- 3 files changed, 41 insertions(+), 22 deletions(-) diff --git a/frappe/boot.py b/frappe/boot.py index 02bdb45d9b..7f6edf8322 100644 --- a/frappe/boot.py +++ b/frappe/boot.py @@ -83,7 +83,7 @@ def get_letter_heads(): def load_conf_settings(bootinfo): from frappe import conf bootinfo.max_file_size = conf.get('max_file_size') or 10485760 - for key in ('developer_mode', 'socketio_port'): + for key in ('developer_mode', 'socketio_port', 'file_watcher_port'): if key in conf: bootinfo[key] = conf.get(key) def load_desktop_icons(bootinfo): diff --git a/frappe/build.js b/frappe/build.js index 4d14b933c5..1caaa0fcb3 100644 --- a/frappe/build.js +++ b/frappe/build.js @@ -3,23 +3,22 @@ const fs = require('fs'); const babel = require('babel-core'); const less = require('less'); const chokidar = require('chokidar'); +const path_join = path.resolve; // for file watcher const app = require('express')(); const http = require('http').Server(app); const io = require('socket.io')(http); -const file_watcher_port = 6787; - -const p = path.resolve; // basic setup -const sites_path = p(__dirname, '..', '..', '..', 'sites'); -const apps_path = p(__dirname, '..', '..', '..', 'apps'); // the apps folder -const apps_contents = fs.readFileSync(p(sites_path, 'apps.txt'), 'utf8'); +const sites_path = path_join(__dirname, '..', '..', '..', 'sites'); +const apps_path = path_join(__dirname, '..', '..', '..', 'apps'); // the apps folder +const apps_contents = fs.readFileSync(path_join(sites_path, 'apps.txt'), 'utf8'); const apps = apps_contents.split('\n'); -const app_paths = apps.map(app => p(apps_path, app, app)) // base_path of each app -const assets_path = p(sites_path, 'assets'); +const app_paths = apps.map(app => path_join(apps_path, app, app)) // base_path of each app +const assets_path = path_join(sites_path, 'assets'); const build_map = make_build_map(); +const file_watcher_port = get_conf().file_watcher_port; // command line args const action = process.argv[2] || '--build'; @@ -107,7 +106,7 @@ function pack(output_path, inputs, minify) { output_txt = output_txt.replace(/['"]use strict['"];/, ''); } - const target = p(assets_path, output_path); + const target = path_join(assets_path, output_path); try { fs.writeFileSync(target, output_txt); @@ -151,7 +150,7 @@ function minify_js(content, path) { function make_build_map() { const build_map = {}; for (const app_path of app_paths) { - const build_json_path = p(app_path, 'public', 'build.json'); + const build_json_path = path_join(app_path, 'public', 'build.json'); if (!fs.existsSync(build_json_path)) continue; let build_json = fs.readFileSync(build_json_path); @@ -167,7 +166,7 @@ function make_build_map() { const new_sources = []; for (const source of sources) { - const s = p(app_path, source); + const s = path_join(app_path, source); new_sources.push(s); } @@ -186,8 +185,8 @@ function compile_less() { return new Promise(function (resolve) { const promises = []; for (const app_path of app_paths) { - const public_path = p(app_path, 'public'); - const less_path = p(public_path, 'less'); + const public_path = path_join(app_path, 'public'); + const less_path = path_join(public_path, 'less'); if (!fs.existsSync(less_path)) continue; const files = fs.readdirSync(less_path); @@ -205,7 +204,7 @@ function compile_less() { } function compile_less_file(file, less_path, public_path) { - const file_content = fs.readFileSync(p(less_path, file), 'utf8'); + const file_content = fs.readFileSync(path_join(less_path, file), 'utf8'); const output_file = file.split('.')[0] + '.css'; console.log('compiling', file); @@ -214,7 +213,7 @@ function compile_less_file(file, less_path, public_path) { filename: file, sourceMap: false }).then(output => { - const out_css = p(public_path, 'css', output_file); + const out_css = path_join(public_path, 'css', output_file); fs.writeFileSync(out_css, output.css); return out_css; }).catch(e => { @@ -224,7 +223,7 @@ function compile_less_file(file, less_path, public_path) { } function watch_less(ondirty) { - const less_paths = app_paths.map(path => p(path, 'public', 'less')); + const less_paths = app_paths.map(path => path_join(path, 'public', 'less')); const to_watch = []; for (const less_path of less_paths) { @@ -235,7 +234,7 @@ function watch_less(ondirty) { console.log(filename, 'dirty'); var last_index = filename.lastIndexOf('/'); const less_path = filename.slice(0, last_index); - const public_path = p(less_path, '..'); + const public_path = path_join(less_path, '..'); filename = filename.split('/').pop(); compile_less_file(filename, less_path, public_path) @@ -254,7 +253,7 @@ function watch_less(ondirty) { } function watch_js(ondirty) { - const js_paths = app_paths.map(path => p(path, 'public', 'js')); + const js_paths = app_paths.map(path => path_join(path, 'public', 'js')); const to_watch = []; for (const js_path of js_paths) { @@ -265,7 +264,7 @@ function watch_js(ondirty) { console.log(filename, 'dirty'); var last_index = filename.lastIndexOf('/'); const js_path = filename.slice(0, last_index); - const public_path = p(js_path, '..'); + const public_path = path_join(js_path, '..'); // build the target js file for which this js/html file is input for (const target in build_map) { @@ -300,4 +299,24 @@ function get_file_size(filepath) { // convert it to humanly readable format. const i = Math.floor(Math.log(size) / Math.log(1024)); return (size / Math.pow(1024, i)).toFixed(2) * 1 + ' ' + ['B', 'KB', 'MB', 'GB', 'TB'][i]; -} \ No newline at end of file +} + +function get_conf() { + // defaults + var conf = { + file_watcher_port: 6787 + }; + + var read_config = function(path) { + if (!fs.existsSync(path)) return; + var bench_config = JSON.parse(fs.readFileSync(path)); + for (var key in bench_config) { + if (bench_config[key]) { + conf[key] = bench_config[key]; + } + } + } + + read_config(path_join(sites_path, 'common_site_config.json')); + return conf; +} diff --git a/frappe/public/js/frappe/socketio_client.js b/frappe/public/js/frappe/socketio_client.js index 68253d520c..f3b028cca9 100644 --- a/frappe/public/js/frappe/socketio_client.js +++ b/frappe/public/js/frappe/socketio_client.js @@ -200,7 +200,7 @@ frappe.socket = { return; } - var port = '6787'; + var port = frappe.boot.file_watcher_port || 6787; var parts = host.split(":"); // remove the port number from string if exists if (parts.length > 2) { From f66a6686d69978b5a0aed4b829875d00592dbe9d Mon Sep 17 00:00:00 2001 From: Manas Solanki Date: Wed, 24 May 2017 18:30:48 +0530 Subject: [PATCH 4/5] fix export report in csv (#3362) --- frappe/public/js/frappe/views/reports/query_report.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frappe/public/js/frappe/views/reports/query_report.js b/frappe/public/js/frappe/views/reports/query_report.js index 7f1387fa39..31b2c5dff1 100644 --- a/frappe/public/js/frappe/views/reports/query_report.js +++ b/frappe/public/js/frappe/views/reports/query_report.js @@ -821,7 +821,7 @@ frappe.views.QueryReport = Class.extend({ options:"Excel\nCSV", default:"Excel", reqd: 1}, function(data) { var view_data = frappe.slickgrid_tools.get_view_data(me.columns, me.dataView); - var result = view_data.map(row => [row.splice(1)]); + var result = view_data.map(row => row.splice(1)); // rows filtered by inline_filter of slickgrid var visible_idx = view_data.map(row => row[0]).filter(sr_no => sr_no !== 'Sr No'); From 7487a00a89f1951c42f2402bae6e4fee5cef8cef Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Wed, 24 May 2017 19:07:44 +0600 Subject: [PATCH 5/5] bumped to version 8.0.59 --- frappe/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frappe/__init__.py b/frappe/__init__.py index a611e7e47a..f3ec219288 100644 --- a/frappe/__init__.py +++ b/frappe/__init__.py @@ -13,7 +13,7 @@ import os, sys, importlib, inspect, json from .exceptions import * from .utils.jinja import get_jenv, get_template, render_template -__version__ = '8.0.58' +__version__ = '8.0.59' __title__ = "Frappe Framework" local = Local()