Browse Source

Addons configuration parameter is now a field part of the Authentication group from base_setup

pull/34/head
Laurent Mignon (aka lmi) 10 years ago
parent
commit
8f9fcae4dc
  1. 2
      auth_from_http_remote_user/__openerp__.py
  2. 3
      auth_from_http_remote_user/controllers/main.py
  3. 43
      auth_from_http_remote_user/res_config.py
  4. 41
      auth_from_http_remote_user/res_config_view.xml

2
auth_from_http_remote_user/__openerp__.py

@ -149,7 +149,7 @@ logged in the system.
'author': 'Acsone SA/NV',
'maintainer': 'ACSONE SA/NV',
'website': 'http://www.acsone.eu',
'depends': ['web'],
'depends': ['base', 'web', 'base_setup'],
"license": "AGPL-3",
'data': [
'res_config_view.xml',

3
auth_from_http_remote_user/controllers/main.py

@ -93,8 +93,7 @@ class Home(main.Home):
installed = modules.search_count(cr, SUPERUSER_ID, domain) == 1
if not installed:
return
config = registry.get('auth_from_http_remote_user.'
'config.settings')
config = registry.get('base.config.settings')
# get parameters for SSO
default_login_page_disabled = \
config.is_default_login_page_disabled(cr,

43
auth_from_http_remote_user/res_config.py

@ -21,15 +21,15 @@
from openerp.osv import orm, fields
from openerp.tools.safe_eval import safe_eval
import types
class auth_from_http_remote_user_configuration(orm.TransientModel):
_name = 'auth_from_http_remote_user.config.settings'
_inherit = 'res.config.settings'
_inherit = 'base.config.settings'
_columns = {
'default_login_page_disabled': fields.boolean("Disable login page",
'default_login_page_disabled': fields.boolean("Disable login page when "
"login with HTTP Remote "
"User",
help="""
Disable the default login page.
If the HTTP_REMOTE_HEADER field is not found or no user matches the given one,
@ -39,29 +39,26 @@ Otherwise the normal login page will be displayed.
}
def is_default_login_page_disabled(self, cr, uid, fields, context=None):
ir_config_obj = self.pool['ir.config_parameter']
default_login_page_disabled = \
ir_config_obj.get_param(cr,
vals = self.get_default_default_login_page_disabled(cr,
uid,
'auth_from_http_remote_user.'
'default_login_page_disabled')
if isinstance(default_login_page_disabled, types.BooleanType):
return default_login_page_disabled
return safe_eval(default_login_page_disabled)
fields,
context=context)
return vals.get('default_login_page_disabled', False)
def get_default_default_login_page_disabled(self, cr, uid, fields,
context=None):
default_login_page_disabled = \
self.is_default_login_page_disabled(cr, uid, fields, context)
return {'default_login_page_disabled': default_login_page_disabled}
icp = self.pool.get('ir.config_parameter')
# we use safe_eval on the result, since the value of
# the parameter is a nonempty string
is_disabled = icp.get_param(cr, uid, 'default_login_page_disabled',
'False')
return {'default_login_page_disabled': safe_eval(is_disabled)}
def set_default_default_login_page_disabled(self, cr, uid, ids,
context=None):
config = self.browse(cr, uid, ids[0], context)
ir_config_parameter_obj = self.pool['ir.config_parameter']
param_value = repr(config.default_login_page_disabled)
ir_config_parameter_obj.set_param(cr,
uid,
'auth_from_http_remote_user.'
'default_login_page_disabled',
param_value)
config = self.browse(cr, uid, ids[0], context=context)
icp = self.pool.get('ir.config_parameter')
# we store the repr of the value, since the value of the parameter
# is a required string
icp.set_param(cr, uid, 'default_login_page_disabled',
repr(config.default_login_page_disabled))

41
auth_from_http_remote_user/res_config_view.xml

@ -1,39 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record model="ir.ui.view" id="help_view_config_settings">
<field name="name">Auth HTTP_REMOTE_USER settings</field>
<field name="model">auth_from_http_remote_user.config.settings</field>
<field name="priority" eval="20" />
<record id="view_general_configuration" model="ir.ui.view">
<field name="name">base.config.settings.auth_from_http_remote_user</field>
<field name="model">base.config.settings</field>
<field name="inherit_id" ref="base_setup.view_general_configuration" />
<field name="arch" type="xml">
<form string="Configure Auth HTTP_REMOTE_USER" version="7.0"
class="oe_form_configuration">
<header>
<header>
<button string="Apply" type="object" name="execute" class="oe_highlight"/>
or
<button string="Cancel" type="object" name="cancel" class="oe_link"/>
</header>
</header>
<separator string="Auth HTTP_REMOTE_USER" />
<group>
<field name="default_login_page_disabled" />
</group>
</form>
<xpath expr="//field[@name='module_auth_oauth']/.." position="after">
<div>
<field name="default_login_page_disabled" class="oe_inline" />
<label for="default_login_page_disabled" />
</div>
</xpath>
</field>
</record>
<record model="ir.actions.act_window" id="auth_from_http_remote_user_action_config_settings">
<field name="name">Configure Auth HTTP_REMOTE_USER</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">auth_from_http_remote_user.config.settings</field>
<field name="view_mode">form</field>
<field name="target">inline</field>
</record>
<menuitem id="base.menu_auth_from_http_remote_user_config" name="Auth HTTP_REMOTE_USER"
parent="base.menu_config" sequence="10"
action="auth_from_http_remote_user_action_config_settings" />
</data>
</openerp>
Loading…
Cancel
Save