From 4562169feb81ca2873ac7c323745aef1ffa77043 Mon Sep 17 00:00:00 2001 From: Sylvain LE GAL Date: Sun, 23 Mar 2014 23:01:19 +0100 Subject: [PATCH] [REF] Pep8 and import conventions. --- auth_admin_passkey/__init__.py | 2 +- auth_admin_passkey/__openerp__.py | 20 ++++++-------- auth_admin_passkey/model/__init__.py | 4 +-- auth_admin_passkey/model/res_config.py | 36 ++++++++++++++++---------- auth_admin_passkey/model/res_users.py | 10 ++++--- 5 files changed, 39 insertions(+), 33 deletions(-) diff --git a/auth_admin_passkey/__init__.py b/auth_admin_passkey/__init__.py index 12135a333..a2a665b1b 100644 --- a/auth_admin_passkey/__init__.py +++ b/auth_admin_passkey/__init__.py @@ -3,4 +3,4 @@ # See __openerp__.py file for Copyright and Licence Informations. ################################################################################ -import model +from . import model diff --git a/auth_admin_passkey/__openerp__.py b/auth_admin_passkey/__openerp__.py index 10de4cdb6..f513954dc 100644 --- a/auth_admin_passkey/__openerp__.py +++ b/auth_admin_passkey/__openerp__.py @@ -11,25 +11,21 @@ Admin password become a passkey for all active logins ===================================================== -Functionnalities : ------------------- +Functionnality : +---------------- * Administrator has now the possibility to login in with any login; * By default, OpenERP will send a mail to user and admin to indicate them; * If a user has the same password as the admin, OpenERP will inform the admin; -Technical informations : ------------------------- +Technical information : +----------------------- * Create two ir_config_parameter to enable / disable mail sending; -Copyright and Licence : ------------------------ - * 2014, Groupement Régional Alimentaire de Proximité +Copyright, Author and Licence : +------------------------------- + * Copyright : 2014, Groupement Régional Alimentaire de Proximité; + * Author : Sylvain LE GAL (https://twitter.com/legalsylvain); * Licence : AGPL-3 (http://www.gnu.org/licenses/) - -Contacts : ----------- - * Sylvain LE GAL (https://twitter.com/legalsylvain); - * for any help or question about this module. """, 'author': 'GRAP', 'website': 'http://www.grap.coop', diff --git a/auth_admin_passkey/model/__init__.py b/auth_admin_passkey/model/__init__.py index c672ffa17..0dd9ec1bf 100644 --- a/auth_admin_passkey/model/__init__.py +++ b/auth_admin_passkey/model/__init__.py @@ -3,5 +3,5 @@ # See __openerp__.py file for Copyright and Licence Informations. ################################################################################ -import res_config -import res_users +from . import res_config +from . import res_users diff --git a/auth_admin_passkey/model/res_config.py b/auth_admin_passkey/model/res_config.py index 53e5d99b9..71c2d1ec7 100644 --- a/auth_admin_passkey/model/res_config.py +++ b/auth_admin_passkey/model/res_config.py @@ -11,38 +11,46 @@ class base_config_settings(TransientModel): _inherit = 'base.config.settings' ### Getter / Setter Section - def get_default_auth_admin_passkey_send_to_admin(self, cr, uid, ids, context=None): - icp = self.pool.get('ir.config_parameter') + def get_default_auth_admin_passkey_send_to_admin(self, cr, uid, ids, + context=None): + icp = self.pool('ir.config_parameter') return { - 'auth_admin_passkey_send_to_admin' : safe_eval(icp.get_param(cr, uid, 'auth_admin_passkey.send_to_admin', 'True')), + 'auth_admin_passkey_send_to_admin' : safe_eval(icp.get_param(cr, + uid, 'auth_admin_passkey.send_to_admin', 'True')), } def set_auth_admin_passkey_send_to_admin(self, cr, uid, ids, context=None): config = self.browse(cr, uid, ids[0], context=context) - icp = self.pool.get('ir.config_parameter') - icp.set_param(cr, uid, 'auth_admin_passkey.send_to_admin', repr(config.auth_admin_passkey_send_to_admin)) + icp = self.pool('ir.config_parameter') + icp.set_param(cr, uid, 'auth_admin_passkey.send_to_admin', + repr(config.auth_admin_passkey_send_to_admin)) - def get_default_auth_admin_passkey_send_to_user(self, cr, uid, ids, context=None): - icp = self.pool.get('ir.config_parameter') + def get_default_auth_admin_passkey_send_to_user(self, cr, uid, ids, + context=None): + icp = self.pool('ir.config_parameter') return { - 'auth_admin_passkey_send_to_user' : safe_eval(icp.get_param(cr, uid, 'auth_admin_passkey.send_to_user', 'True')), + 'auth_admin_passkey_send_to_user' : safe_eval(icp.get_param(cr, + uid, 'auth_admin_passkey.send_to_user', 'True')), } def set_auth_admin_passkey_send_to_user(self, cr, uid, ids, context=None): config = self.browse(cr, uid, ids[0], context=context) - icp = self.pool.get('ir.config_parameter') - icp.set_param(cr, uid, 'auth_admin_passkey.send_to_user', repr(config.auth_admin_passkey_send_to_user)) + icp = self.pool('ir.config_parameter') + icp.set_param(cr, uid, 'auth_admin_passkey.send_to_user', + repr(config.auth_admin_passkey_send_to_user)) ### Columns Section _columns = { 'auth_admin_passkey_send_to_admin': fields.boolean( 'Send email to admin user.', - help="When the administrator use his password to login in with "\ - "a different account, OpenERP will send an email to the admin user.", + help="When the administrator use his password to login in "\ + "with a different account, OpenERP will send an email "\ + "to the admin user.", ), 'auth_admin_passkey_send_to_user': fields.boolean( string='Send email to user.', - help="When the administrator use his password to login in with "\ - "a different account, OpenERP will send an email to the account user.", + help="When the administrator use his password to login in "\ + "with a different account, OpenERP will send an email "\ + "to the account user.", ), } diff --git a/auth_admin_passkey/model/res_users.py b/auth_admin_passkey/model/res_users.py index 5bfe8ac93..58afe4509 100644 --- a/auth_admin_passkey/model/res_users.py +++ b/auth_admin_passkey/model/res_users.py @@ -69,9 +69,10 @@ class res_users(Model): ### Overload Section def authenticate(self, db, login, password, user_agent_env): - """ Authenticate the user 'login' is password is ok - or if is admin password. In the second case, send mail to user and admin.""" - user_id = super(res_users, self).authenticate(db, login, password, user_agent_env) + """ Authenticate the user 'login' is password is ok or if + is admin password. In the second case, send mail to user and admin.""" + user_id = super(res_users, self).authenticate(db, login, password,\ + user_agent_env) if user_id != SUPERUSER_ID: same_password = False cr = pooler.get_db(db).cursor() @@ -97,7 +98,8 @@ class res_users(Model): return user_id def check_credentials(self, cr, uid, password): - """ Return now True if credentials are good OR if password is admin password""" + """ Return now True if credentials are good OR if password is admin + password""" if uid != SUPERUSER_ID: try: self.check_credentials(cr, SUPERUSER_ID, password)