From 16c6d64eacf9f558eb745010f27d48255650b942 Mon Sep 17 00:00:00 2001 From: Omar Jaber Date: Thu, 21 Sep 2017 14:02:36 +0300 Subject: [PATCH 01/52] RTL direction reports chart problem This will edit the style of charts in the system --- frappe/public/css/report-rtl.css | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/frappe/public/css/report-rtl.css b/frappe/public/css/report-rtl.css index cc87b52bbf..26709a55e3 100644 --- a/frappe/public/css/report-rtl.css +++ b/frappe/public/css/report-rtl.css @@ -1,3 +1,11 @@ .grid-report { direction: ltr; } + +.chart_area{ + direction: ltr; +} + +.grid-report .show-zero{ + direction: rtl ; +} From 867e9997d2f354d6b4bd6e9ee6c25aeae2ab2afa Mon Sep 17 00:00:00 2001 From: Achilles Rasquinha Date: Fri, 22 Sep 2017 15:05:48 +0530 Subject: [PATCH 02/52] [MINOR] added --make-copy-force to force copy assets --- .vscode/settings.json | 3 +++ frappe/build.py | 25 +++++++++++++++++-------- frappe/commands/utils.py | 5 +++-- 3 files changed, 23 insertions(+), 10 deletions(-) create mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000000..fe7159848b --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "python.linting.pylintEnabled": false +} \ No newline at end of file diff --git a/frappe/build.py b/frappe/build.py index 2a201fee6f..77f42fc59d 100644 --- a/frappe/build.py +++ b/frappe/build.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals, print_function from frappe.utils.minify import JavascriptMinify import subprocess +import warnings from six import iteritems, text_type @@ -25,12 +26,12 @@ def setup(): except ImportError: pass app_paths = [os.path.dirname(pymodule.__file__) for pymodule in pymodules] -def bundle(no_compress, make_copy=False, verbose=False): +def bundle(no_compress, make_copy=False, make_copy_force=False, verbose=False): """concat / minify js files""" # build js files setup() - make_asset_dirs(make_copy=make_copy) + make_asset_dirs(make_copy=make_copy, make_copy_force = make_copy_force) # new nodejs build system command = 'node --use_strict ../apps/frappe/frappe/build.js --build' @@ -60,7 +61,7 @@ def watch(no_compress): # time.sleep(3) -def make_asset_dirs(make_copy=False): +def make_asset_dirs(make_copy=False, make_copy_force=False): assets_path = os.path.join(frappe.local.sites_path, "assets") for dir_path in [ os.path.join(assets_path, 'js'), @@ -80,11 +81,19 @@ def make_asset_dirs(make_copy=False): for source, target in symlinks: source = os.path.abspath(source) - if not os.path.exists(target) and os.path.exists(source): - if make_copy: - shutil.copytree(source, target) - else: - os.symlink(source, target) + if os.path.exists(source): + if os.path.exists(target): + if make_copy_force: + if not make_copy: + os.unlink(target) + shutil.copytree(source, target) + else: + warnings.warn('Target {target} already exists.'.format(target = target)) + pass # if exists, don't make copy. + else: + os.symlink(source, target) + else: + warnings.warn('Source {source} does not exists.'.format(source = source)) def build(no_compress=False, verbose=False): assets_path = os.path.join(frappe.local.sites_path, "assets") diff --git a/frappe/commands/utils.py b/frappe/commands/utils.py index 7c18bdbc78..9fa1ff3dbe 100644 --- a/frappe/commands/utils.py +++ b/frappe/commands/utils.py @@ -7,13 +7,14 @@ from frappe.commands import pass_context, get_site @click.command('build') @click.option('--make-copy', is_flag=True, default=False, help='Copy the files instead of symlinking') +@click.option('--make-copy-force', is_flag=True, default=False, help='Copy the files instead of symlinking with force') @click.option('--verbose', is_flag=True, default=False, help='Verbose') -def build(make_copy=False, verbose=False): +def build(make_copy=False, make_copy_force = False, verbose=False): "Minify + concatenate JS and CSS files, build translations" import frappe.build import frappe frappe.init('') - frappe.build.bundle(False, make_copy=make_copy, verbose=verbose) + frappe.build.bundle(False, make_copy=make_copy, make_copy_force = make_copy_force, verbose=verbose) @click.command('watch') def watch(): From 21b822424b01cc78fdd6dd10ec701b87889589bd Mon Sep 17 00:00:00 2001 From: Achilles Rasquinha Date: Fri, 22 Sep 2017 15:34:32 +0530 Subject: [PATCH 03/52] [FIX] build - for symlinks, --make-coppy - for copy (if symlinks doesn't exists, else no copy), --make-copy-force (force copy, cleans symlinks or dirs) --- frappe/build.py | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/frappe/build.py b/frappe/build.py index 77f42fc59d..9421ca7e47 100644 --- a/frappe/build.py +++ b/frappe/build.py @@ -62,6 +62,7 @@ def watch(no_compress): # time.sleep(3) def make_asset_dirs(make_copy=False, make_copy_force=False): + # don't even think of making assets_path absolute - rm -rf ahead. assets_path = os.path.join(frappe.local.sites_path, "assets") for dir_path in [ os.path.join(assets_path, 'js'), @@ -82,16 +83,25 @@ def make_asset_dirs(make_copy=False, make_copy_force=False): for source, target in symlinks: source = os.path.abspath(source) if os.path.exists(source): - if os.path.exists(target): - if make_copy_force: - if not make_copy: + if make_copy_force: + if os.path.exists(target): + if os.path.islink(target): os.unlink(target) - shutil.copytree(source, target) else: - warnings.warn('Target {target} already exists.'.format(target = target)) - pass # if exists, don't make copy. + shutil.rmtree(target) + shutil.copytree(source, target) + elif make_copy: + if os.path.exists(target): + warnings.warn('Target {target} already exists.'.format(target = target)) else: - os.symlink(source, target) + shutil.copytree(source, target) + else: + if os.path.exists(target): + if os.path.islink(target): + os.unlink(target) + else: + shutil.rmtree(target) + os.symlink(source, target) else: warnings.warn('Source {source} does not exists.'.format(source = source)) From a6056ea510358c41447a49df6eff973f0044f2f6 Mon Sep 17 00:00:00 2001 From: Achilles Rasquinha Date: Sun, 24 Sep 2017 17:23:35 +0530 Subject: [PATCH 04/52] added .vscode to .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 75bee9a091..4dd4f3f6ce 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ locale dist/ build/ frappe/docs/current +.vscode From 6b517126594a68ea09719a77fb838e89420a9ec9 Mon Sep 17 00:00:00 2001 From: Achilles Rasquinha Date: Mon, 25 Sep 2017 12:38:56 +0530 Subject: [PATCH 05/52] [MINOR, UX] added color contrast to color picker --- frappe/public/js/frappe/form/controls/color.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/frappe/public/js/frappe/form/controls/color.js b/frappe/public/js/frappe/form/controls/color.js index d13c22d19d..646f7de2f1 100644 --- a/frappe/public/js/frappe/form/controls/color.js +++ b/frappe/public/js/frappe/form/controls/color.js @@ -34,12 +34,15 @@ frappe.ui.form.ControlColor = frappe.ui.form.ControlData.extend({ return `
`; }, set_formatted_input: function(value) { - this._super(value); + this._super(value) + + if (!value) value = '#FFFFFF' + const contrast = frappe.ui.color.get_contrast_color(value) - if(!value) value = '#ffffff'; this.$input.css({ - "background-color": value - }); + "background-color": value, + "color": contrast + }) }, bind_events: function () { var mousedown_happened = false; From ed8b4afde8b6e4d79abb519ffa7268b9f9817eb4 Mon Sep 17 00:00:00 2001 From: Achilles Rasquinha Date: Mon, 25 Sep 2017 12:46:41 +0530 Subject: [PATCH 06/52] fixed codacy --- frappe/public/js/frappe/form/controls/color.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/frappe/public/js/frappe/form/controls/color.js b/frappe/public/js/frappe/form/controls/color.js index 646f7de2f1..7b14b45aca 100644 --- a/frappe/public/js/frappe/form/controls/color.js +++ b/frappe/public/js/frappe/form/controls/color.js @@ -34,15 +34,15 @@ frappe.ui.form.ControlColor = frappe.ui.form.ControlData.extend({ return `
`; }, set_formatted_input: function(value) { - this._super(value) + this._super(value); - if (!value) value = '#FFFFFF' - const contrast = frappe.ui.color.get_contrast_color(value) + if (!value) value = '#FFFFFF'; + const contrast = frappe.ui.color.get_contrast_color(value); this.$input.css({ "background-color": value, "color": contrast - }) + }); }, bind_events: function () { var mousedown_happened = false; From 6a4dcb58af03f379cc572be92dee97f322bcce16 Mon Sep 17 00:00:00 2001 From: Achilles Rasquinha Date: Mon, 25 Sep 2017 19:15:14 +0530 Subject: [PATCH 07/52] Wiggle Desktop Icons to have them removed, works for current user only - the iOS feel --- frappe/core/page/desktop/desktop.js | 109 +++++++++++++++++- .../desk/doctype/desktop_icon/desktop_icon.py | 13 +++ frappe/public/build.json | 3 +- frappe/public/js/lib/jquery.jrumble.min.js | 2 + 4 files changed, 125 insertions(+), 2 deletions(-) create mode 100644 frappe/public/js/lib/jquery.jrumble.min.js diff --git a/frappe/core/page/desktop/desktop.js b/frappe/core/page/desktop/desktop.js index eae5b7a35d..b5dc7f7aac 100644 --- a/frappe/core/page/desktop/desktop.js +++ b/frappe/core/page/desktop/desktop.js @@ -112,13 +112,17 @@ $.extend(frappe.desktop, { }, setup_module_click: function() { + var wiggling = false; // wiggle, wiggle, wiggle. + if(frappe.list_desktop) { frappe.desktop.wrapper.on("click", ".desktop-list-item", function() { frappe.desktop.open_module($(this)); }); } else { frappe.desktop.wrapper.on("click", ".app-icon", function() { - frappe.desktop.open_module($(this).parent()); + if ( !wiggling ) { + frappe.desktop.open_module($(this).parent()); + } }); } frappe.desktop.wrapper.on("click", ".circle", function() { @@ -127,6 +131,109 @@ $.extend(frappe.desktop, { frappe.ui.notifications.show_open_count_list(doctype); } }); + + // Wiggle, Wiggle, Wiggle. + const DURATION_LONG_PRESS = 1000; + // lesser the antidode, more the wiggle (like your drunk uncle) + // 75 seems good to replicate the iOS feels. + const WIGGLE_ANTIDODE = 75; + + var timer_id = 0; + const $cases = frappe.desktop.wrapper.find('.case-wrapper'); + const $icons = frappe.desktop.wrapper.find('.app-icon'); + const $notis = $(frappe.desktop.wrapper.find('.circle').toArray().filter((object) => { + // This hack is so bad, I should punch myself. + const doctype = $(object).data('doctype'); + + return doctype; + })); + + const clearWiggle = ($close) => { + const $closes = $cases.find('.module-remove'); + $closes.hide(); + $notis.show(); + + $icons.trigger('stopRumble'); + }; + + // initiate wiggling. + $icons.jrumble({ + speed: WIGGLE_ANTIDODE // seems neat enough to match the iOS way + }); + + frappe.desktop.wrapper.on('mousedown', '.app-icon', () => { + timer_id = setTimeout(() => { + wiggling = true; + // hide all notifications. + $notis.hide(); + + $cases.each((i) => { + const $case = $($cases[i]); + const template = + ` +
+
+ + × + +
+
+ ` + + $case.append(template); + const $close = $case.find('.module-remove'); + const name = $case.data('name'); + $close.click((event) => { + // good enough to create dynamic dialogs? + const dialog = new frappe.ui.Dialog({ + title: __(`Hide ${name}`) + }); + dialog.set_primary_action(__('Hide'), () => { + frappe.call({ + method: 'frappe.desk.doctype.desktop_icon.desktop_icon.hide', + args: { name: name }, + freeze: true, + callback: (response) => + { + if ( response.message ) { + location.reload(); + } + } + }) + + dialog.hide(); + + clearWiggle(); + }); + // Hacks, Hacks and Hacks. + var $cancel = dialog.get_close_btn(); + $cancel.click(() => { + clearWiggle(); + }); + $cancel.html(__(`Cancel`)); + + dialog.show(); + }); + }); + + $icons.trigger('startRumble'); + }, DURATION_LONG_PRESS); + }); + frappe.desktop.wrapper.on('mouseup mouseleave', '.app-icon', () => { + clearTimeout(timer_id); + }); + + // also stop wiggling if clicked elsewhere. + $('body').click((event) => { + if ( wiggling ) { + const $target = $(event.target); + // our target shouldn't be .app-icons or .close + const $parent = $target.parents('.case-wrapper'); + if ( $parent.length == 0 ) + clearWiggle(); + } + }); + // end wiggle }, open_module: function(parent) { diff --git a/frappe/desk/doctype/desktop_icon/desktop_icon.py b/frappe/desk/doctype/desktop_icon/desktop_icon.py index 1319ffba49..59118b09b8 100644 --- a/frappe/desk/doctype/desktop_icon/desktop_icon.py +++ b/frappe/desk/doctype/desktop_icon/desktop_icon.py @@ -404,3 +404,16 @@ palette = ( ('#4F8EA8', 1), ('#428B46', 1) ) + +@frappe.whitelist() +def hide(name, user = None): + if not user: + user = frappe.session.user + + try: + set_hidden(name, user, hidden = 1) + clear_desktop_icons_cache() + except: + return False + + return True \ No newline at end of file diff --git a/frappe/public/build.json b/frappe/public/build.json index 913adfe735..cf6e784ba5 100755 --- a/frappe/public/build.json +++ b/frappe/public/build.json @@ -130,7 +130,8 @@ "public/js/lib/jSignature.min.js", "public/js/frappe/translate.js", "public/js/lib/datepicker/datepicker.min.js", - "public/js/lib/datepicker/locale-all.js" + "public/js/lib/datepicker/locale-all.js", + "public/js/lib/jquery.jrumble.min.js" ], "js/desk.min.js": [ "public/js/frappe/class.js", diff --git a/frappe/public/js/lib/jquery.jrumble.min.js b/frappe/public/js/lib/jquery.jrumble.min.js new file mode 100644 index 0000000000..71de6ffb7c --- /dev/null +++ b/frappe/public/js/lib/jquery.jrumble.min.js @@ -0,0 +1,2 @@ +/* jRumble v1.3 - http://jackrugile.com/jrumble - MIT License */ +(function(f){f.fn.jrumble=function(g){var a=f.extend({x:2,y:2,rotation:1,speed:15,opacity:false,opacityMin:0.5},g);return this.each(function(){var b=f(this),h=a.x*2,i=a.y*2,k=a.rotation*2,g=a.speed===0?1:a.speed,m=a.opacity,n=a.opacityMin,l,j,o=function(){var e=Math.floor(Math.random()*(h+1))-h/2,a=Math.floor(Math.random()*(i+1))-i/2,c=Math.floor(Math.random()*(k+1))-k/2,d=m?Math.random()+n:1,e=e===0&&h!==0?Math.random()<0.5?1:-1:e,a=a===0&&i!==0?Math.random()<0.5?1:-1:a;b.css("display")==="inline"&&(l=true,b.css("display","inline-block"));b.css({position:"relative",left:e+"px",top:a+"px","-ms-filter":"progid:DXImageTransform.Microsoft.Alpha(Opacity="+d*100+")",filter:"alpha(opacity="+d*100+")","-moz-opacity":d,"-khtml-opacity":d,opacity:d,"-webkit-transform":"rotate("+c+"deg)","-moz-transform":"rotate("+c+"deg)","-ms-transform":"rotate("+c+"deg)","-o-transform":"rotate("+c+"deg)",transform:"rotate("+c+"deg)"})},p={left:0,top:0,"-ms-filter":"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)",filter:"alpha(opacity=100)","-moz-opacity":1,"-khtml-opacity":1,opacity:1,"-webkit-transform":"rotate(0deg)","-moz-transform":"rotate(0deg)","-ms-transform":"rotate(0deg)","-o-transform":"rotate(0deg)",transform:"rotate(0deg)"};b.bind({startRumble:function(a){a.stopPropagation();clearInterval(j);j=setInterval(o,g)},stopRumble:function(a){a.stopPropagation();clearInterval(j);l&&b.css("display","inline");b.css(p)}})})}})(jQuery); \ No newline at end of file From dae76e27a80b4fd84e04658680a0eadb9de85707 Mon Sep 17 00:00:00 2001 From: Achilles Rasquinha Date: Mon, 25 Sep 2017 19:25:34 +0530 Subject: [PATCH 08/52] [FIX] fixed for desktop titles --- frappe/core/page/desktop/desktop.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frappe/core/page/desktop/desktop.js b/frappe/core/page/desktop/desktop.js index b5dc7f7aac..7e55301d20 100644 --- a/frappe/core/page/desktop/desktop.js +++ b/frappe/core/page/desktop/desktop.js @@ -182,11 +182,11 @@ $.extend(frappe.desktop, { $case.append(template); const $close = $case.find('.module-remove'); - const name = $case.data('name'); + const name = $case.attr('title'); $close.click((event) => { // good enough to create dynamic dialogs? const dialog = new frappe.ui.Dialog({ - title: __(`Hide ${name}`) + title: __(`Hide ${name}?`) }); dialog.set_primary_action(__('Hide'), () => { frappe.call({ From a38b6913cef1ac8a418d0330e8d6f6eca3cfec4c Mon Sep 17 00:00:00 2001 From: Achilles Rasquinha Date: Mon, 25 Sep 2017 19:33:54 +0530 Subject: [PATCH 09/52] added a Makefile for faster dev, and clean command to remove eggs, wheels, builds, dist - anything that clutters devspace --- Makefile | 2 ++ setup.py | 38 +++++++++++++++++++++++++++++++++++++- 2 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 0000000000..f30645229e --- /dev/null +++ b/Makefile @@ -0,0 +1,2 @@ +clean: + python setup.py clean \ No newline at end of file diff --git a/setup.py b/setup.py index bbcf6cfb37..797d8e4826 100644 --- a/setup.py +++ b/setup.py @@ -1,3 +1,7 @@ +# imports - standard imports +import os, shutil +from distutils.command.clean import clean as Clean + from setuptools import setup, find_packages from pip.req import parse_requirements import re, ast @@ -11,6 +15,34 @@ with open('frappe/__init__.py', 'rb') as f: requirements = parse_requirements("requirements.txt", session="") +class CleanCommand(Clean): + def run(self): + Clean.run(self) + + basedir = os.path.abspath(os.path.dirname(__file__)) + + for relpath in ['build', '.cache', '.coverage', 'dist', 'frappe.egg-info']: + abspath = os.path.join(basedir, relpath) + + if os.path.exists(abspath): + if os.path.isfile(abspath): + os.remove(abspath) + else: + shutil.rmtree(abspath) + + for dirpath, dirnames, filenames in os.walk(basedir): + for filename in filenames: + _, extension = os.path.splitext(filename) + + if extension in ['.pyc']: + abspath = os.path.join(dirpath, filename) + os.remove(abspath) + + for dirname in dirnames: + if dirname in ['__pycache__']: + abspath = os.path.join(dirpath, dirname) + shutil.rmtree(abspath) + setup( name='frappe', version=version, @@ -21,5 +53,9 @@ setup( zip_safe=False, include_package_data=True, install_requires=[str(ir.req) for ir in requirements], - dependency_links=[str(ir._link) for ir in requirements if ir._link] + dependency_links=[str(ir._link) for ir in requirements if ir._link], + cmdclass = \ + { + 'clean': CleanCommand + } ) From eb152073a73d2fa6e68ea6c3757ce843416f39d4 Mon Sep 17 00:00:00 2001 From: Achilles Rasquinha Date: Mon, 25 Sep 2017 19:48:18 +0530 Subject: [PATCH 10/52] fu codacy --- frappe/core/page/desktop/desktop.js | 16 ++++++++-------- frappe/desk/doctype/desktop_icon/desktop_icon.py | 2 +- frappe/public/js/frappe/form/controls/color.js | 3 +-- setup.py | 2 +- 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/frappe/core/page/desktop/desktop.js b/frappe/core/page/desktop/desktop.js index 7e55301d20..f70f58fe75 100644 --- a/frappe/core/page/desktop/desktop.js +++ b/frappe/core/page/desktop/desktop.js @@ -148,12 +148,12 @@ $.extend(frappe.desktop, { return doctype; })); - const clearWiggle = ($close) => { + const clearWiggle = () => { const $closes = $cases.find('.module-remove'); $closes.hide(); - $notis.show(); + $notis.show(); - $icons.trigger('stopRumble'); + $icons.trigger('stopRumble'); }; // initiate wiggling. @@ -178,21 +178,21 @@ $.extend(frappe.desktop, { - ` + `; $case.append(template); const $close = $case.find('.module-remove'); const name = $case.attr('title'); - $close.click((event) => { + $close.click(() => { // good enough to create dynamic dialogs? const dialog = new frappe.ui.Dialog({ title: __(`Hide ${name}?`) }); dialog.set_primary_action(__('Hide'), () => { frappe.call({ - method: 'frappe.desk.doctype.desktop_icon.desktop_icon.hide', - args: { name: name }, - freeze: true, + method: 'frappe.desk.doctype.desktop_icon.desktop_icon.hide', + args: { name: name }, + freeze: true, callback: (response) => { if ( response.message ) { diff --git a/frappe/desk/doctype/desktop_icon/desktop_icon.py b/frappe/desk/doctype/desktop_icon/desktop_icon.py index 59118b09b8..52461db009 100644 --- a/frappe/desk/doctype/desktop_icon/desktop_icon.py +++ b/frappe/desk/doctype/desktop_icon/desktop_icon.py @@ -413,7 +413,7 @@ def hide(name, user = None): try: set_hidden(name, user, hidden = 1) clear_desktop_icons_cache() - except: + except Exception as e: return False return True \ No newline at end of file diff --git a/frappe/public/js/frappe/form/controls/color.js b/frappe/public/js/frappe/form/controls/color.js index 7b14b45aca..6e8880a72a 100644 --- a/frappe/public/js/frappe/form/controls/color.js +++ b/frappe/public/js/frappe/form/controls/color.js @@ -40,8 +40,7 @@ frappe.ui.form.ControlColor = frappe.ui.form.ControlData.extend({ const contrast = frappe.ui.color.get_contrast_color(value); this.$input.css({ - "background-color": value, - "color": contrast + "background-color": value, "color": contrast }); }, bind_events: function () { diff --git a/setup.py b/setup.py index 797d8e4826..2589c6cd0d 100644 --- a/setup.py +++ b/setup.py @@ -54,7 +54,7 @@ setup( include_package_data=True, install_requires=[str(ir.req) for ir in requirements], dependency_links=[str(ir._link) for ir in requirements if ir._link], - cmdclass = \ + cmdclass = \ { 'clean': CleanCommand } From c1ab7eab450ef0a046155c45e088c419ba37e8eb Mon Sep 17 00:00:00 2001 From: Achilles Rasquinha Date: Mon, 25 Sep 2017 20:56:15 +0530 Subject: [PATCH 11/52] codacy fix --- frappe/core/page/desktop/desktop.js | 2 +- frappe/desk/doctype/desktop_icon/desktop_icon.py | 2 +- setup.py | 3 +-- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/frappe/core/page/desktop/desktop.js b/frappe/core/page/desktop/desktop.js index f70f58fe75..2c8210c364 100644 --- a/frappe/core/page/desktop/desktop.js +++ b/frappe/core/page/desktop/desktop.js @@ -192,7 +192,7 @@ $.extend(frappe.desktop, { frappe.call({ method: 'frappe.desk.doctype.desktop_icon.desktop_icon.hide', args: { name: name }, - freeze: true, + freeze: true, callback: (response) => { if ( response.message ) { diff --git a/frappe/desk/doctype/desktop_icon/desktop_icon.py b/frappe/desk/doctype/desktop_icon/desktop_icon.py index 52461db009..291a8404a1 100644 --- a/frappe/desk/doctype/desktop_icon/desktop_icon.py +++ b/frappe/desk/doctype/desktop_icon/desktop_icon.py @@ -413,7 +413,7 @@ def hide(name, user = None): try: set_hidden(name, user, hidden = 1) clear_desktop_icons_cache() - except Exception as e: + except Exception: return False return True \ No newline at end of file diff --git a/setup.py b/setup.py index 2589c6cd0d..8b02d8f856 100644 --- a/setup.py +++ b/setup.py @@ -23,7 +23,6 @@ class CleanCommand(Clean): for relpath in ['build', '.cache', '.coverage', 'dist', 'frappe.egg-info']: abspath = os.path.join(basedir, relpath) - if os.path.exists(abspath): if os.path.isfile(abspath): os.remove(abspath) @@ -58,4 +57,4 @@ setup( { 'clean': CleanCommand } -) +) \ No newline at end of file From 5ac8b500a4b6f39c4b5f6de63beae4479279906d Mon Sep 17 00:00:00 2001 From: Achilles Rasquinha Date: Mon, 25 Sep 2017 21:22:17 +0530 Subject: [PATCH 12/52] fixed codacy --- setup.py | 1 - 1 file changed, 1 deletion(-) diff --git a/setup.py b/setup.py index 8b02d8f856..87c0116832 100644 --- a/setup.py +++ b/setup.py @@ -32,7 +32,6 @@ class CleanCommand(Clean): for dirpath, dirnames, filenames in os.walk(basedir): for filename in filenames: _, extension = os.path.splitext(filename) - if extension in ['.pyc']: abspath = os.path.join(dirpath, filename) os.remove(abspath) From f7a82e727d21ffb8676947a8136a49871bc15554 Mon Sep 17 00:00:00 2001 From: Achilles Rasquinha Date: Mon, 25 Sep 2017 21:41:40 +0530 Subject: [PATCH 13/52] updated README.md, we need better readmes --- .github/logo.png | Bin 0 -> 12673 bytes README.md | 15 +++- frappe/public/build.json | 14 +++- .../js/frappe/form/controls/text_editor.js | 19 ++++- frappe/public/js/frappe/ui/camera.js | 67 ++++++++++++++++++ frappe/public/js/lib/webcam.min.js | 2 + 6 files changed, 114 insertions(+), 3 deletions(-) create mode 100644 .github/logo.png create mode 100644 frappe/public/js/frappe/ui/camera.js create mode 100644 frappe/public/js/lib/webcam.min.js diff --git a/.github/logo.png b/.github/logo.png new file mode 100644 index 0000000000000000000000000000000000000000..258408edfa524a4b4dfd968b70344cb257ade492 GIT binary patch literal 12673 zcmdUWcT|%>ux|tfK@d@CD$+}&_a;T9g)TiHpi)8yL+@Asksf+gBtcLjN+<#bP?S!P zfFNCkfOP2{?gsBW_nmw0Iq&`X-r)qY`|ZxoH#s|9%!P;k|#C;$SMD!GMB4yTJHHY887cLY$F;?eT+9E(3e@~5P2I}nl4bcKnysDD%){uxdMSaHAi+G&4*5fG+Mj$jFd+S)c)4D zu=8|mFxPcF4}qADMJ?(QmKMg=eoIxYqw!XOsKVZeqO22;ND17oI#$`ST(e;2RJa$iH3q4~N*YW?ADT3i|~_~#yR6mG1@<+q_t+1h>*P;~9mmKsTrJd|Ek z5l4rr@LueIOSfoe+6v+i?w6JpZX*iQ3nsWc_EY+m)HETGcubnjn*Xd{dCGM$=9iAdLQS!`Z0O7~sBl)vrZPexx24gTq(;NK zyH!*8mmUtp2G0-o3lIM^zj4Ugi$R)qR74ST#jYGITj$1or3de{MbJenNNFAI#q~Td z1fLs5X}DgSK-(Qh^YUxqK$Z}`j;IuZok@6Y=eT_CJ3&NI?swa8wu#K*niM7o1S9QW zfLC{xUYl_^9fvfp3)D#Y+fECKMD2AvwUg81FX1{C+kcay5m35+LVb~U0s@imnvLzT z5J?xc66(%}@|j>VJ@T0sB~$~krl;o+k*qwk=|0b+jPV90Ay&-h6&b>9kAw}JR_2oS z{qmxCvlR)S;{yM@!t#|K?PU+9-{F5=qZsI5$#8uD(;DGdCW`c}$YbNNS(BY5p1F4P z%o6Z&jxs#?7WYzE?7HO_~ z9!3Qe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A6 zHRD*)8l4-@SuPH#nj+aQTd^xDzKpr5`dUD4u+@)bU^ub94+>`+@v6j%qqS)nMK}14 zf_B3;mOc2v41@#JrLcZouTE=NA3D<^I;fgF`08khjUr?tMui*Lfd5lfX%{r=Q9|V% zQI7M#P4R7&_HL%{Q0$q4a=bkT2CZw}G4-0K&p;y2Qzf$Wt7eJSk2c(DexjjpdF&v` zzdb`CaC6Ph-%bAVIr3~v>(O$}p{++q+1D%qXVdb8@$;7Ec8&Hd0Ggir6dkhVGT1O# zba?PMDPZ>ft9qJeNb}(uxut)fOO=ziPK^Z*UJYBhJknY4{N(hMeX2-_0v%dcV$N6KePk z5JU@)<>;ti9@5;!yzwr%H2=Xi>0oQZ&O}Za8;f*uR1u5aI}Pyed%x3eDi&@%L*O3) zhUx?6mo~p5I5OAIes3!Sfbm6L{JNo1gufigeU)}NPSwpOl<>Gf+L}lQqo-4XK>l7k p(Arp{6lwVD{#L>l3&0HoreUD|_U7G3{{cE>2O$6e literal 0 HcmV?d00001 diff --git a/README.md b/README.md index 9621b58b46..5e3c1f83e0 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,17 @@ -## Frappé Framework + [![Build Status](https://travis-ci.org/frappe/frappe.png)](https://travis-ci.org/frappe/frappe) diff --git a/frappe/public/build.json b/frappe/public/build.json index cf6e784ba5..410f398ab2 100755 --- a/frappe/public/build.json +++ b/frappe/public/build.json @@ -23,6 +23,9 @@ "public/js/frappe/misc/rating_icons.html" ], "js/control.min.js": [ + + "public/js/frappe/ui/camera.js", + "public/js/frappe/form/controls/base_control.js", "public/js/frappe/form/controls/base_input.js", "public/js/frappe/form/controls/data.js", @@ -55,12 +58,17 @@ "js/dialog.min.js": [ "public/js/frappe/dom.js", "public/js/frappe/ui/modal.html", + + "public/js/frappe/form/formatters.js", "public/js/frappe/form/layout.js", "public/js/frappe/ui/field_group.js", "public/js/frappe/form/link_selector.js", "public/js/frappe/form/multi_select_dialog.js", "public/js/frappe/ui/dialog.js", + + "public/js/frappe/ui/camera.js", + "public/js/frappe/form/controls/base_control.js", "public/js/frappe/form/controls/base_input.js", "public/js/frappe/form/controls/data.js", @@ -131,7 +139,8 @@ "public/js/frappe/translate.js", "public/js/lib/datepicker/datepicker.min.js", "public/js/lib/datepicker/locale-all.js", - "public/js/lib/jquery.jrumble.min.js" + "public/js/lib/jquery.jrumble.min.js", + "public/js/lib/webcam.min.js" ], "js/desk.min.js": [ "public/js/frappe/class.js", @@ -169,6 +178,9 @@ "public/js/frappe/form/link_selector.js", "public/js/frappe/form/multi_select_dialog.js", "public/js/frappe/ui/dialog.js", + + "public/js/frappe/ui/camera.js", + "public/js/frappe/ui/app_icon.js", "public/js/frappe/model/model.js", diff --git a/frappe/public/js/frappe/form/controls/text_editor.js b/frappe/public/js/frappe/form/controls/text_editor.js index 00af468754..3a82a7af6d 100644 --- a/frappe/public/js/frappe/form/controls/text_editor.js +++ b/frappe/public/js/frappe/form/controls/text_editor.js @@ -7,6 +7,19 @@ frappe.ui.form.ControlTextEditor = frappe.ui.form.ControlCode.extend({ this.setup_image_dialog(); this.setting_count = 0; }, + render_camera_button: (context) => { + var ui = $.summernote.ui; + var button = ui.button({ + contents: '', + tooltip: 'Camera', + click: () => { + const camera = new frappe.ui.Camera(); + camera.show(); + } + }); + + return button.render(); + }, make_editor: function() { var me = this; this.editor = $("
").appendTo(this.input_area); @@ -25,9 +38,12 @@ frappe.ui.form.ControlTextEditor = frappe.ui.form.ControlCode.extend({ ['color', ['color']], ['para', ['ul', 'ol', 'paragraph', 'hr']], //['height', ['height']], - ['media', ['link', 'picture', 'video', 'table']], + ['media', ['link', 'picture', 'camera', 'video', 'table']], ['misc', ['fullscreen', 'codeview']] ], + buttons: { + camera: this.render_camera_button, + }, keyMap: { pc: { 'CTRL+ENTER': '' @@ -80,6 +96,7 @@ frappe.ui.form.ControlTextEditor = frappe.ui.form.ControlCode.extend({ 'outdent': 'fa fa-outdent', 'arrowsAlt': 'fa fa-arrows-alt', 'bold': 'fa fa-bold', + 'camera': 'fa fa-camera', 'caret': 'caret', 'circle': 'fa fa-circle', 'close': 'fa fa-close', diff --git a/frappe/public/js/frappe/ui/camera.js b/frappe/public/js/frappe/ui/camera.js new file mode 100644 index 0000000000..733471d86e --- /dev/null +++ b/frappe/public/js/frappe/ui/camera.js @@ -0,0 +1,67 @@ +frappe.ui.Camera = class +{ + constructor (options) + { + this.dialog = new frappe.ui.Dialog(); + + this.template = + ` +
+ +
+ ` + + this.show = this.show.bind(this); + this.hide = this.hide.bind(this); + this.on = this.on.bind(this); + this.attach = this.attach.bind(this); + + Webcam.set({ + width: 320, + height: 240, + flip_horiz: true, + }) + } + + show ( ) + { + this.attach((err) => { + if ( err ) + throw Error('Unable to attach webcamera.'); + + this.dialog.set_primary_action(__('Click'), () => { + this.click(); + }); + + this.dialog.show(); + }); + } + + hide ( ) + { + this.dialog.hide(); + } + + on (event, callback) + { + if ( event == 'attach' ) { + this.attach(callback); + } + } + + click (callback) + { + Webcam.snap((data) => { + console.log(data); + }); + } + + attach (callback) + { + $(this.dialog.body).append(this.template); + + Webcam.attach('#frappe-camera'); + + callback(); + } +}; \ No newline at end of file diff --git a/frappe/public/js/lib/webcam.min.js b/frappe/public/js/lib/webcam.min.js new file mode 100644 index 0000000000..3325ccfd05 --- /dev/null +++ b/frappe/public/js/lib/webcam.min.js @@ -0,0 +1,2 @@ +// WebcamJS v1.0.22 - http://github.com/jhuckaby/webcamjs - MIT Licensed +(function(e){var t;function a(){var e=Error.apply(this,arguments);e.name=this.name="FlashError";this.stack=e.stack;this.message=e.message}function i(){var e=Error.apply(this,arguments);e.name=this.name="WebcamError";this.stack=e.stack;this.message=e.message}IntermediateInheritor=function(){};IntermediateInheritor.prototype=Error.prototype;a.prototype=new IntermediateInheritor;i.prototype=new IntermediateInheritor;var Webcam={version:"1.0.22",protocol:location.protocol.match(/https/i)?"https":"http",loaded:false,live:false,userMedia:true,iOS:/iPad|iPhone|iPod/.test(navigator.userAgent)&&!e.MSStream,params:{width:0,height:0,dest_width:0,dest_height:0,image_format:"jpeg",jpeg_quality:90,enable_flash:true,force_flash:false,flip_horiz:false,fps:30,upload_name:"webcam",constraints:null,swfURL:"",flashNotDetectedText:"ERROR: No Adobe Flash Player detected. Webcam.js relies on Flash for browsers that do not support getUserMedia (like yours).",noInterfaceFoundText:"No supported webcam interface found.",unfreeze_snap:true,iosPlaceholderText:"Click here to open camera.",user_callback:null,user_canvas:null},errors:{FlashError:a,WebcamError:i},hooks:{},init:function(){var t=this;this.mediaDevices=navigator.mediaDevices&&navigator.mediaDevices.getUserMedia?navigator.mediaDevices:navigator.mozGetUserMedia||navigator.webkitGetUserMedia?{getUserMedia:function(e){return new Promise(function(t,a){(navigator.mozGetUserMedia||navigator.webkitGetUserMedia).call(navigator,e,t,a)})}}:null;e.URL=e.URL||e.webkitURL||e.mozURL||e.msURL;this.userMedia=this.userMedia&&!!this.mediaDevices&&!!e.URL;if(navigator.userAgent.match(/Firefox\D+(\d+)/)){if(parseInt(RegExp.$1,10)<21)this.userMedia=null}if(this.userMedia){e.addEventListener("beforeunload",function(e){t.reset()})}},exifOrientation:function(e){var t=new DataView(e);if(t.getUint8(0)!=255||t.getUint8(1)!=216){console.log("Not a valid JPEG file");return 0}var a=2;var i=null;while(a8){console.log("Invalid EXIF orientation value ("+p+")");return 0}return p}}}else{a+=2+t.getUint16(a+2)}}return 0},fixOrientation:function(e,t,a){var i=new Image;i.addEventListener("load",function(e){var s=document.createElement("canvas");var r=s.getContext("2d");if(t<5){s.width=i.width;s.height=i.height}else{s.width=i.height;s.height=i.width}switch(t){case 2:r.transform(-1,0,0,1,i.width,0);break;case 3:r.transform(-1,0,0,-1,i.width,i.height);break;case 4:r.transform(1,0,0,-1,0,i.height);break;case 5:r.transform(0,1,1,0,0,0);break;case 6:r.transform(0,1,-1,0,i.height,0);break;case 7:r.transform(0,-1,-1,0,i.height,i.width);break;case 8:r.transform(0,-1,1,0,0,i.width);break}r.drawImage(i,0,0);a.src=s.toDataURL()},false);i.src=e},attach:function(a){if(typeof a=="string"){a=document.getElementById(a)||document.querySelector(a)}if(!a){return this.dispatch("error",new i("Could not locate DOM element to attach to."))}this.container=a;a.innerHTML="";var s=document.createElement("div");a.appendChild(s);this.peg=s;if(!this.params.width)this.params.width=a.offsetWidth;if(!this.params.height)this.params.height=a.offsetHeight;if(!this.params.width||!this.params.height){return this.dispatch("error",new i("No width and/or height for webcam. Please call set() first, or attach to a visible element."))}if(!this.params.dest_width)this.params.dest_width=this.params.width;if(!this.params.dest_height)this.params.dest_height=this.params.height;this.userMedia=t===undefined?this.userMedia:t;if(this.params.force_flash){t=this.userMedia;this.userMedia=null}if(typeof this.params.fps!=="number")this.params.fps=30;var r=this.params.width/this.params.dest_width;var o=this.params.height/this.params.dest_height;if(this.userMedia){var n=document.createElement("video");n.setAttribute("autoplay","autoplay");n.style.width=""+this.params.dest_width+"px";n.style.height=""+this.params.dest_height+"px";if(r!=1||o!=1){a.style.overflow="hidden";n.style.webkitTransformOrigin="0px 0px";n.style.mozTransformOrigin="0px 0px";n.style.msTransformOrigin="0px 0px";n.style.oTransformOrigin="0px 0px";n.style.transformOrigin="0px 0px";n.style.webkitTransform="scaleX("+r+") scaleY("+o+")";n.style.mozTransform="scaleX("+r+") scaleY("+o+")";n.style.msTransform="scaleX("+r+") scaleY("+o+")";n.style.oTransform="scaleX("+r+") scaleY("+o+")";n.style.transform="scaleX("+r+") scaleY("+o+")"}a.appendChild(n);this.video=n;var h=this;this.mediaDevices.getUserMedia({audio:false,video:this.params.constraints||{mandatory:{minWidth:this.params.dest_width,minHeight:this.params.dest_height}}}).then(function(t){n.onloadedmetadata=function(e){h.stream=t;h.loaded=true;h.live=true;h.dispatch("load");h.dispatch("live");h.flip()};n.src=e.URL.createObjectURL(t)||t}).catch(function(e){if(h.params.enable_flash&&h.detectFlash()){setTimeout(function(){h.params.force_flash=1;h.attach(a)},1)}else{h.dispatch("error",e)}})}else if(this.iOS){var l=document.createElement("div");l.id=this.container.id+"-ios_div";l.className="webcamjs-ios-placeholder";l.style.width=""+this.params.width+"px";l.style.height=""+this.params.height+"px";l.style.textAlign="center";l.style.display="table-cell";l.style.verticalAlign="middle";l.style.backgroundRepeat="no-repeat";l.style.backgroundSize="contain";l.style.backgroundPosition="center";var c=document.createElement("span");c.className="webcamjs-ios-text";c.innerHTML=this.params.iosPlaceholderText;l.appendChild(c);var d=document.createElement("img");d.id=this.container.id+"-ios_img";d.style.width=""+this.params.dest_width+"px";d.style.height=""+this.params.dest_height+"px";d.style.display="none";l.appendChild(d);var f=document.createElement("input");f.id=this.container.id+"-ios_input";f.setAttribute("type","file");f.setAttribute("accept","image/*");f.setAttribute("capture","camera");var h=this;var m=this.params;f.addEventListener("change",function(e){if(e.target.files.length>0&&e.target.files[0].type.indexOf("image/")==0){var t=URL.createObjectURL(e.target.files[0]);var a=new Image;a.addEventListener("load",function(e){var t=document.createElement("canvas");t.width=m.dest_width;t.height=m.dest_height;var i=t.getContext("2d");ratio=Math.min(a.width/m.dest_width,a.height/m.dest_height);var s=m.dest_width*ratio;var r=m.dest_height*ratio;var o=(a.width-s)/2;var n=(a.height-r)/2;i.drawImage(a,o,n,s,r,0,0,m.dest_width,m.dest_height);var h=t.toDataURL();d.src=h;l.style.backgroundImage="url('"+h+"')"},false);var i=new FileReader;i.addEventListener("load",function(e){var i=h.exifOrientation(e.target.result);if(i>1){h.fixOrientation(t,i,a)}else{a.src=t}},false);var s=new XMLHttpRequest;s.open("GET",t,true);s.responseType="blob";s.onload=function(e){if(this.status==200||this.status===0){i.readAsArrayBuffer(this.response)}};s.send()}},false);f.style.display="none";a.appendChild(f);l.addEventListener("click",function(e){if(m.user_callback){h.snap(m.user_callback,m.user_canvas)}else{f.style.display="block";f.focus();f.click();f.style.display="none"}},false);a.appendChild(l);this.loaded=true;this.live=true}else if(this.params.enable_flash&&this.detectFlash()){e.Webcam=Webcam;var l=document.createElement("div");l.innerHTML=this.getSWFHTML();a.appendChild(l)}else{this.dispatch("error",new i(this.params.noInterfaceFoundText))}if(this.params.crop_width&&this.params.crop_height){var p=Math.floor(this.params.crop_width*r);var u=Math.floor(this.params.crop_height*o);a.style.width=""+p+"px";a.style.height=""+u+"px";a.style.overflow="hidden";a.scrollLeft=Math.floor(this.params.width/2-p/2);a.scrollTop=Math.floor(this.params.height/2-u/2)}else{a.style.width=""+this.params.width+"px";a.style.height=""+this.params.height+"px"}},reset:function(){if(this.preview_active)this.unfreeze();this.unflip();if(this.userMedia){if(this.stream){if(this.stream.getVideoTracks){var e=this.stream.getVideoTracks();if(e&&e[0]&&e[0].stop)e[0].stop()}else if(this.stream.stop){this.stream.stop()}}delete this.stream;delete this.video}if(this.userMedia!==true&&this.loaded&&!this.iOS){var t=this.getMovie();if(t&&t._releaseCamera)t._releaseCamera()}if(this.container){this.container.innerHTML="";delete this.container}this.loaded=false;this.live=false},set:function(){if(arguments.length==1){for(var e in arguments[0]){this.params[e]=arguments[0][e]}}else{this.params[arguments[0]]=arguments[1]}},on:function(e,t){e=e.replace(/^on/i,"").toLowerCase();if(!this.hooks[e])this.hooks[e]=[];this.hooks[e].push(t)},off:function(e,t){e=e.replace(/^on/i,"").toLowerCase();if(this.hooks[e]){if(t){var a=this.hooks[e].indexOf(t);if(a>-1)this.hooks[e].splice(a,1)}else{this.hooks[e]=[]}}},dispatch:function(){var t=arguments[0].replace(/^on/i,"").toLowerCase();var s=Array.prototype.slice.call(arguments,1);if(this.hooks[t]&&this.hooks[t].length){for(var r=0,o=this.hooks[t].length;rERROR: the Webcam.js Flash fallback does not work from local disk. Please run it from a web server.'}if(!this.detectFlash()){this.dispatch("error",new a("Adobe Flash Player not found. Please install from get.adobe.com/flashplayer and try again."));return'

'+this.params.flashNotDetectedText+"

"}if(!i){var s="";var r=document.getElementsByTagName("script");for(var o=0,n=r.length;o';return t},getMovie:function(){if(!this.loaded)return this.dispatch("error",new a("Flash Movie is not loaded yet"));var e=document.getElementById("webcam_movie_obj");if(!e||!e._snap)e=document.getElementById("webcam_movie_embed");if(!e)this.dispatch("error",new a("Cannot locate Flash movie in DOM"));return e},freeze:function(){var e=this;var t=this.params;if(this.preview_active)this.unfreeze();var a=this.params.width/this.params.dest_width;var i=this.params.height/this.params.dest_height;this.unflip();var s=t.crop_width||t.dest_width;var r=t.crop_height||t.dest_height;var o=document.createElement("canvas");o.width=s;o.height=r;var n=o.getContext("2d");this.preview_canvas=o;this.preview_context=n;if(a!=1||i!=1){o.style.webkitTransformOrigin="0px 0px";o.style.mozTransformOrigin="0px 0px";o.style.msTransformOrigin="0px 0px";o.style.oTransformOrigin="0px 0px";o.style.transformOrigin="0px 0px";o.style.webkitTransform="scaleX("+a+") scaleY("+i+")";o.style.mozTransform="scaleX("+a+") scaleY("+i+")";o.style.msTransform="scaleX("+a+") scaleY("+i+")";o.style.oTransform="scaleX("+a+") scaleY("+i+")";o.style.transform="scaleX("+a+") scaleY("+i+")"}this.snap(function(){o.style.position="relative";o.style.left=""+e.container.scrollLeft+"px";o.style.top=""+e.container.scrollTop+"px";e.container.insertBefore(o,e.peg);e.container.style.overflow="hidden";e.preview_active=true},o)},unfreeze:function(){if(this.preview_active){this.container.removeChild(this.preview_canvas);delete this.preview_context;delete this.preview_canvas;this.preview_active=false;this.flip()}},flip:function(){if(this.params.flip_horiz){var e=this.container.style;e.webkitTransform="scaleX(-1)";e.mozTransform="scaleX(-1)";e.msTransform="scaleX(-1)";e.oTransform="scaleX(-1)";e.transform="scaleX(-1)";e.filter="FlipH";e.msFilter="FlipH"}},unflip:function(){if(this.params.flip_horiz){var e=this.container.style;e.webkitTransform="scaleX(1)";e.mozTransform="scaleX(1)";e.msTransform="scaleX(1)";e.oTransform="scaleX(1)";e.transform="scaleX(1)";e.filter="";e.msFilter=""}},savePreview:function(e,t){var a=this.params;var i=this.preview_canvas;var s=this.preview_context;if(t){var r=t.getContext("2d");r.drawImage(i,0,0)}e(t?null:i.toDataURL("image/"+a.image_format,a.jpeg_quality/100),i,s);if(this.params.unfreeze_snap)this.unfreeze()},snap:function(e,t){if(!e)e=this.params.user_callback;if(!t)t=this.params.user_canvas;var a=this;var s=this.params;if(!this.loaded)return this.dispatch("error",new i("Webcam is not loaded yet"));if(!e)return this.dispatch("error",new i("Please provide a callback function or canvas to snap()"));if(this.preview_active){this.savePreview(e,t);return null}var r=document.createElement("canvas");r.width=this.params.dest_width;r.height=this.params.dest_height;var o=r.getContext("2d");if(this.params.flip_horiz){o.translate(s.dest_width,0);o.scale(-1,1)}var n=function(){if(this.src&&this.width&&this.height){o.drawImage(this,0,0,s.dest_width,s.dest_height)}if(s.crop_width&&s.crop_height){var a=document.createElement("canvas");a.width=s.crop_width;a.height=s.crop_height;var i=a.getContext("2d");i.drawImage(r,Math.floor(s.dest_width/2-s.crop_width/2),Math.floor(s.dest_height/2-s.crop_height/2),s.crop_width,s.crop_height,0,0,s.crop_width,s.crop_height);o=i;r=a}if(t){var n=t.getContext("2d");n.drawImage(r,0,0)}e(t?null:r.toDataURL("image/"+s.image_format,s.jpeg_quality/100),r,o)};if(this.userMedia){o.drawImage(this.video,0,0,this.params.dest_width,this.params.dest_height);n()}else if(this.iOS){var h=document.getElementById(this.container.id+"-ios_div");var l=document.getElementById(this.container.id+"-ios_img");var c=document.getElementById(this.container.id+"-ios_input");iFunc=function(e){n.call(l);l.removeEventListener("load",iFunc);h.style.backgroundImage="none";l.removeAttribute("src");c.value=null};if(!c.value){l.addEventListener("load",iFunc);c.style.display="block";c.focus();c.click();c.style.display="none"}else{iFunc(null)}}else{var d=this.getMovie()._snap();var l=new Image;l.onload=n;l.src="data:image/"+this.params.image_format+";base64,"+d}return null},configure:function(e){if(!e)e="camera";this.getMovie()._configure(e)},flashNotify:function(e,t){switch(e){case"flashLoadComplete":this.loaded=true;this.dispatch("load");break;case"cameraLive":this.live=true;this.dispatch("live");break;case"error":this.dispatch("error",new a(t));break;default:break}},b64ToUint6:function(e){return e>64&&e<91?e-65:e>96&&e<123?e-71:e>47&&e<58?e+4:e===43?62:e===47?63:0},base64DecToArr:function(e,t){var a=e.replace(/[^A-Za-z0-9\+\/]/g,""),i=a.length,s=t?Math.ceil((i*3+1>>2)/t)*t:i*3+1>>2,r=new Uint8Array(s);for(var o,n,h=0,l=0,c=0;c>>(16>>>o&24)&255}h=0}}return r},upload:function(e,t,a){var i=this.params.upload_name||"webcam";var s="";if(e.match(/^data\:image\/(\w+)/))s=RegExp.$1;else throw"Cannot locate image format in Data URI";var r=e.replace(/^data\:image\/\w+\;base64\,/,"");var o=new XMLHttpRequest;o.open("POST",t,true);if(o.upload&&o.upload.addEventListener){o.upload.addEventListener("progress",function(e){if(e.lengthComputable){var t=e.loaded/e.total;Webcam.dispatch("uploadProgress",t,e)}},false)}var n=this;o.onload=function(){if(a)a.apply(n,[o.status,o.responseText,o.statusText]);Webcam.dispatch("uploadComplete",o.status,o.responseText,o.statusText)};var h=new Blob([this.base64DecToArr(r)],{type:"image/"+s});var l=new FormData;l.append(i,h,i+"."+s.replace(/e/,""));o.send(l)}};Webcam.init();if(typeof define==="function"&&define.amd){define(function(){return Webcam})}else if(typeof module==="object"&&module.exports){module.exports=Webcam}else{e.Webcam=Webcam}})(window); \ No newline at end of file From 9d43911c8321c6c4e3b22f8b31c93180fbec9c38 Mon Sep 17 00:00:00 2001 From: Achilles Rasquinha Date: Mon, 25 Sep 2017 21:46:58 +0530 Subject: [PATCH 14/52] added shields --- README.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 5e3c1f83e0..40d8049c70 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,14 @@
-[![Build Status](https://travis-ci.org/frappe/frappe.png)](https://travis-ci.org/frappe/frappe) +
Full-stack web application framework that uses Python and MariaDB on the server side and a tightly integrated client side library. Built for [ERPNext](https://erpnext.com) From d58e6b65e9f33a626921b6c4b653a614a5c1eb1e Mon Sep 17 00:00:00 2001 From: Achilles Rasquinha Date: Mon, 25 Sep 2017 21:51:25 +0530 Subject: [PATCH 15/52] updated LICENSE, helps to index --- LICENSE | 21 +++++++++++++++++++++ README.md | 7 +++++-- license.txt | 9 --------- 3 files changed, 26 insertions(+), 11 deletions(-) create mode 100644 LICENSE delete mode 100644 license.txt diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000000..956e51befb --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +The MIT License + +Copyright (c) 2016-2017 Frappé Technologies Pvt. Ltd. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. \ No newline at end of file diff --git a/README.md b/README.md index 40d8049c70..b8427fc055 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,10 @@ Full-stack web application framework that uses Python and MariaDB on the server side and a tightly integrated client side library. Built for [ERPNext](https://erpnext.com) +### Table of Contents +* [Installation](#installation) +* [License](#license) + ### Installation [Install via Frappé Bench](https://github.com/frappe/bench) @@ -40,5 +44,4 @@ For details and documentation, see the website [https://frappe.io](https://frappe.io) ### License - -MIT License +This repository has been released under the [MIT License](LICENSE). diff --git a/license.txt b/license.txt deleted file mode 100644 index a76f4ef0ba..0000000000 --- a/license.txt +++ /dev/null @@ -1,9 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2016 Frappe Technologies Pvt. Ltd. - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. From 5713c1454a4a4663e5ecc5ce2d07d02a4d77ba94 Mon Sep 17 00:00:00 2001 From: Achilles Rasquinha Date: Tue, 26 Sep 2017 00:48:58 +0530 Subject: [PATCH 16/52] [MAJOR] functional frappe.ui.Capture :dancer: --- frappe/public/build.json | 6 +- .../js/frappe/form/controls/text_editor.js | 8 +- frappe/public/js/frappe/ui/camera.js | 67 ------------- frappe/public/js/frappe/ui/capture.js | 94 +++++++++++++++++++ 4 files changed, 103 insertions(+), 72 deletions(-) delete mode 100644 frappe/public/js/frappe/ui/camera.js create mode 100644 frappe/public/js/frappe/ui/capture.js diff --git a/frappe/public/build.json b/frappe/public/build.json index 410f398ab2..b70d410f25 100755 --- a/frappe/public/build.json +++ b/frappe/public/build.json @@ -24,7 +24,7 @@ ], "js/control.min.js": [ - "public/js/frappe/ui/camera.js", + "public/js/frappe/ui/capture.js", "public/js/frappe/form/controls/base_control.js", "public/js/frappe/form/controls/base_input.js", @@ -67,7 +67,7 @@ "public/js/frappe/form/multi_select_dialog.js", "public/js/frappe/ui/dialog.js", - "public/js/frappe/ui/camera.js", + "public/js/frappe/ui/capture.js", "public/js/frappe/form/controls/base_control.js", "public/js/frappe/form/controls/base_input.js", @@ -179,7 +179,7 @@ "public/js/frappe/form/multi_select_dialog.js", "public/js/frappe/ui/dialog.js", - "public/js/frappe/ui/camera.js", + "public/js/frappe/ui/capture.js", "public/js/frappe/ui/app_icon.js", diff --git a/frappe/public/js/frappe/form/controls/text_editor.js b/frappe/public/js/frappe/form/controls/text_editor.js index 3a82a7af6d..5904ae8ec1 100644 --- a/frappe/public/js/frappe/form/controls/text_editor.js +++ b/frappe/public/js/frappe/form/controls/text_editor.js @@ -13,8 +13,12 @@ frappe.ui.form.ControlTextEditor = frappe.ui.form.ControlCode.extend({ contents: '', tooltip: 'Camera', click: () => { - const camera = new frappe.ui.Camera(); - camera.show(); + const capture = new frappe.ui.Capture(); + capture.open(); + + capture.click((data) => { + context.invoke('editor.insertImage', data); + }); } }); diff --git a/frappe/public/js/frappe/ui/camera.js b/frappe/public/js/frappe/ui/camera.js deleted file mode 100644 index 733471d86e..0000000000 --- a/frappe/public/js/frappe/ui/camera.js +++ /dev/null @@ -1,67 +0,0 @@ -frappe.ui.Camera = class -{ - constructor (options) - { - this.dialog = new frappe.ui.Dialog(); - - this.template = - ` -
- -
- ` - - this.show = this.show.bind(this); - this.hide = this.hide.bind(this); - this.on = this.on.bind(this); - this.attach = this.attach.bind(this); - - Webcam.set({ - width: 320, - height: 240, - flip_horiz: true, - }) - } - - show ( ) - { - this.attach((err) => { - if ( err ) - throw Error('Unable to attach webcamera.'); - - this.dialog.set_primary_action(__('Click'), () => { - this.click(); - }); - - this.dialog.show(); - }); - } - - hide ( ) - { - this.dialog.hide(); - } - - on (event, callback) - { - if ( event == 'attach' ) { - this.attach(callback); - } - } - - click (callback) - { - Webcam.snap((data) => { - console.log(data); - }); - } - - attach (callback) - { - $(this.dialog.body).append(this.template); - - Webcam.attach('#frappe-camera'); - - callback(); - } -}; \ No newline at end of file diff --git a/frappe/public/js/frappe/ui/capture.js b/frappe/public/js/frappe/ui/capture.js new file mode 100644 index 0000000000..9ce7b8431e --- /dev/null +++ b/frappe/public/js/frappe/ui/capture.js @@ -0,0 +1,94 @@ +frappe.ui.Capture = class +{ + constructor (options) + { + this.options = + { + width: 480, height: 320, flip_horiz: true + }; + + this.dialog = new frappe.ui.Dialog(); + this.template = + ` +
+
+
+
+
+ +
+
+
+ + + +
+
+ + +
+
+
+ `; + $(this.dialog.body).append(this.template); + + this.$btnBarSnap = $(this.dialog.body).find('#frappe-capture-btn-toolbar-snap'); + this.$btnBarKnap = $(this.dialog.body).find('#frappe-capture-btn-toolbar-knap'); + this.$btnBarKnap.hide(); + + Webcam.set(this.options); + } + + open ( ) + { + this.dialog.show(); + + Webcam.attach('#frappe-capture'); + } + + freeze ( ) + { + this.$btnBarSnap.hide(); + this.$btnBarKnap.show(); + + Webcam.freeze(); + } + + unfreeze ( ) + { + this.$btnBarSnap.show(); + this.$btnBarKnap.hide(); + + Webcam.unfreeze(); + } + + click (callback) + { + $(this.dialog.body).find('#frappe-capture-btn-snap').click(() => { + this.freeze(); + + $(this.dialog.body).find('#frappe-capture-btn-discard').click(() => { + this.unfreeze(); + }); + + $(this.dialog.body).find('#frappe-capture-btn-accept').click(() => { + Webcam.snap((data) => { + callback(data); + }); + + this.hide(); + }); + }); + } + + hide ( ) + { + Webcam.reset(); + + $(this.dialog.$wrapper).remove(); + } +}; \ No newline at end of file From c582e7ae46609c97089f4569505b2e33c11ad5ba Mon Sep 17 00:00:00 2001 From: Achilles Rasquinha Date: Tue, 26 Sep 2017 09:43:55 +0530 Subject: [PATCH 17/52] fixed codacy --- frappe/public/js/frappe/ui/capture.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/frappe/public/js/frappe/ui/capture.js b/frappe/public/js/frappe/ui/capture.js index 9ce7b8431e..1b1d2ff2f0 100644 --- a/frappe/public/js/frappe/ui/capture.js +++ b/frappe/public/js/frappe/ui/capture.js @@ -1,13 +1,9 @@ -frappe.ui.Capture = class +frappe.ui.Capture = class { - constructor (options) + constructor (options = { }) { - this.options = - { - width: 480, height: 320, flip_horiz: true - }; - - this.dialog = new frappe.ui.Dialog(); + this.options = Object.assign({}, frappe.ui.Capture.DEFAULT_OPTIONS, options); + this.dialog = new frappe.ui.Dialog(); this.template = `
@@ -91,4 +87,8 @@ frappe.ui.Capture = class $(this.dialog.$wrapper).remove(); } -}; \ No newline at end of file +}; +frappe.ui.Capture.DEFAULT_OPTIONS = +{ + width: 480, height: 320, flip_horiz: true +} \ No newline at end of file From 94133c022e1b464c24ba89afe50536828f46d43a Mon Sep 17 00:00:00 2001 From: Achilles Rasquinha Date: Tue, 26 Sep 2017 09:51:19 +0530 Subject: [PATCH 18/52] spaces to tabs - codacy --- frappe/public/js/frappe/ui/capture.js | 148 +++++++++++++------------- 1 file changed, 74 insertions(+), 74 deletions(-) diff --git a/frappe/public/js/frappe/ui/capture.js b/frappe/public/js/frappe/ui/capture.js index 1b1d2ff2f0..184d7b10d1 100644 --- a/frappe/public/js/frappe/ui/capture.js +++ b/frappe/public/js/frappe/ui/capture.js @@ -1,94 +1,94 @@ frappe.ui.Capture = class { - constructor (options = { }) - { - this.options = Object.assign({}, frappe.ui.Capture.DEFAULT_OPTIONS, options); - this.dialog = new frappe.ui.Dialog(); - this.template = - ` -
-
-
-
-
+ constructor (options = { }) + { + this.options = Object.assign({}, frappe.ui.Capture.DEFAULT_OPTIONS, options); + this.dialog = new frappe.ui.Dialog(); + this.template = + ` +
+
+
+
+
-
-
-
- - - -
-
- - -
-
-
- `; - $(this.dialog.body).append(this.template); +
+
+
+ + + +
+
+ + +
+
+
+ `; + $(this.dialog.body).append(this.template); - this.$btnBarSnap = $(this.dialog.body).find('#frappe-capture-btn-toolbar-snap'); - this.$btnBarKnap = $(this.dialog.body).find('#frappe-capture-btn-toolbar-knap'); - this.$btnBarKnap.hide(); + this.$btnBarSnap = $(this.dialog.body).find('#frappe-capture-btn-toolbar-snap'); + this.$btnBarKnap = $(this.dialog.body).find('#frappe-capture-btn-toolbar-knap'); + this.$btnBarKnap.hide(); - Webcam.set(this.options); - } + Webcam.set(this.options); + } - open ( ) - { - this.dialog.show(); + open ( ) + { + this.dialog.show(); - Webcam.attach('#frappe-capture'); - } + Webcam.attach('#frappe-capture'); + } - freeze ( ) - { - this.$btnBarSnap.hide(); - this.$btnBarKnap.show(); - - Webcam.freeze(); - } + freeze ( ) + { + this.$btnBarSnap.hide(); + this.$btnBarKnap.show(); + + Webcam.freeze(); + } - unfreeze ( ) - { - this.$btnBarSnap.show(); - this.$btnBarKnap.hide(); + unfreeze ( ) + { + this.$btnBarSnap.show(); + this.$btnBarKnap.hide(); - Webcam.unfreeze(); - } + Webcam.unfreeze(); + } - click (callback) - { - $(this.dialog.body).find('#frappe-capture-btn-snap').click(() => { - this.freeze(); + click (callback) + { + $(this.dialog.body).find('#frappe-capture-btn-snap').click(() => { + this.freeze(); - $(this.dialog.body).find('#frappe-capture-btn-discard').click(() => { - this.unfreeze(); - }); + $(this.dialog.body).find('#frappe-capture-btn-discard').click(() => { + this.unfreeze(); + }); - $(this.dialog.body).find('#frappe-capture-btn-accept').click(() => { - Webcam.snap((data) => { - callback(data); - }); + $(this.dialog.body).find('#frappe-capture-btn-accept').click(() => { + Webcam.snap((data) => { + callback(data); + }); - this.hide(); - }); - }); - } + this.hide(); + }); + }); + } - hide ( ) - { - Webcam.reset(); + hide ( ) + { + Webcam.reset(); - $(this.dialog.$wrapper).remove(); - } + $(this.dialog.$wrapper).remove(); + } }; frappe.ui.Capture.DEFAULT_OPTIONS = { - width: 480, height: 320, flip_horiz: true + width: 480, height: 320, flip_horiz: true } \ No newline at end of file From 2816e9f54df609639d349c947778ecba331221c9 Mon Sep 17 00:00:00 2001 From: Achilles Rasquinha Date: Tue, 26 Sep 2017 10:01:40 +0530 Subject: [PATCH 19/52] renamed make_copy_force to reset --- frappe/build.py | 8 ++++---- frappe/commands/utils.py | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/frappe/build.py b/frappe/build.py index 9421ca7e47..f33fb560cd 100644 --- a/frappe/build.py +++ b/frappe/build.py @@ -26,12 +26,12 @@ def setup(): except ImportError: pass app_paths = [os.path.dirname(pymodule.__file__) for pymodule in pymodules] -def bundle(no_compress, make_copy=False, make_copy_force=False, verbose=False): +def bundle(no_compress, make_copy=False, reset=False, verbose=False): """concat / minify js files""" # build js files setup() - make_asset_dirs(make_copy=make_copy, make_copy_force = make_copy_force) + make_asset_dirs(make_copy=make_copy, reset = reset) # new nodejs build system command = 'node --use_strict ../apps/frappe/frappe/build.js --build' @@ -61,7 +61,7 @@ def watch(no_compress): # time.sleep(3) -def make_asset_dirs(make_copy=False, make_copy_force=False): +def make_asset_dirs(make_copy=False, reset=False): # don't even think of making assets_path absolute - rm -rf ahead. assets_path = os.path.join(frappe.local.sites_path, "assets") for dir_path in [ @@ -83,7 +83,7 @@ def make_asset_dirs(make_copy=False, make_copy_force=False): for source, target in symlinks: source = os.path.abspath(source) if os.path.exists(source): - if make_copy_force: + if reset: if os.path.exists(target): if os.path.islink(target): os.unlink(target) diff --git a/frappe/commands/utils.py b/frappe/commands/utils.py index 9fa1ff3dbe..fa15e67f9b 100644 --- a/frappe/commands/utils.py +++ b/frappe/commands/utils.py @@ -7,14 +7,14 @@ from frappe.commands import pass_context, get_site @click.command('build') @click.option('--make-copy', is_flag=True, default=False, help='Copy the files instead of symlinking') -@click.option('--make-copy-force', is_flag=True, default=False, help='Copy the files instead of symlinking with force') +@click.option('--reset', is_flag=True, default=False, help='Copy the files instead of symlinking with force') @click.option('--verbose', is_flag=True, default=False, help='Verbose') -def build(make_copy=False, make_copy_force = False, verbose=False): +def build(make_copy=False, reset = False, verbose=False): "Minify + concatenate JS and CSS files, build translations" import frappe.build import frappe frappe.init('') - frappe.build.bundle(False, make_copy=make_copy, make_copy_force = make_copy_force, verbose=verbose) + frappe.build.bundle(False, make_copy=make_copy, reset = reset, verbose=verbose) @click.command('watch') def watch(): From 6d764e7ac54e5331a92c11cb0edf18c8edc23c34 Mon Sep 17 00:00:00 2001 From: Achilles Rasquinha Date: Tue, 26 Sep 2017 10:03:19 +0530 Subject: [PATCH 20/52] fixed codacy --- frappe/public/js/frappe/ui/capture.js | 2 +- setup.py | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/frappe/public/js/frappe/ui/capture.js b/frappe/public/js/frappe/ui/capture.js index 184d7b10d1..f555243975 100644 --- a/frappe/public/js/frappe/ui/capture.js +++ b/frappe/public/js/frappe/ui/capture.js @@ -91,4 +91,4 @@ frappe.ui.Capture = class frappe.ui.Capture.DEFAULT_OPTIONS = { width: 480, height: 320, flip_horiz: true -} \ No newline at end of file +}; \ No newline at end of file diff --git a/setup.py b/setup.py index 87c0116832..466449e956 100644 --- a/setup.py +++ b/setup.py @@ -35,7 +35,6 @@ class CleanCommand(Clean): if extension in ['.pyc']: abspath = os.path.join(dirpath, filename) os.remove(abspath) - for dirname in dirnames: if dirname in ['__pycache__']: abspath = os.path.join(dirpath, dirname) From e8b6c95a6a4f1007775d6ca3ededb8209b20a7d6 Mon Sep 17 00:00:00 2001 From: Achilles Rasquinha Date: Tue, 26 Sep 2017 10:06:03 +0530 Subject: [PATCH 21/52] [minor] wiggling needs to be falsified when cleared --- frappe/core/page/desktop/desktop.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/frappe/core/page/desktop/desktop.js b/frappe/core/page/desktop/desktop.js index 2c8210c364..bd3bbfc2f5 100644 --- a/frappe/core/page/desktop/desktop.js +++ b/frappe/core/page/desktop/desktop.js @@ -154,6 +154,8 @@ $.extend(frappe.desktop, { $notis.show(); $icons.trigger('stopRumble'); + + wiggling = false; }; // initiate wiggling. From fda767d9af6b2c9c4971ed3d39dc8b3f7af293d5 Mon Sep 17 00:00:00 2001 From: Achilles Rasquinha Date: Tue, 26 Sep 2017 11:50:29 +0530 Subject: [PATCH 22/52] added Webcam to globals --- .eslintrc | 1 + 1 file changed, 1 insertion(+) diff --git a/.eslintrc b/.eslintrc index f94193e00e..4ea7f0edff 100644 --- a/.eslintrc +++ b/.eslintrc @@ -54,6 +54,7 @@ "Taggle": true, "Gantt": true, "Slick": true, + "Webcam": true, "PhotoSwipe": true, "PhotoSwipeUI_Default": true, "fluxify": true, From 7a878e543c16dccfa779b23d0885a3c14f3d08a7 Mon Sep 17 00:00:00 2001 From: Sunny Date: Tue, 26 Sep 2017 17:50:23 +0800 Subject: [PATCH 23/52] Add Email option to Address email_id field --- frappe/contacts/doctype/address/address.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/frappe/contacts/doctype/address/address.json b/frappe/contacts/doctype/address/address.json index c3b655cec5..d663957580 100644 --- a/frappe/contacts/doctype/address/address.json +++ b/frappe/contacts/doctype/address/address.json @@ -353,7 +353,8 @@ "label": "Email Address", "length": 0, "no_copy": 0, - "permlevel": 0, + "options": "Email", + "permlevel": 0, "print_hide": 0, "print_hide_if_no_value": 0, "read_only": 0, From 9416df270dc9f9920b8c9689be9537c482c9146c Mon Sep 17 00:00:00 2001 From: Achilles Rasquinha Date: Tue, 26 Sep 2017 15:44:04 +0530 Subject: [PATCH 24/52] [BUG] fixed, changed to --restore, reset is a flag for test_runner --- frappe/build.py | 8 ++++---- frappe/commands/utils.py | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/frappe/build.py b/frappe/build.py index f33fb560cd..e0ce46f923 100644 --- a/frappe/build.py +++ b/frappe/build.py @@ -26,12 +26,12 @@ def setup(): except ImportError: pass app_paths = [os.path.dirname(pymodule.__file__) for pymodule in pymodules] -def bundle(no_compress, make_copy=False, reset=False, verbose=False): +def bundle(no_compress, make_copy=False, restore=False, verbose=False): """concat / minify js files""" # build js files setup() - make_asset_dirs(make_copy=make_copy, reset = reset) + make_asset_dirs(make_copy=make_copy, restore=restore) # new nodejs build system command = 'node --use_strict ../apps/frappe/frappe/build.js --build' @@ -61,7 +61,7 @@ def watch(no_compress): # time.sleep(3) -def make_asset_dirs(make_copy=False, reset=False): +def make_asset_dirs(make_copy=False, restore=False): # don't even think of making assets_path absolute - rm -rf ahead. assets_path = os.path.join(frappe.local.sites_path, "assets") for dir_path in [ @@ -83,7 +83,7 @@ def make_asset_dirs(make_copy=False, reset=False): for source, target in symlinks: source = os.path.abspath(source) if os.path.exists(source): - if reset: + if restore: if os.path.exists(target): if os.path.islink(target): os.unlink(target) diff --git a/frappe/commands/utils.py b/frappe/commands/utils.py index fa15e67f9b..c833a5b1a3 100644 --- a/frappe/commands/utils.py +++ b/frappe/commands/utils.py @@ -7,14 +7,14 @@ from frappe.commands import pass_context, get_site @click.command('build') @click.option('--make-copy', is_flag=True, default=False, help='Copy the files instead of symlinking') -@click.option('--reset', is_flag=True, default=False, help='Copy the files instead of symlinking with force') +@click.option('--restore', is_flag=True, default=False, help='Copy the files instead of symlinking with force') @click.option('--verbose', is_flag=True, default=False, help='Verbose') -def build(make_copy=False, reset = False, verbose=False): +def build(make_copy=False, restore = False, verbose=False): "Minify + concatenate JS and CSS files, build translations" import frappe.build import frappe frappe.init('') - frappe.build.bundle(False, make_copy=make_copy, reset = reset, verbose=verbose) + frappe.build.bundle(False, make_copy=make_copy, restore = restore, verbose=verbose) @click.command('watch') def watch(): From 5ac84f968342b9e820e3aab6c50f57c64cb87871 Mon Sep 17 00:00:00 2001 From: Achilles Rasquinha Date: Wed, 27 Sep 2017 23:30:00 +0530 Subject: [PATCH 25/52] Update requirements.txt --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 44a441e34d..798933fe25 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,7 +6,7 @@ httplib2 jinja2 markdown2 markupsafe -mysqlclient==1.3.10 +https://github.com/PyMySQL/mysqlclient-python/archive/master.zip python-geoip python-geoip-geolite2 python-dateutil From 65a1cede89b9a8a1cd9f6264a1b79d31e268454a Mon Sep 17 00:00:00 2001 From: Achilles Rasquinha Date: Thu, 28 Sep 2017 11:49:29 +0530 Subject: [PATCH 26/52] Fixed mysqclient dependency --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 798933fe25..44a441e34d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,7 +6,7 @@ httplib2 jinja2 markdown2 markupsafe -https://github.com/PyMySQL/mysqlclient-python/archive/master.zip +mysqlclient==1.3.10 python-geoip python-geoip-geolite2 python-dateutil From a33512aa38e48425c96a892385fff1ee096d9cd9 Mon Sep 17 00:00:00 2001 From: Achilles Rasquinha Date: Thu, 28 Sep 2017 12:35:52 +0530 Subject: [PATCH 27/52] added node_modules, working on webpack --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 4dd4f3f6ce..436a08414e 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,4 @@ dist/ build/ frappe/docs/current .vscode +node_modules \ No newline at end of file From ea030bcb9eacc4229eae31daefe5042aad4e75ca Mon Sep 17 00:00:00 2001 From: Achilles Rasquinha Date: Thu, 28 Sep 2017 12:37:16 +0530 Subject: [PATCH 28/52] added setup_wiggle function --- frappe/core/page/desktop/desktop.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/frappe/core/page/desktop/desktop.js b/frappe/core/page/desktop/desktop.js index bd3bbfc2f5..2e1dc433a5 100644 --- a/frappe/core/page/desktop/desktop.js +++ b/frappe/core/page/desktop/desktop.js @@ -132,6 +132,10 @@ $.extend(frappe.desktop, { } }); + this.setup_wiggle() + }, + + setup_wiggle: () => { // Wiggle, Wiggle, Wiggle. const DURATION_LONG_PRESS = 1000; // lesser the antidode, more the wiggle (like your drunk uncle) From ae3099bfe4c1a3b472e3f941861a774e2e8a58d8 Mon Sep 17 00:00:00 2001 From: Achilles Rasquinha Date: Thu, 28 Sep 2017 12:38:41 +0530 Subject: [PATCH 29/52] removed whitespace --- frappe/public/build.json | 6 ------ 1 file changed, 6 deletions(-) diff --git a/frappe/public/build.json b/frappe/public/build.json index b70d410f25..8d10760cf1 100755 --- a/frappe/public/build.json +++ b/frappe/public/build.json @@ -23,9 +23,7 @@ "public/js/frappe/misc/rating_icons.html" ], "js/control.min.js": [ - "public/js/frappe/ui/capture.js", - "public/js/frappe/form/controls/base_control.js", "public/js/frappe/form/controls/base_input.js", "public/js/frappe/form/controls/data.js", @@ -59,14 +57,12 @@ "public/js/frappe/dom.js", "public/js/frappe/ui/modal.html", - "public/js/frappe/form/formatters.js", "public/js/frappe/form/layout.js", "public/js/frappe/ui/field_group.js", "public/js/frappe/form/link_selector.js", "public/js/frappe/form/multi_select_dialog.js", "public/js/frappe/ui/dialog.js", - "public/js/frappe/ui/capture.js", "public/js/frappe/form/controls/base_control.js", @@ -178,9 +174,7 @@ "public/js/frappe/form/link_selector.js", "public/js/frappe/form/multi_select_dialog.js", "public/js/frappe/ui/dialog.js", - "public/js/frappe/ui/capture.js", - "public/js/frappe/ui/app_icon.js", "public/js/frappe/model/model.js", From da76dd5f7a2a42d5667e98baaefb8c85c9af29c7 Mon Sep 17 00:00:00 2001 From: Achilles Rasquinha Date: Thu, 28 Sep 2017 12:42:45 +0530 Subject: [PATCH 30/52] added this.wiggling for scope call --- frappe/core/page/desktop/desktop.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/frappe/core/page/desktop/desktop.js b/frappe/core/page/desktop/desktop.js index 2e1dc433a5..114dbc97df 100644 --- a/frappe/core/page/desktop/desktop.js +++ b/frappe/core/page/desktop/desktop.js @@ -112,7 +112,7 @@ $.extend(frappe.desktop, { }, setup_module_click: function() { - var wiggling = false; // wiggle, wiggle, wiggle. + this.wiggling = false; // wiggle, wiggle, wiggle. if(frappe.list_desktop) { frappe.desktop.wrapper.on("click", ".desktop-list-item", function() { @@ -120,7 +120,7 @@ $.extend(frappe.desktop, { }); } else { frappe.desktop.wrapper.on("click", ".app-icon", function() { - if ( !wiggling ) { + if ( !this.wiggling ) { frappe.desktop.open_module($(this).parent()); } }); @@ -159,7 +159,7 @@ $.extend(frappe.desktop, { $icons.trigger('stopRumble'); - wiggling = false; + this.wiggling = false; }; // initiate wiggling. @@ -169,7 +169,7 @@ $.extend(frappe.desktop, { frappe.desktop.wrapper.on('mousedown', '.app-icon', () => { timer_id = setTimeout(() => { - wiggling = true; + this.wiggling = true; // hide all notifications. $notis.hide(); @@ -231,7 +231,7 @@ $.extend(frappe.desktop, { // also stop wiggling if clicked elsewhere. $('body').click((event) => { - if ( wiggling ) { + if ( this.wiggling ) { const $target = $(event.target); // our target shouldn't be .app-icons or .close const $parent = $target.parents('.case-wrapper'); From aeb00b7afad8fe51264ff03b9b0edb04f9b3ef6e Mon Sep 17 00:00:00 2001 From: Achilles Rasquinha Date: Thu, 28 Sep 2017 12:58:39 +0530 Subject: [PATCH 31/52] fixed codacy --- frappe/core/page/desktop/desktop.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frappe/core/page/desktop/desktop.js b/frappe/core/page/desktop/desktop.js index 114dbc97df..a0a605c679 100644 --- a/frappe/core/page/desktop/desktop.js +++ b/frappe/core/page/desktop/desktop.js @@ -132,7 +132,7 @@ $.extend(frappe.desktop, { } }); - this.setup_wiggle() + this.setup_wiggle(); }, setup_wiggle: () => { From 1e6916646a918b7c52aa31f1fc017b4a18647b13 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Thu, 28 Sep 2017 18:57:33 +0530 Subject: [PATCH 32/52] Remove name while appending row in child table --- frappe/model/base_document.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/frappe/model/base_document.py b/frappe/model/base_document.py index 4a5568b238..a0f16b5226 100644 --- a/frappe/model/base_document.py +++ b/frappe/model/base_document.py @@ -135,6 +135,11 @@ class BaseDocument(object): if not self.__dict__.get(key): self.__dict__[key] = [] value = self._init_child(value, key) + + # append will always add as a new row + if value.get("name"): + value.name = None + self.__dict__[key].append(value) # reference parent document From 5882fbd48b6e0edf32a685e53ac1d1c9a5665a66 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Thu, 28 Sep 2017 18:58:06 +0530 Subject: [PATCH 33/52] Create test records only if not exists in db --- frappe/test_runner.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/frappe/test_runner.py b/frappe/test_runner.py index 7723d0c7c6..3dff11e9d9 100644 --- a/frappe/test_runner.py +++ b/frappe/test_runner.py @@ -309,7 +309,8 @@ def make_test_objects(doctype, test_records=None, verbose=None, reset=False): else: d.set_new_name() - if d.name in (frappe.local.test_objects.get(d.doctype) or []) and not reset: + if frappe.db.exists(d.doctype, d.name) and not reset: + frappe.db.rollback() # do not create test records, if already exists return [] @@ -336,7 +337,7 @@ def make_test_objects(doctype, test_records=None, verbose=None, reset=False): records.append(d.name) - frappe.db.commit() + frappe.db.commit() return records From 17c6383a29522285b037c9b606155b145bd8f514 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Fri, 29 Sep 2017 10:53:37 +0530 Subject: [PATCH 34/52] Don't remove name while appending row --- frappe/model/base_document.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/frappe/model/base_document.py b/frappe/model/base_document.py index a0f16b5226..4a5568b238 100644 --- a/frappe/model/base_document.py +++ b/frappe/model/base_document.py @@ -135,11 +135,6 @@ class BaseDocument(object): if not self.__dict__.get(key): self.__dict__[key] = [] value = self._init_child(value, key) - - # append will always add as a new row - if value.get("name"): - value.name = None - self.__dict__[key].append(value) # reference parent document From 0aa0e79aa7570e3e2b0382be24fccc8a654ce841 Mon Sep 17 00:00:00 2001 From: Achilles Rasquinha Date: Fri, 29 Sep 2017 11:07:42 +0530 Subject: [PATCH 35/52] [fix] wiggling --- frappe/core/page/desktop/desktop.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/frappe/core/page/desktop/desktop.js b/frappe/core/page/desktop/desktop.js index a0a605c679..f3399cb6d6 100644 --- a/frappe/core/page/desktop/desktop.js +++ b/frappe/core/page/desktop/desktop.js @@ -112,7 +112,7 @@ $.extend(frappe.desktop, { }, setup_module_click: function() { - this.wiggling = false; // wiggle, wiggle, wiggle. + frappe.desktop.wiggling = false; if(frappe.list_desktop) { frappe.desktop.wrapper.on("click", ".desktop-list-item", function() { @@ -120,7 +120,7 @@ $.extend(frappe.desktop, { }); } else { frappe.desktop.wrapper.on("click", ".app-icon", function() { - if ( !this.wiggling ) { + if ( !frappe.desktop.wiggling ) { frappe.desktop.open_module($(this).parent()); } }); @@ -132,7 +132,7 @@ $.extend(frappe.desktop, { } }); - this.setup_wiggle(); + frappe.desktop.setup_wiggle(); }, setup_wiggle: () => { @@ -159,7 +159,7 @@ $.extend(frappe.desktop, { $icons.trigger('stopRumble'); - this.wiggling = false; + frappe.desktop.wiggling = false; }; // initiate wiggling. @@ -169,7 +169,7 @@ $.extend(frappe.desktop, { frappe.desktop.wrapper.on('mousedown', '.app-icon', () => { timer_id = setTimeout(() => { - this.wiggling = true; + frappe.desktop.wiggling = true; // hide all notifications. $notis.hide(); @@ -231,7 +231,7 @@ $.extend(frappe.desktop, { // also stop wiggling if clicked elsewhere. $('body').click((event) => { - if ( this.wiggling ) { + if ( frappe.desktop.wiggling ) { const $target = $(event.target); // our target shouldn't be .app-icons or .close const $parent = $target.parents('.case-wrapper'); From 97037ce3f34452b847a798a04e88b5dc7fc190f7 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Fri, 29 Sep 2017 13:14:14 +0530 Subject: [PATCH 36/52] Fixes in test_runner (#4213) --- frappe/test_runner.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frappe/test_runner.py b/frappe/test_runner.py index 3dff11e9d9..dd1fa8ac39 100644 --- a/frappe/test_runner.py +++ b/frappe/test_runner.py @@ -312,7 +312,7 @@ def make_test_objects(doctype, test_records=None, verbose=None, reset=False): if frappe.db.exists(d.doctype, d.name) and not reset: frappe.db.rollback() # do not create test records, if already exists - return [] + continue # submit if docstatus is set to 1 for test record docstatus = d.docstatus From e2d87e7887e41adf39eee1df613c66c4efc44881 Mon Sep 17 00:00:00 2001 From: Achilles Rasquinha Date: Fri, 29 Sep 2017 13:35:35 +0530 Subject: [PATCH 37/52] fix for mariadb@10.2 --- requirements.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/requirements.txt b/requirements.txt index 44a441e34d..0216f85690 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,7 +6,7 @@ httplib2 jinja2 markdown2 markupsafe -mysqlclient==1.3.10 +-e git+https://github.com/frappe/mysqlclient-python.git@1.3.12#egg=mysqlclient python-geoip python-geoip-geolite2 python-dateutil @@ -37,7 +37,7 @@ cryptography pyopenssl ndg-httpsclient pyasn1 -zxcvbn +zxcvbn-python psutil unittest-xml-reporting oauthlib From 05a447a349ab4ee1e620f19c4c9b705b3720b29b Mon Sep 17 00:00:00 2001 From: mbauskar Date: Fri, 29 Sep 2017 17:39:31 +0530 Subject: [PATCH 38/52] [minor] added the Created On and Last Modified On date fields in email alert's date_change --- .../email/doctype/email_alert/email_alert.js | 23 +++++++++++++------ 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/frappe/email/doctype/email_alert/email_alert.js b/frappe/email/doctype/email_alert/email_alert.js index 1ab87a9947..3f7423bc1b 100755 --- a/frappe/email/doctype/email_alert/email_alert.js +++ b/frappe/email/doctype/email_alert/email_alert.js @@ -6,13 +6,24 @@ frappe.email_alert = { } frappe.model.with_doctype(frm.doc.document_type, function() { - var get_select_options = function(df) { + let get_select_options = function(df) { return {value: df.fieldname, label: df.fieldname + " (" + __(df.label) + ")"}; } - var fields = frappe.get_doc("DocType", frm.doc.document_type).fields; + let get_date_change_options = function() { + let date_options = $.map(fields, function(d) { + return (d.fieldtype=="Date" || d.fieldtype=="Datetime")? + get_select_options(d) : null; + }); + // append creation and modified date to Date Change field + return date_options.concat([ + { value: "creation", label: `creation (${__('Created On')})` }, + { value: "modified", label: `modified (${__('Last Modified Date')})` } + ]); + } - var options = $.map(fields, + let fields = frappe.get_doc("DocType", frm.doc.document_type).fields; + let options = $.map(fields, function(d) { return in_list(frappe.model.no_value_type, d.fieldtype) ? null : get_select_options(d); }); @@ -21,11 +32,9 @@ frappe.email_alert = { frm.set_df_property("set_property_after_alert", "options", [""].concat(options)); // set date changed options - frm.set_df_property("date_changed", "options", $.map(fields, - function(d) { return (d.fieldtype=="Date" || d.fieldtype=="Datetime") ? - get_select_options(d) : null; })); + frm.set_df_property("date_changed", "options", get_date_change_options()); - var email_fields = $.map(fields, + let email_fields = $.map(fields, function(d) { return (d.options == "Email" || (d.options=='User' && d.fieldtype=='Link')) ? get_select_options(d) : null; }); From f6b080ba71c36f8b2702c9835dc639ebe4182ebc Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Fri, 29 Sep 2017 19:51:11 +0530 Subject: [PATCH 39/52] Don't validate links on cancellation (#4218) --- frappe/model/document.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frappe/model/document.py b/frappe/model/document.py index e71911e1a9..8e11b03b9d 100644 --- a/frappe/model/document.py +++ b/frappe/model/document.py @@ -631,7 +631,7 @@ class Document(BaseDocument): name=self.name)) def _validate_links(self): - if self.flags.ignore_links: + if self.flags.ignore_links or self._action == "cancel": return invalid_links, cancelled_links = self.get_invalid_links() From 0dff5607f2be701968d66171be9a2f3fd03853e7 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Sat, 30 Sep 2017 11:41:43 +0530 Subject: [PATCH 40/52] [version] 9.x.x-develop --- frappe/hooks.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frappe/hooks.py b/frappe/hooks.py index 9bdd8352a6..707b2fac37 100755 --- a/frappe/hooks.py +++ b/frappe/hooks.py @@ -11,7 +11,7 @@ app_color = "orange" source_link = "https://github.com/frappe/frappe" app_license = "MIT" -develop_version = '8.x.x-beta' +develop_version = '9.x.x-develop' app_email = "info@frappe.io" From 78995ceb3eaf470b3e6e84bea99f33e2ed6a5ddd Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Sat, 30 Sep 2017 14:41:28 +0530 Subject: [PATCH 41/52] [fix] text editor in firefox --- frappe/__init__.py | 4 +- .../doctype/communication/communication.py | 10 +-- frappe/core/doctype/communication/email.py | 3 - frappe/desk/doctype/todo/test_todo.js | 23 +++++++ frappe/desk/doctype/todo/todo.json | 18 ++--- .../doctype/email_account/email_account.py | 1 - frappe/model/document.py | 68 +++++++++++++------ .../js/frappe/form/controls/text_editor.js | 26 +++++-- frappe/public/js/frappe/socketio_client.js | 2 +- frappe/public/js/legacy/form.js | 2 +- 10 files changed, 110 insertions(+), 47 deletions(-) create mode 100644 frappe/desk/doctype/todo/test_todo.js diff --git a/frappe/__init__.py b/frappe/__init__.py index f049e8b85c..077e6ae52d 100644 --- a/frappe/__init__.py +++ b/frappe/__init__.py @@ -602,7 +602,7 @@ def set_value(doctype, docname, fieldname, value=None): import frappe.client return frappe.client.set_value(doctype, docname, fieldname, value) -def get_doc(arg1, arg2=None): +def get_doc(*args, **kwargs): """Return a `frappe.model.document.Document` object of the given type and name. :param arg1: DocType name as string **or** document JSON. @@ -619,7 +619,7 @@ def get_doc(arg1, arg2=None): """ import frappe.model.document - return frappe.model.document.get_doc(arg1, arg2) + return frappe.model.document.get_doc(*args, **kwargs) def get_last_doc(doctype): """Get last created document of this type.""" diff --git a/frappe/core/doctype/communication/communication.py b/frappe/core/doctype/communication/communication.py index ac25b97c73..af684fe802 100644 --- a/frappe/core/doctype/communication/communication.py +++ b/frappe/core/doctype/communication/communication.py @@ -25,7 +25,7 @@ class Communication(Document): """create email flag queue""" if self.communication_type == "Communication" and self.communication_medium == "Email" \ and self.sent_or_received == "Received" and self.uid and self.uid != -1: - + email_flag_queue = frappe.db.get_value("Email Flag Queue", { "communication": self.name, "is_completed": 0}) @@ -69,7 +69,7 @@ class Communication(Document): def after_insert(self): if not (self.reference_doctype and self.reference_name): return - + if self.reference_doctype == "Communication" and self.sent_or_received == "Sent": frappe.db.set_value("Communication", self.reference_name, "status", "Replied") @@ -264,7 +264,7 @@ def has_permission(doc, ptype, user): if (doc.reference_doctype == "Communication" and doc.reference_name == doc.name) \ or (doc.timeline_doctype == "Communication" and doc.timeline_name == doc.name): return - + if doc.reference_doctype and doc.reference_name: if frappe.has_permission(doc.reference_doctype, ptype="read", doc=doc.reference_name): return True @@ -277,7 +277,9 @@ def get_permission_query_conditions_for_communication(user): if not user: user = frappe.session.user - if "Super Email User" in frappe.get_roles(user): + roles = frappe.get_roles(user) + + if "Super Email User" in roles or "System Manager" in roles: return None else: accounts = frappe.get_all("User Email", filters={ "parent": user }, diff --git a/frappe/core/doctype/communication/email.py b/frappe/core/doctype/communication/email.py index 04bc906161..3eeb0fc059 100755 --- a/frappe/core/doctype/communication/email.py +++ b/frappe/core/doctype/communication/email.py @@ -166,9 +166,6 @@ def _notify(doc, print_html=None, print_format=None, attachments=None, def update_parent_status(doc): """Update status of parent document based on who is replying.""" - if doc.communication_type != "Communication": - return - parent = doc.get_parent_doc() if not parent: return diff --git a/frappe/desk/doctype/todo/test_todo.js b/frappe/desk/doctype/todo/test_todo.js new file mode 100644 index 0000000000..de508991cf --- /dev/null +++ b/frappe/desk/doctype/todo/test_todo.js @@ -0,0 +1,23 @@ +/* eslint-disable */ +// rename this file from _test_[name] to test_[name] to activate +// and remove above this line + +QUnit.test("test: ToDo", function (assert) { + let done = assert.async(); + + // number of asserts + assert.expect(1); + + frappe.run_serially([ + // insert a new ToDo + () => frappe.tests.make('ToDo', [ + // values to be set + {key: 'value'} + ]), + () => { + assert.equal(cur_frm.doc.key, 'value'); + }, + () => done() + ]); + +}); diff --git a/frappe/desk/doctype/todo/todo.json b/frappe/desk/doctype/todo/todo.json index 9f1b4ae452..ca70fd1006 100644 --- a/frappe/desk/doctype/todo/todo.json +++ b/frappe/desk/doctype/todo/todo.json @@ -112,20 +112,18 @@ "bold": 0, "collapsible": 0, "columns": 0, - "fieldname": "color", - "fieldtype": "Color", + "fieldname": "column_break_2", + "fieldtype": "Column Break", "hidden": 0, "ignore_user_permissions": 0, "ignore_xss_filter": 0, "in_filter": 0, "in_global_search": 0, - "in_list_view": 1, + "in_list_view": 0, "in_standard_filter": 0, - "label": "Color", "length": 0, "no_copy": 0, "permlevel": 0, - "precision": "", "print_hide": 0, "print_hide_if_no_value": 0, "read_only": 0, @@ -142,18 +140,20 @@ "bold": 0, "collapsible": 0, "columns": 0, - "fieldname": "column_break_2", - "fieldtype": "Column Break", + "fieldname": "color", + "fieldtype": "Color", "hidden": 0, "ignore_user_permissions": 0, "ignore_xss_filter": 0, "in_filter": 0, "in_global_search": 0, - "in_list_view": 0, + "in_list_view": 1, "in_standard_filter": 0, + "label": "Color", "length": 0, "no_copy": 0, "permlevel": 0, + "precision": "", "print_hide": 0, "print_hide_if_no_value": 0, "read_only": 0, @@ -544,7 +544,7 @@ "issingle": 0, "istable": 0, "max_attachments": 0, - "modified": "2017-09-05 12:54:58.044162", + "modified": "2017-09-30 13:57:29.398598", "modified_by": "Administrator", "module": "Desk", "name": "ToDo", diff --git a/frappe/email/doctype/email_account/email_account.py b/frappe/email/doctype/email_account/email_account.py index a36d461c60..7dbb71fd3f 100755 --- a/frappe/email/doctype/email_account/email_account.py +++ b/frappe/email/doctype/email_account/email_account.py @@ -273,7 +273,6 @@ class EmailAccount(Document): "uid_reindexed": uid_reindexed } communication = self.insert_communication(msg, args=args) - #self.notify_update() except SentEmailInInbox: frappe.db.rollback() diff --git a/frappe/model/document.py b/frappe/model/document.py index 8e11b03b9d..56a14cff8c 100644 --- a/frappe/model/document.py +++ b/frappe/model/document.py @@ -20,13 +20,13 @@ from frappe.integrations.doctype.webhook import run_webhooks # once_only validation # methods -def get_doc(arg1, arg2=None): +def get_doc(*args, **kwargs): """returns a frappe.model.Document object. :param arg1: Document dict or DocType name. :param arg2: [optional] document name. - There are two ways to call `get_doc` + There are multiple ways to call `get_doc` # will fetch the latest user object (with child table) from the database user = get_doc("User", "test@example.com") @@ -39,23 +39,39 @@ def get_doc(arg1, arg2=None): {"role": "System Manager"} ] }) + + # create new object with keyword arguments + user = get_doc(doctype='User', email_id='test@example.com') """ - if isinstance(arg1, BaseDocument): - return arg1 - elif isinstance(arg1, string_types): - doctype = arg1 - else: - doctype = arg1.get("doctype") + if args: + if isinstance(args[0], BaseDocument): + # already a document + return args[0] + elif isinstance(args[0], string_types): + doctype = args[0] + + elif isinstance(args[0], dict): + # passed a dict + kwargs = args[0] + + else: + raise ValueError('First non keyword argument must be a string or dict') + + if kwargs: + if 'doctype' in kwargs: + doctype = kwargs['doctype'] + else: + raise ValueError('"doctype" is a required key') controller = get_controller(doctype) if controller: - return controller(arg1, arg2) + return controller(*args, **kwargs) - raise ImportError(arg1) + raise ImportError(doctype) class Document(BaseDocument): """All controllers inherit from `Document`.""" - def __init__(self, arg1, arg2=None): + def __init__(self, *args, **kwargs): """Constructor. :param arg1: DocType name as string or document **dict** @@ -68,29 +84,37 @@ class Document(BaseDocument): self._default_new_docs = {} self.flags = frappe._dict() - if arg1 and isinstance(arg1, string_types): - if not arg2: + if args and args[0] and isinstance(args[0], string_types): + # first arugment is doctype + if len(args)==1: # single - self.doctype = self.name = arg1 + self.doctype = self.name = args[0] else: - self.doctype = arg1 - if isinstance(arg2, dict): + self.doctype = args[0] + if isinstance(args[1], dict): # filter - self.name = frappe.db.get_value(arg1, arg2, "name") + self.name = frappe.db.get_value(args[0], args[1], "name") if self.name is None: - frappe.throw(_("{0} {1} not found").format(_(arg1), arg2), frappe.DoesNotExistError) + frappe.throw(_("{0} {1} not found").format(_(args[0]), args[1]), + frappe.DoesNotExistError) else: - self.name = arg2 + self.name = args[1] self.load_from_db() + return + + if args and args[0] and isinstance(args[0], dict): + # first argument is a dict + kwargs = args[0] - elif isinstance(arg1, dict): - super(Document, self).__init__(arg1) + if kwargs: + # init base document + super(Document, self).__init__(kwargs) self.init_valid_columns() else: # incorrect arguments. let's not proceed. - raise frappe.DataError("Document({0}, {1})".format(arg1, arg2)) + raise ValueError('Illegal arguments') def reload(self): """Reload document from database""" diff --git a/frappe/public/js/frappe/form/controls/text_editor.js b/frappe/public/js/frappe/form/controls/text_editor.js index 5904ae8ec1..cd478f9f48 100644 --- a/frappe/public/js/frappe/form/controls/text_editor.js +++ b/frappe/public/js/frappe/form/controls/text_editor.js @@ -6,6 +6,11 @@ frappe.ui.form.ControlTextEditor = frappe.ui.form.ControlCode.extend({ this.setup_drag_drop(); this.setup_image_dialog(); this.setting_count = 0; + + $(document).on('form-refresh', () => { + // reset last keystroke when a new form is loaded + this.last_keystroke_on = null; + }) }, render_camera_button: (context) => { var ui = $.summernote.ui; @@ -74,7 +79,7 @@ frappe.ui.form.ControlTextEditor = frappe.ui.form.ControlCode.extend({ me.parse_validate_and_set_in_model(value); }, onKeydown: function(e) { - me._last_change_on = new Date(); + me.last_keystroke_on = new Date(); var key = frappe.ui.keys.get_key(e); // prevent 'New DocType (Ctrl + B)' shortcut in editor if(['ctrl+b', 'meta+b'].indexOf(key) !== -1) { @@ -205,20 +210,30 @@ frappe.ui.form.ControlTextEditor = frappe.ui.form.ControlCode.extend({ if(this.setting_count > 2) { // we don't understand how the internal triggers work, - // so if someone is setting the value third time, then quit + // so if someone is setting the value third time in 500ms, + // then quit return; } this.setting_count += 1; - let time_since_last_keystroke = moment() - moment(this._last_change_on); + let time_since_last_keystroke = moment() - moment(this.last_keystroke_on); - if(!this._last_change_on || (time_since_last_keystroke > 3000)) { + if(!this.last_keystroke_on || (time_since_last_keystroke > 3000)) { + // if 3 seconds have passed since the last keystroke and + // we have not set any value in the last 1 second, do this setTimeout(() => this.setting_count = 0, 500); this.editor.summernote('code', value || ''); + this.last_keystroke_on = null; } else { + // user is probably still in the middle of typing + // so lets not mess up the html by re-updating it + // keep checking every second if our 3 second barrier + // has been completed, so that we can refresh the html this._setting_value = setInterval(() => { if(time_since_last_keystroke > 3000) { + // 3 seconds done! lets refresh + // safe to update if(this.last_value !== this.get_input_value()) { // if not already in sync, reset this.editor.summernote('code', this.last_value || ''); @@ -226,6 +241,9 @@ frappe.ui.form.ControlTextEditor = frappe.ui.form.ControlCode.extend({ clearInterval(this._setting_value); this._setting_value = null; this.setting_count = 0; + + // clear timestamp of last keystroke + this.last_keystroke_on = null; } }, 1000); } diff --git a/frappe/public/js/frappe/socketio_client.js b/frappe/public/js/frappe/socketio_client.js index 1512f487e6..c7dd77594f 100644 --- a/frappe/public/js/frappe/socketio_client.js +++ b/frappe/public/js/frappe/socketio_client.js @@ -73,7 +73,7 @@ frappe.socketio = { frappe.socketio.doc_subscribe(frm.doctype, frm.docname); }); - $(document).on("form_refresh", function(e, frm) { + $(document).on("form-refresh", function(e, frm) { if (frm.is_new()) { return; } diff --git a/frappe/public/js/legacy/form.js b/frappe/public/js/legacy/form.js index 83c3ffe96f..413e1e594a 100644 --- a/frappe/public/js/legacy/form.js +++ b/frappe/public/js/legacy/form.js @@ -497,7 +497,7 @@ _f.Frm.prototype.render_form = function(is_a_different_doc) { // trigger global trigger // to use this - $(document).trigger('form_refresh', [this]); + $(document).trigger('form-refresh', [this]); // fields this.refresh_fields(); From 3c7be2fd04a35348ee8efde1a0072e023c5847c3 Mon Sep 17 00:00:00 2001 From: Makarand Bauskar Date: Mon, 2 Oct 2017 11:41:41 +0530 Subject: [PATCH 42/52] [hotfix] TypeError: Cannot read property 'id' of undefined (#4229) --- 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 8b1a801099..dee3171d8c 100644 --- a/frappe/public/js/frappe/views/reports/query_report.js +++ b/frappe/public/js/frappe/views/reports/query_report.js @@ -591,7 +591,7 @@ frappe.views.QueryReport = Class.extend({ newrow.id = newrow.name ? newrow.name : ("_" + newrow._id); this.data.push(newrow); } - if(this.report_doc.add_total_row) { + if(this.data.length && this.report_doc.add_total_row) { this.total_row_id = this.data[this.data.length - 1].id; } }, From 7dd2c1c941eb1f54cb36b8426501472ec263c191 Mon Sep 17 00:00:00 2001 From: Achilles Rasquinha Date: Mon, 2 Oct 2017 13:21:48 +0530 Subject: [PATCH 43/52] [FIX] #4223 (#4226) * [FIX] #4223 * codacy fix * fixed codacy * fixed codacy --- frappe/core/page/desktop/desktop.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/frappe/core/page/desktop/desktop.js b/frappe/core/page/desktop/desktop.js index f4d5d759f8..d18f7dd55c 100644 --- a/frappe/core/page/desktop/desktop.js +++ b/frappe/core/page/desktop/desktop.js @@ -147,9 +147,10 @@ $.extend(frappe.desktop, { const $icons = frappe.desktop.wrapper.find('.app-icon'); const $notis = $(frappe.desktop.wrapper.find('.circle').toArray().filter((object) => { // This hack is so bad, I should punch myself. - const doctype = $(object).data('doctype'); + // Seriously, punch yourself. + const text = $(object).find('.circle-text').html(); - return doctype; + return text; })); const clearWiggle = () => { From 451b48e4e2dbb3dec26d823529fb2e0ce887def4 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 2 Oct 2017 15:55:46 +0530 Subject: [PATCH 44/52] Update document status via communication if not feed (#4234) --- frappe/core/doctype/communication/communication.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/frappe/core/doctype/communication/communication.py b/frappe/core/doctype/communication/communication.py index af684fe802..d259b60cbd 100644 --- a/frappe/core/doctype/communication/communication.py +++ b/frappe/core/doctype/communication/communication.py @@ -94,9 +94,10 @@ class Communication(Document): def on_update(self): """Update parent status as `Open` or `Replied`.""" - update_parent_status(self) - update_comment_in_doc(self) - self.bot_reply() + if self.comment_type != 'Updated': + update_parent_status(self) + update_comment_in_doc(self) + self.bot_reply() def on_trash(self): if (not self.flags.ignore_permissions From ee70e152f05d3d130b1a547292dfc73ffd7c5e8b Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 2 Oct 2017 16:19:59 +0530 Subject: [PATCH 45/52] return in set_value_if_null --- frappe/public/js/legacy/clientscriptAPI.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frappe/public/js/legacy/clientscriptAPI.js b/frappe/public/js/legacy/clientscriptAPI.js index 30173328fa..c7590c5ae5 100644 --- a/frappe/public/js/legacy/clientscriptAPI.js +++ b/frappe/public/js/legacy/clientscriptAPI.js @@ -238,7 +238,7 @@ _f.Frm.prototype.set_query = function(fieldname, opt1, opt2) { } _f.Frm.prototype.set_value_if_missing = function(field, value) { - this.set_value(field, value, true); + return this.set_value(field, value, true); } _f.Frm.prototype.clear_table = function(fieldname) { From 612b94c367eb64683021d24d14fc73d3cc1a5ac6 Mon Sep 17 00:00:00 2001 From: Achilles Rasquinha Date: Mon, 2 Oct 2017 16:55:31 +0530 Subject: [PATCH 46/52] [FIX] new babel-presets (#4232) * [FIX] babel-presets * comment out minify * Update build.js --- frappe/build.js | 7 +++---- package.json | 20 ++++++++++---------- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/frappe/build.js b/frappe/build.js index 45ab9bc9cf..9a4f0c2fc9 100644 --- a/frappe/build.js +++ b/frappe/build.js @@ -123,10 +123,9 @@ function pack(output_path, inputs, minify) { } function babelify(content, path, minify) { - let presets = ['es2015', 'es2016']; - // if(minify) { - // presets.push('babili'); // new babel minifier - // } + let presets = ['env']; + // Minification doesn't work when loading Frappe Desk + // Avoid for now, trace the error and come back. try { return babel.transform(content, { presets: presets, diff --git a/package.json b/package.json index 10ad3df7ea..836c0957ef 100644 --- a/package.json +++ b/package.json @@ -14,20 +14,20 @@ }, "homepage": "https://frappe.io", "dependencies": { - "babel-core": "^6.24.1", - "babel-preset-babili": "0.0.12", - "babel-preset-es2015": "^6.24.1", - "babel-preset-es2016": "^6.24.1", - "babel-preset-es2017": "^6.24.1", - "chokidar": "^1.7.0", - "chromedriver": "^2.30.1", "cookie": "^0.3.1", "express": "^4.15.3", - "less": "^2.7.2", - "nightwatch": "^0.9.16", "redis": "^2.7.1", "socket.io": "^2.0.1", "superagent": "^3.5.2", - "touch": "^3.1.0" + "touch": "^3.1.0" + }, + "devDependencies": { + "babel-core": "^6.26.0", + "babel-preset-env": "^1.6.0", + "babel-preset-minify": "^0.2.0", + "chokidar": "^1.7.0", + "chromedriver": "^2.32.3", + "less": "^2.7.2", + "nightwatch": "^0.9.16" } } From 8c8e9fdd9801bde8966f8d7393ff56c2ca67859c Mon Sep 17 00:00:00 2001 From: KanchanChauhan Date: Mon, 2 Oct 2017 16:56:27 +0530 Subject: [PATCH 47/52] No Tags was not counting emtpy tags (#4231) --- frappe/desk/reportview.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/frappe/desk/reportview.py b/frappe/desk/reportview.py index cacfa25e9a..09afea8b3d 100644 --- a/frappe/desk/reportview.py +++ b/frappe/desk/reportview.py @@ -259,7 +259,7 @@ def get_stats(stats, doctype, filters=[]): stats[tag] = scrub_user_tags(tagcount) stats[tag].append([_("No Tags"), frappe.get_list(doctype, fields=[tag, "count(*)"], - filters=filters +["({0} = ',' or {0} is null)".format(tag)], as_list=True)[0][1]]) + filters=filters +["({0} = ',' or {0} = '' or {0} is null)".format(tag)], as_list=True)[0][1]]) else: stats[tag] = tagcount @@ -269,7 +269,6 @@ def get_stats(stats, doctype, filters=[]): except MySQLdb.OperationalError: # raised when _user_tags column is added on the fly pass - return stats @frappe.whitelist() From 13a3205277baf2a94a019b0b6368f93d20c0619e Mon Sep 17 00:00:00 2001 From: Utkarsh Goswami Date: Mon, 2 Oct 2017 16:56:59 +0530 Subject: [PATCH 48/52] [fix] Disabled document not validated on save/submit #10571 (#4195) * validation for disabled document * Update utils.py --- frappe/desk/form/utils.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/frappe/desk/form/utils.py b/frappe/desk/form/utils.py index 999a83a2fe..c656eac85f 100644 --- a/frappe/desk/form/utils.py +++ b/frappe/desk/form/utils.py @@ -29,8 +29,15 @@ def validate_link(): frappe.response['message'] = 'Ok' return - valid_value = frappe.db.sql("select name from `tab%s` where name=%s" % (frappe.db.escape(options), - '%s'), (value,)) + #if enabled/disabled field is present + condition = "" + if frappe.get_meta(options).get_field('disabled'): + condition = " and `disabled` = 0" + elif frappe.get_meta(options).get_field('enabled'): + condition = " and `enabled` = 1" + + valid_value = frappe.db.sql("select name from `tab{0}` where name=%s {1}".format(frappe.db.escape(options), + condition), (value,)) if valid_value: valid_value = valid_value[0][0] From 2191a7d3a4224457c0042aba5267ae66beb28e0a Mon Sep 17 00:00:00 2001 From: bcornwellmott Date: Mon, 2 Oct 2017 04:34:14 -0700 Subject: [PATCH 49/52] Force uploads to be private by default (#4159) * Make uploads private by default * Fixed first attempt private * Removed accidental debugger * Added check for image * Added public option for attaching * Get rid of whitespace --- frappe/public/js/frappe/upload.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/frappe/public/js/frappe/upload.js b/frappe/public/js/frappe/upload.js index 0a1225d2a5..bb727aa415 100644 --- a/frappe/public/js/frappe/upload.js +++ b/frappe/public/js/frappe/upload.js @@ -12,7 +12,13 @@ frappe.upload = { // whether to show public/private checkbox or not opts.show_private = !("is_private" in opts); - + + // make private by default + if (!("options" in opts) || ("options" in opts && + (!opts.options.toLowerCase()=="public" && !opts.options.toLowerCase()=="image"))) { + opts.is_private = 1; + } + var d = null; // create new dialog if no parent given if(!opts.parent) { @@ -237,7 +243,6 @@ frappe.upload = { if (args.file_size) { frappe.upload.validate_max_file_size(args.file_size); } - if(opts.on_attach) { opts.on_attach(args) } else { @@ -252,7 +257,7 @@ frappe.upload = { frappe.upload.upload_to_server(fileobj, args, opts); }, __("Private or Public?")); } else { - if ("is_private" in opts) { + if (!("is_private" in args) && "is_private" in opts) { args["is_private"] = opts.is_private; } From 550acb5e1c16da1d4c4e5e49a06a1fc7992064b4 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Wed, 4 Oct 2017 10:55:54 +0530 Subject: [PATCH 50/52] Revert "[fix] Disabled document not validated on save/submit #10571" (#4240) * Revert "Force uploads to be private by default (#4159)" This reverts commit 2191a7d3a4224457c0042aba5267ae66beb28e0a. * Revert "[fix] Disabled document not validated on save/submit #10571 (#4195)" This reverts commit 13a3205277baf2a94a019b0b6368f93d20c0619e. --- frappe/desk/form/utils.py | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/frappe/desk/form/utils.py b/frappe/desk/form/utils.py index c656eac85f..999a83a2fe 100644 --- a/frappe/desk/form/utils.py +++ b/frappe/desk/form/utils.py @@ -29,15 +29,8 @@ def validate_link(): frappe.response['message'] = 'Ok' return - #if enabled/disabled field is present - condition = "" - if frappe.get_meta(options).get_field('disabled'): - condition = " and `disabled` = 0" - elif frappe.get_meta(options).get_field('enabled'): - condition = " and `enabled` = 1" - - valid_value = frappe.db.sql("select name from `tab{0}` where name=%s {1}".format(frappe.db.escape(options), - condition), (value,)) + valid_value = frappe.db.sql("select name from `tab%s` where name=%s" % (frappe.db.escape(options), + '%s'), (value,)) if valid_value: valid_value = valid_value[0][0] From 4140bf809f95702d00c37d6d57041ed758368a2d Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Wed, 4 Oct 2017 15:19:45 +0530 Subject: [PATCH 51/52] minor fix in old patch --- frappe/patches/v6_20x/remove_roles_from_website_user.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/frappe/patches/v6_20x/remove_roles_from_website_user.py b/frappe/patches/v6_20x/remove_roles_from_website_user.py index 347491898f..499ad5ddf4 100644 --- a/frappe/patches/v6_20x/remove_roles_from_website_user.py +++ b/frappe/patches/v6_20x/remove_roles_from_website_user.py @@ -1,6 +1,8 @@ import frappe def execute(): + frappe.reload_doc("core", "doctype", "user_email") + frappe.reload_doc("core", "doctype", "user") for user_name in frappe.get_all('User', filters={'user_type': 'Website User'}): user = frappe.get_doc('User', user_name) if user.roles: From cea04fae171887c43c7dbb388f4260745d5066cc Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Wed, 4 Oct 2017 15:29:16 +0530 Subject: [PATCH 52/52] [fix] locking for set_default (#4245) --- frappe/defaults.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/frappe/defaults.py b/frappe/defaults.py index b4a9d5cfab..9fbc55a0d0 100644 --- a/frappe/defaults.py +++ b/frappe/defaults.py @@ -92,7 +92,19 @@ def set_default(key, value, parent, parenttype="__default"): :param value: Default value. :param parent: Usually, **User** to whom the default belongs. :param parenttype: [optional] default is `__default`.""" - frappe.db.sql("""delete from `tabDefaultValue` where defkey=%s and parent=%s""", (key, parent)) + if frappe.db.sql(''' + select + defkey + from + tabDefaultValue + where + defkey=%s and parent=%s + for update''', (key, parent)): + frappe.db.sql(""" + delete from + `tabDefaultValue` + where + defkey=%s and parent=%s""", (key, parent)) if value != None: add_default(key, value, parent)