From 332d56db387db1aafe751e87b0e793f1ebaf9631 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Wed, 7 Sep 2011 16:05:29 +0530 Subject: [PATCH 1/3] fixed patch --- patches/patch.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/patches/patch.py b/patches/patch.py index e4b38d0f62..e5586f8bc8 100644 --- a/patches/patch.py +++ b/patches/patch.py @@ -306,7 +306,7 @@ def execute(patch_no): reload_doc('hr', 'doctype', 'salary_slip') delete_doc('DocType', 'Salary Control Panel') elif patch_no == 356: - reload_doc('doctype', 'core', 'doctype') + reload_doc('core', 'doctype', 'doctype') sql("update `tabDocType` set default_print_format = 'Standard' where name = 'Delivery Note'") elif patch_no == 357: sql("delete from `tabDocField` where (fieldname in ('client_string', 'server_code_error', 'server_code_compiled', 'server_code', 'server_code_core', 'client_script', 'client_script_core', 'dt_template', change_log) or label = 'Template') and parent = 'DocType'") From 99c1edc86f1b9bb0a55373bf7437340270c29a5f Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Wed, 7 Sep 2011 16:10:25 +0530 Subject: [PATCH 2/3] fixed patch --- patches/patch.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/patches/patch.py b/patches/patch.py index e5586f8bc8..6ca01714f7 100644 --- a/patches/patch.py +++ b/patches/patch.py @@ -309,4 +309,4 @@ def execute(patch_no): reload_doc('core', 'doctype', 'doctype') sql("update `tabDocType` set default_print_format = 'Standard' where name = 'Delivery Note'") elif patch_no == 357: - sql("delete from `tabDocField` where (fieldname in ('client_string', 'server_code_error', 'server_code_compiled', 'server_code', 'server_code_core', 'client_script', 'client_script_core', 'dt_template', change_log) or label = 'Template') and parent = 'DocType'") + sql("delete from `tabDocField` where (fieldname in ('client_string', 'server_code_error', 'server_code_compiled', 'server_code', 'server_code_core', 'client_script', 'client_script_core', 'dt_template', 'change_log') or label = 'Template') and parent = 'DocType'") From 389de000d993823a572f343fb63c66c5d9b15b9f Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Fri, 9 Sep 2011 13:41:36 +0530 Subject: [PATCH 3/3] Allow system manager to change other users password Also, update gateway membership type if sync_with_gateway is true --- .../company_control/company_control.py | 9 +++ home/page/my_company/my_company.js | 74 +++++++++++++++---- home/page/my_company/my_company.py | 5 +- 3 files changed, 69 insertions(+), 19 deletions(-) diff --git a/home/doctype/company_control/company_control.py b/home/doctype/company_control/company_control.py index cab8e7c17e..246b07e736 100644 --- a/home/doctype/company_control/company_control.py +++ b/home/doctype/company_control/company_control.py @@ -53,6 +53,15 @@ class DocType: pr.role = r pr.parentfield = 'userroles' pr.save(1) + + # Update Membership Type at Gateway + if cint(webnotes.conn.get_value('Control Panel', None, 'sync_with_gateway')): + if 'System Manager' in role_list : membership_type = 'Administrator' + else : membership_type = 'Member' + + import server_tools.gateway_utils + server_tools.gateway_utils.update_membership_type(cstr(arg['usr']), membership_type) + sql("delete from __SessionCache where user=%s", cstr(arg['usr'])) # Save profile diff --git a/home/page/my_company/my_company.js b/home/page/my_company/my_company.js index 9da7e9bd2d..40bf155585 100644 --- a/home/page/my_company/my_company.js +++ b/home/page/my_company/my_company.js @@ -322,7 +322,7 @@ MemberProfile = function(parent, uid, member_item) { // show securty settings this.set_security = function() { - var d = new wn.widgets.Dialog({ + var sd = new wn.widgets.Dialog({ title: 'Set User Security', width: 500, fields: [ @@ -362,30 +362,72 @@ MemberProfile = function(parent, uid, member_item) { } ] }); - d.onshow = function() { - d.set_values({ + + me.sec_dialog = sd + + sd.onshow = function() { + me.sec_dialog.set_values({ restrict_ip: me.profile.restrict_ip || '', login_before: me.profile.login_before || '', login_after: me.profile.login_after || '', new_password: '' - }) - } - d.fields_dict.update.input.onclick = function() { + }); + }; + sd.fields_dict.update.input.onclick = function() { var btn = this; this.set_working(); - var args = d.get_values(); + var args = me.sec_dialog.get_values(); args.user = me.profile.name; - $c_page('home', 'my_company', 'update_security', JSON.stringify(args), function(r,rt) { - if(r.exc) { - msgprint(r.exc); + + if (args.new_password) { + var pass_d = new wn.widgets.Dialog({ + title: 'Your Password', + width: 300, + fields: [ + { + label: 'Please Enter Your Password', + description: "Your password is required to update the concerned user's password", + fieldtype: 'Password', + fieldname: 'sys_admin_pwd', + reqd: 1 + }, + + { + label: 'Continue', + fieldtype: 'Button', + fieldname: 'continue' + } + ] + }); + + pass_d.fields_dict.continue.input.onclick = function() { + btn.pwd_dialog.hide(); + args.sys_admin_pwd = btn.pwd_dialog.get_values().sys_admin_pwd; + btn.set_working(); + me.update_security(args); btn.done_working(); - return; } - $.extend(me.profile, d.get_values()); - d.hide(); - }); - } - d.show(); + + pass_d.show(); + btn.pwd_dialog = pass_d; + btn.done_working(); + } else { + btn.done_working(); + me.update_security(args); + } + }; + sd.show(); + } + + this.update_security = function(args) { + $c_page('home', 'my_company', 'update_security', JSON.stringify(args), function(r,rt) { + if(r.exc) { + msgprint(r.exc); + return; + } + me.sec_dialog.hide(); + $.extend(me.profile, me.sec_dialog.get_values()); + }); } // delete user diff --git a/home/page/my_company/my_company.py b/home/page/my_company/my_company.py index 5d5ed800a8..3ff1482e9f 100644 --- a/home/page/my_company/my_company.py +++ b/home/page/my_company/my_company.py @@ -140,8 +140,7 @@ def update_security(args=''): if 'new_password' in args: if cint(webnotes.conn.get_value('Control Panel',None,'sync_with_gateway')): import server_tools.gateway_utils - webnotes.msgprint(server_tools.gateway_utils.change_password('', args['new_password'])['message']) + webnotes.msgprint(server_tools.gateway_utils.change_password('', args['new_password'], args['user'], args['sys_admin_pwd'])['message']) else: webnotes.conn.sql("update tabProfile set password=password(%s) where name=%s", (args['new_password'], args['user'])) - - webnotes.msgprint('Settings Updated') \ No newline at end of file + else: webnotes.msgprint('Settings Updated') \ No newline at end of file