Browse Source

[MIG] auth_user_insensitive: Migrate Module to OCA

* Upgrade module to 10.0 and bring up to OCA standards
pull/826/head
Ted Salmon 8 years ago
parent
commit
8fd59ba45b
No known key found for this signature in database GPG Key ID: 1E92222DD9AF3435
  1. 56
      auth_user_insensitive/README.rst
  2. 3
      auth_user_insensitive/__init__.py
  3. 18
      auth_user_insensitive/__manifest__.py
  4. 2
      auth_user_insensitive/models/__init__.py
  5. 17
      auth_user_insensitive/models/res_users.py
  6. 2
      auth_user_insensitive/tests/__init__.py
  7. 20
      auth_user_insensitive/tests/test_res_users.py
  8. 32
      res_users_case_insensitive/README.rst
  9. 18
      res_users_case_insensitive/__openerp__.py
  10. BIN
      res_users_case_insensitive/static/description/icon.png
  11. 12745
      res_users_case_insensitive/static/description/icon.svg

56
auth_user_insensitive/README.rst

@ -0,0 +1,56 @@
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
=======================
Case Insensitive Logins
=======================
This module makes user logins case insensitive. It also overwrites the
search method to allow these case insensitive logins to work on a database
that previously had case sensitive logins.
Installation
============
Install this module as you would any other. No further configuration is
required.
Bug Tracker
===========
Bugs are tracked on `GitHub Issues
<https://github.com/OCA/server-tools/issues>`_. In case of trouble, please
check there if your issue has already been reported. If you spotted it first,
help us smash it by providing detailed and welcomed feedback.
Credits
=======
Images
------
* Odoo Community Association: `Icon <https://github.com/OCA/maintainer-tools/blob/master/template/module/static/description/icon.svg>`_.
Contributors
------------
* Dave Lasley <dave@laslabs.com>
* Ted Salmon <tsalmon@laslabs.com>
Maintainer
----------
.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org
This module is maintained by the OCA.
OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.
To contribute to this module, please visit https://odoo-community.org.

3
res_users_case_insensitive/__init__.py → auth_user_insensitive/__init__.py

@ -1,6 +1,5 @@
# -*- coding: utf-8 -*-
# © 2015-TODAY LasLabs Inc.
# Copyright 2015-2017 LasLabs Inc.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import models
from . import tests

18
auth_user_insensitive/__manifest__.py

@ -0,0 +1,18 @@
# -*- coding: utf-8 -*-
# Copyright 2015-2017 LasLabs Inc.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
{
"name": "Case Insensitive Logins",
"summary": "Makes the user login field case insensitive",
"version": "10.0.1.0.0",
"category": "Authentication",
"website": "https://laslabs.com/",
"author": "LasLabs, Odoo Community Association (OCA)",
"license": "AGPL-3",
"application": False,
'installable': True,
"depends": [
"mail",
],
"data": [],
}

2
res_users_case_insensitive/models/__init__.py → auth_user_insensitive/models/__init__.py

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# © 2015-TODAY LasLabs Inc.
# Copyright 2015-2017 LasLabs Inc.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import res_users

17
res_users_case_insensitive/models/res_users.py → auth_user_insensitive/models/res_users.py

