From 8dafb6dc0548ff75b227eba0a49ff900c177a65d Mon Sep 17 00:00:00 2001 From: Saurabh Date: Tue, 30 Oct 2018 15:58:35 +0530 Subject: [PATCH 01/20] [fix] toggle title based on setup status --- frappe/www/update-password.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frappe/www/update-password.html b/frappe/www/update-password.html index 8af2dca2e6..9e5ab57bd4 100644 --- a/frappe/www/update-password.html +++ b/frappe/www/update-password.html @@ -6,7 +6,7 @@
- {{ _("Reset Password") }} + {{ _("Reset Password") if frappe.db.get_default('company') else _("Set Password")}}
From 5dceb7fb423a4849b593e6e88af12ff7db1312a6 Mon Sep 17 00:00:00 2001 From: Saurabh Date: Fri, 2 Nov 2018 15:38:19 +0530 Subject: [PATCH 02/20] provision to setup password while adding system manager --- frappe/commands/site.py | 6 ++++-- frappe/utils/user.py | 7 ++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/frappe/commands/site.py b/frappe/commands/site.py index 708f8f5e7d..8ae39d5b4e 100755 --- a/frappe/commands/site.py +++ b/frappe/commands/site.py @@ -183,15 +183,17 @@ def list_apps(context): @click.argument('email') @click.option('--first-name') @click.option('--last-name') +@click.option('--password') @click.option('--send-welcome-email', default=False, is_flag=True) @pass_context -def add_system_manager(context, email, first_name, last_name, send_welcome_email): +def add_system_manager(context, email, first_name, last_name, send_welcome_email, password): "Add a new system manager to a site" import frappe.utils.user for site in context.sites: frappe.connect(site=site) try: - frappe.utils.user.add_system_manager(email, first_name, last_name, send_welcome_email) + frappe.utils.user.add_system_manager(email, first_name, last_name, + send_welcome_email, password) frappe.db.commit() finally: frappe.destroy() diff --git a/frappe/utils/user.py b/frappe/utils/user.py index 0cc23893b7..f6042cf921 100755 --- a/frappe/utils/user.py +++ b/frappe/utils/user.py @@ -256,7 +256,7 @@ def get_system_managers(only_name=False): def add_role(user, role): frappe.get_doc("User", user).add_roles(role) -def add_system_manager(email, first_name=None, last_name=None, send_welcome_email=False): +def add_system_manager(email, first_name=None, last_name=None, send_welcome_email=False, password=None): # add user user = frappe.new_doc("User") user.update({ @@ -269,6 +269,11 @@ def add_system_manager(email, first_name=None, last_name=None, send_welcome_emai "send_welcome_email": 1 if send_welcome_email else 0 }) + if password: + user.update({ + "new_password": password + }) + user.insert() # add roles From 50af0dc3883b0cea19775ab7161329aa662dd4d3 Mon Sep 17 00:00:00 2001 From: Prateeksha Singh Date: Fri, 2 Nov 2018 11:12:35 +0530 Subject: [PATCH 03/20] remove setup progress --- frappe/public/js/frappe/misc/utils.js | 9 ++++ frappe/public/js/frappe/router.js | 19 +++++--- .../public/js/frappe/ui/toolbar/navbar.html | 7 --- frappe/public/js/frappe/ui/toolbar/toolbar.js | 47 +++++-------------- frappe/public/less/flex.less | 15 ++++++ 5 files changed, 49 insertions(+), 48 deletions(-) diff --git a/frappe/public/js/frappe/misc/utils.js b/frappe/public/js/frappe/misc/utils.js index e93a45decc..a9e058c0b2 100644 --- a/frappe/public/js/frappe/misc/utils.js +++ b/frappe/public/js/frappe/misc/utils.js @@ -92,6 +92,15 @@ Object.assign(frappe.utils, { return txt.toLowerCase().substr(0,7)=='http://' || txt.toLowerCase().substr(0,8)=='https://' }, + to_title_case: function(string, with_space=false) { + let titlecased_string = string.toLowerCase().replace(/(?:^|[\s-/])\w/g, function (match) { + return match.toUpperCase(); + }); + + let replace_with = with_space ? ' ' : ''; + + return titlecased_string.replace(/-|_/g, replace_with); + }, toggle_blockquote: function(txt) { if (!txt) return txt; diff --git a/frappe/public/js/frappe/router.js b/frappe/public/js/frappe/router.js index 4f6b47fb32..9ad05edc34 100644 --- a/frappe/public/js/frappe/router.js +++ b/frappe/public/js/frappe/router.js @@ -39,13 +39,20 @@ frappe.route = function() { frappe.route_history.push(route); - if(route[0] && route[1] && frappe.views[route[0] + "Factory"]) { - // has a view generator, generate! - if(!frappe.view_factory[route[0]]) { - frappe.view_factory[route[0]] = new frappe.views[route[0] + "Factory"](); - } + if(route[0]) { + const title_cased_route = frappe.utils.to_title_case(route[0]); - frappe.view_factory[route[0]].show(); + if(route[1] && frappe.views[title_cased_route + "Factory"]) { + // has a view generator, generate! + if(!frappe.view_factory[title_cased_route]) { + frappe.view_factory[title_cased_route] = new frappe.views[title_cased_route + "Factory"](); + } + + frappe.view_factory[title_cased_route].show(); + } else { + // show page + frappe.views.pageview.show(route[0]); + } } else { // show page const route_name = frappe.utils.xss_sanitise(route[0]); diff --git a/frappe/public/js/frappe/ui/toolbar/navbar.html b/frappe/public/js/frappe/ui/toolbar/navbar.html index bee71db847..dc13b357cc 100644 --- a/frappe/public/js/frappe/ui/toolbar/navbar.html +++ b/frappe/public/js/frappe/ui/toolbar/navbar.html @@ -11,13 +11,6 @@