From 96188f03104b46ed8f814ef5ec867538a880496d Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Thu, 15 Mar 2012 11:11:57 +0530 Subject: [PATCH] sync with gateway moved to defs --- .../doctype/company_control/company_control.py | 5 ++++- erpnext/home/page/my_company/my_company.py | 15 ++++++++++++--- .../page/profile_settings/profile_settings.py | 7 +++++-- erpnext/startup/event_handlers.py | 12 ++++++++---- erpnext/utilities/page/users/users.py | 15 ++++++++++++--- version.num | 2 +- 6 files changed, 42 insertions(+), 14 deletions(-) diff --git a/erpnext/home/doctype/company_control/company_control.py b/erpnext/home/doctype/company_control/company_control.py index 63f8b715f1..567f9f6c1e 100644 --- a/erpnext/home/doctype/company_control/company_control.py +++ b/erpnext/home/doctype/company_control/company_control.py @@ -71,7 +71,10 @@ class DocType: pr.save(1) # Update Membership Type at Gateway - if cint(webnotes.conn.get_value('Control Panel', None, 'sync_with_gateway')): + import webnotes.defs + from webnotes.utils import cint + if hasattr(webnotes.defs, 'sync_with_gateway') and \ + cint(webnotes.defs.sync_with_gateway) or 0: if 'System Manager' in role_list : membership_type = 'Administrator' else : membership_type = 'Member' diff --git a/erpnext/home/page/my_company/my_company.py b/erpnext/home/page/my_company/my_company.py index d3a7bc7a36..f2a2522989 100644 --- a/erpnext/home/page/my_company/my_company.py +++ b/erpnext/home/page/my_company/my_company.py @@ -54,7 +54,10 @@ def delete_user(args): args = json.loads(args) webnotes.conn.sql("update tabProfile set enabled=0, docstatus=2 where name=%s", args['user']) # erpnext-saas - if cint(webnotes.conn.get_value('Control Panel', None, 'sync_with_gateway')): + import webnotes.defs + from webnotes.utils import cint + if hasattr(webnotes.defs, 'sync_with_gateway') and \ + cint(webnotes.defs.sync_with_gateway) or 0: from server_tools.gateway_utils import remove_user_gateway remove_user_gateway(args['user']) @@ -65,7 +68,10 @@ def delete_user(args): def add_user(args): args = json.loads(args) # erpnext-saas - if cint(webnotes.conn.get_value('Control Panel', None, 'sync_with_gateway')): + import webnotes.defs + from webnotes.utils import cint + if hasattr(webnotes.defs, 'sync_with_gateway') and \ + cint(webnotes.defs.sync_with_gateway) or 0: from server_tools.gateway_utils import add_user_gateway add_user_gateway(args) @@ -183,7 +189,10 @@ def update_security(args=''): webnotes.conn.set_value('Profile', args['user'], 'login_before', args.get('login_before')) if 'new_password' in args: - if cint(webnotes.conn.get_value('Control Panel',None,'sync_with_gateway')): + import webnotes.defs + from webnotes.utils import cint + if hasattr(webnotes.defs, 'sync_with_gateway') and \ + cint(webnotes.defs.sync_with_gateway) or 0: import server_tools.gateway_utils res = server_tools.gateway_utils.change_password('', args['new_password'], args['user'], args['sys_admin_pwd']) if 'Traceback' not in res['message']: diff --git a/erpnext/home/page/profile_settings/profile_settings.py b/erpnext/home/page/profile_settings/profile_settings.py index fb633fdb19..9b9f890fdb 100644 --- a/erpnext/home/page/profile_settings/profile_settings.py +++ b/erpnext/home/page/profile_settings/profile_settings.py @@ -27,8 +27,11 @@ def change_password(arg): if not webnotes.conn.sql('select name from tabProfile where name=%s and password=password(%s)', (webnotes.session['user'], arg['old_password'])): webnotes.msgprint('Old password is not correct', raise_exception=1) - - if cint(webnotes.conn.get_value('Control Panel',None,'sync_with_gateway')): + + import webnotes.defs + from webnotes.utils import cint + if hasattr(webnotes.defs, 'sync_with_gateway') and \ + cint(webnotes.defs.sync_with_gateway) or 0: import server_tools.gateway_utils webnotes.msgprint(server_tools.gateway_utils.change_password(arg['old_password'], arg['new_password'])['message']) diff --git a/erpnext/startup/event_handlers.py b/erpnext/startup/event_handlers.py index 7db56bdb53..107a5d759e 100644 --- a/erpnext/startup/event_handlers.py +++ b/erpnext/startup/event_handlers.py @@ -26,9 +26,11 @@ def on_login(login_manager): if login_manager.user not in ('Guest', None, '') and webnotes.conn.cur_db_name!='accounts' and webnotes.conn.get_value('Control Panel', 'Control Panel', 'account_id')!='s5u011': try: login_manager = login_as(login_manager) - update_account_details() - import server_tools.gateway_utils - server_tools.gateway_utils.check_login(login_manager.user) + if hasattr(webnotes.defs, 'sync_with_gateway') and \ + cint(webnotes.defs.sync_with_gateway) or 0: + update_account_details() + import server_tools.gateway_utils + server_tools.gateway_utils.check_login(login_manager.user) except ImportError: pass @@ -157,6 +159,8 @@ def update_account_details(): # logout the user from SSO # def on_logout(login_manager): - if cint(webnotes.conn.get_value('Control Panel', None, 'sync_with_gateway')): + import webnotes.defs + if hasattr(webnotes.defs, 'sync_with_gateway') and \ + cint(webnotes.defs.sync_with_gateway) or 0: from server_tools.gateway_utils import logout_sso logout_sso(user=login_manager.user) diff --git a/erpnext/utilities/page/users/users.py b/erpnext/utilities/page/users/users.py index f2bb1a5f47..ec01479bfa 100644 --- a/erpnext/utilities/page/users/users.py +++ b/erpnext/utilities/page/users/users.py @@ -83,7 +83,10 @@ def update_security(args=''): webnotes.conn.set_value('Profile', args['user'], 'enabled', int(args.get('enabled',0)) or 0) if args.get('new_password') and args.get('sys_admin_pwd'): - if cint(webnotes.conn.get_value('Control Panel',None,'sync_with_gateway')): + import webnotes.defs + from webnotes.utils import cint + if hasattr(webnotes.defs, 'sync_with_gateway') and \ + cint(webnotes.defs.sync_with_gateway) or 0: import server_tools.gateway_utils res = server_tools.gateway_utils.change_password('', args['new_password'], args['user'], args['sys_admin_pwd']) @@ -104,7 +107,10 @@ def update_security(args=''): def add_user(args): args = json.loads(args) # erpnext-saas - if cint(webnotes.conn.get_value('Control Panel', None, 'sync_with_gateway')): + import webnotes.defs + from webnotes.utils import cint + if hasattr(webnotes.defs, 'sync_with_gateway') and \ + cint(webnotes.defs.sync_with_gateway) or 0: from server_tools.gateway_utils import add_user_gateway add_user_gateway(args) @@ -169,7 +175,10 @@ def delete(arg=None): webnotes.conn.sql("update tabProfile set enabled=0, docstatus=2 where name=%s", webnotes.form_dict['uid']) # erpnext-saas - if int(webnotes.conn.get_value('Control Panel', None, 'sync_with_gateway')): + import webnotes.defs + from webnotes.utils import cint + if hasattr(webnotes.defs, 'sync_with_gateway') and \ + cint(webnotes.defs.sync_with_gateway) or 0: from server_tools.gateway_utils import remove_user_gateway remove_user_gateway(webnotes.form_dict['uid']) diff --git a/version.num b/version.num index 7179a19790..8f32b0ba57 100644 --- a/version.num +++ b/version.num @@ -1 +1 @@ -964 \ No newline at end of file +969 \ No newline at end of file