Browse Source

[REF] Pep8 and import conventions.

pull/2/head
Sylvain LE GAL 11 years ago
parent
commit
4562169feb
  1. 2
      auth_admin_passkey/__init__.py
  2. 20
      auth_admin_passkey/__openerp__.py
  3. 4
      auth_admin_passkey/model/__init__.py
  4. 36
      auth_admin_passkey/model/res_config.py
  5. 10
      auth_admin_passkey/model/res_users.py

2
auth_admin_passkey/__init__.py

@ -3,4 +3,4 @@
# See __openerp__.py file for Copyright and Licence Informations.
################################################################################
import model
from . import model

20
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);
* <informatique@grap.coop> for any help or question about this module.
""",
'author': 'GRAP',
'website': 'http://www.grap.coop',

4
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

36
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.",
),
}

10
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)

Loading…
Cancel
Save