@ -1,12 +1,14 @@
# -*- coding: utf-8 -*-
# © 2015-TODAY LasLabs Inc.
# Copyright 2015-2017 LasLabs Inc.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from openerp import models, api, fields
from odoo import api, fields, models
class ResUsers(models.Model):
_inherit = 'res.users'
login = fields.Char(
'Login',
size=64,
@ -16,10 +18,9 @@ class ResUsers(models.Model):
@api.model
def search(self, domain, *args, **kwargs):
'''
Overload search to lowercase name domains. Can't do in a typical
search method due to the field not being computed
'''
""" Overload search to lowercase name domains. This can't be done in
a regular search method as the field is not computed
"""
for idx, _domain in enumerate(domain):
if _domain[0] == 'login':
lower = _domain[2].lower() if _domain[2] else False
@ -28,13 +29,13 @@ class ResUsers(models.Model):
@api.model
def create(self, vals, ):
''' Overload create to lowercase login '''
""" Overload create to lowercase login """
vals['login'] = vals.get('login', '').lower()
return super(ResUsers, self).create(vals)
@api.multi
def write(self, vals, ):
''' Overload write to lowercase login '''
""" Overload write to lowercase login """
if vals.get('login'):
vals['login'] = vals['login'].lower()
return super(ResUsers, self).write(vals)

2
res_users_case_insensitive/tests/__init__.py → auth_user_insensitive/tests/__init__.py

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# © 2015-TODAY LasLabs Inc.
# Copyright 2015-2017 LasLabs Inc.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import test_res_users

20
res_users_case_insensitive/tests/test_res_users.py → auth_user_insensitive/tests/test_res_users.py

@ -1,14 +1,14 @@
# -*- coding: utf-8 -*-
# © 2015-TODAY LasLabs Inc.
# Copyright 2015-2017 LasLabs Inc.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from openerp.tests.common import TransactionCase
from odoo.tests.common import TransactionCase
class TestResUsers(TransactionCase):
def setUp(self, *args, **kwargs):
super(TestResUsers, self).setUp(*args, **kwargs)
def setUp(self):
super(TestResUsers, self).setUp()
self.login = 'LasLabs@ExAmPlE.CoM'
self.partner_vals = {
'name': 'Partner',
@ -22,19 +22,22 @@ class TestResUsers(TransactionCase):
}
self.model_obj = self.env['res.users']
def _new_record(self, ):
def _new_record(self):
""" It should enerate a new record to test with """
partner_id = self.env['res.partner'].create(self.partner_vals)
self.vals['partner_id'] = partner_id.id
return self.model_obj.create(self.vals)
def test_login_is_lowercased_on_create(self, ):
def test_login_is_lowercased_on_create(self):
""" It should verify the login is set to lowercase on create """
rec_id = self._new_record()
self.assertEqual(
self.login.lower(), rec_id.login,
'Login was not lowercased when saved to db.',
)
def test_login_is_lowercased_on_write(self, ):
def test_login_is_lowercased_on_write(self):
""" It should verify the login is set to lowercase on write """
rec_id = self._new_record()
rec_id.write({'login': self.login})
self.assertEqual(
@ -42,7 +45,8 @@ class TestResUsers(TransactionCase):
'Login was not lowercased when saved to db.',
)
def test_login_search_is_lowercased(self, ):
def test_login_search_is_lowercased(self):
""" It should verify the login is set to lowercase on search """
rec_id = self._new_record()
res_id = self.model_obj.search([('login', '=', self.login.upper())])
res = res_id.id if res_id else False

32
res_users_case_insensitive/README.rst

@ -1,32 +0,0 @@
.. image:: https://img.shields.io/badge/license-AGPL--3-blue.svg
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
==========================
Case Insensitive Usernames
==========================
This module extends the functionality of res.users to make logins case
insensitive.
Credits
=======
Images
------
* LasLabs: `Icon <https://repo.laslabs.com/projects/TEM/repos/odoo-module_template/browse/module_name/static/description/icon.svg?raw>`_.
Contributors
------------
* Firstname Lastname <email.address@laslabs.com>
Maintainer
----------
.. image:: https://laslabs.com/logo.png
:alt: LasLabs Inc.
:target: https://laslabs.com
This module is maintained by LasLabs Inc.

18
res_users_case_insensitive/__openerp__.py

@ -1,18 +0,0 @@
# -*- coding: utf-8 -*-
# © 2015-TODAY LasLabs Inc.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
{
"name": "Case Insensitive Logins",
"summary": "Makes the login field of res.users case insensitive.",
"version": "9.0.1.0.0",
"category": "Base",
'depends': [
'mail', # Required if shares branch with password_security module
],
"website": "https://laslabs.com/",
"author": "LasLabs",
"license": "AGPL-3",
"application": False,
"installable": True,
}

BIN
res_users_case_insensitive/static/description/icon.png

Before

Width: 600  |  Height: 518  |  Size: 10 KiB

12745
res_users_case_insensitive/static/description/icon.svg
File diff suppressed because it is too large
View File

Loading…
Cancel
Save