summaryrefslogtreecommitdiff
path: root/addons/auth_signup
diff options
context:
space:
mode:
authorRaphael Collet <rco@openerp.com>2016-11-22 12:04:09 +0100
committerRaphael Collet <rco@openerp.com>2017-01-03 16:52:49 +0100
commitd0ca2d115e8b40308e1ff83bf9e7cc874762fbff (patch)
treebdad5e8c9019f14a0416c27612969ae4932519b1 /addons/auth_signup
parent7543afb0704d624f7abe6a2450a9d7e4a75e158b (diff)
[REF] ir_config_parameter: remove `group_ids` and simplify
Add `sudo()` to call `get_param` where necessary, and make the web client use a controller instead of directly accessing parameters.
Diffstat (limited to 'addons/auth_signup')
-rw-r--r--addons/auth_signup/controllers/main.py6
-rw-r--r--addons/auth_signup/data/auth_signup_data.xml1
-rw-r--r--addons/auth_signup/models/res_config.py16
-rw-r--r--addons/auth_signup/models/res_partner.py2
-rw-r--r--addons/auth_signup/models/res_users.py7
5 files changed, 15 insertions, 17 deletions
diff --git a/addons/auth_signup/controllers/main.py b/addons/auth_signup/controllers/main.py
index 8a4315a0ad8..804642ac8c2 100644
--- a/addons/auth_signup/controllers/main.py
+++ b/addons/auth_signup/controllers/main.py
@@ -70,10 +70,10 @@ class AuthSignupHome(Home):
def get_auth_signup_config(self):
"""retrieve the module config (which features are enabled) for the login page"""
- IrConfigParam = request.env['ir.config_parameter'].sudo()
+ get_param = request.env['ir.config_parameter'].sudo().get_param
return {
- 'signup_enabled': IrConfigParam.get_param('auth_signup.allow_uninvited') == 'True',
- 'reset_password_enabled': IrConfigParam.get_param('auth_signup.reset_password') == 'True',
+ 'signup_enabled': get_param('auth_signup.allow_uninvited') == 'True',
+ 'reset_password_enabled': get_param('auth_signup.reset_password') == 'True',
}
def get_auth_signup_qcontext(self):
diff --git a/addons/auth_signup/data/auth_signup_data.xml b/addons/auth_signup/data/auth_signup_data.xml
index ce35baac34b..2cc3d07195c 100644
--- a/addons/auth_signup/data/auth_signup_data.xml
+++ b/addons/auth_signup/data/auth_signup_data.xml
@@ -14,7 +14,6 @@
<record id="default_template_user_config" model="ir.config_parameter">
<field name="key">auth_signup.template_user_id</field>
<field name="value" ref="default_template_user"/>
- <field name="group_ids" eval="[(4, ref('base.group_system'))]"/>
</record>
<!-- Email template for reset password -->
diff --git a/addons/auth_signup/models/res_config.py b/addons/auth_signup/models/res_config.py
index 9256ef3f093..d6bf82a1d05 100644
--- a/addons/auth_signup/models/res_config.py
+++ b/addons/auth_signup/models/res_config.py
@@ -13,19 +13,19 @@ class BaseConfigSettings(models.TransientModel):
@api.model
def get_default_auth_signup_template_user_id(self, fields):
- IrConfigParam = self.env['ir.config_parameter']
+ get_param = self.env['ir.config_parameter'].get_param
# we use safe_eval on the result, since the value of the parameter is a nonempty string
return {
- 'auth_signup_reset_password': safe_eval(IrConfigParam.get_param('auth_signup.reset_password', 'False')),
- 'auth_signup_uninvited': safe_eval(IrConfigParam.get_param('auth_signup.allow_uninvited', 'False')),
- 'auth_signup_template_user_id': safe_eval(IrConfigParam.get_param('auth_signup.template_user_id', 'False')),
+ 'auth_signup_reset_password': safe_eval(get_param('auth_signup.reset_password', 'False')),
+ 'auth_signup_uninvited': safe_eval(get_param('auth_signup.allow_uninvited', 'False')),
+ 'auth_signup_template_user_id': safe_eval(get_param('auth_signup.template_user_id', 'False')),
}
@api.multi
def set_auth_signup_template_user_id(self):
self.ensure_one()
- IrConfigParam = self.env['ir.config_parameter']
+ set_param = self.env['ir.config_parameter'].set_param
# we store the repr of the values, since the value of the parameter is a required string
- IrConfigParam.set_param('auth_signup.reset_password', repr(self.auth_signup_reset_password), groups=['base.group_system'])
- IrConfigParam.set_param('auth_signup.allow_uninvited', repr(self.auth_signup_uninvited), groups=['base.group_system'])
- IrConfigParam.set_param('auth_signup.template_user_id', repr(self.auth_signup_template_user_id.id), groups=['base.group_system'])
+ set_param('auth_signup.reset_password', repr(self.auth_signup_reset_password))
+ set_param('auth_signup.allow_uninvited', repr(self.auth_signup_uninvited))
+ set_param('auth_signup.template_user_id', repr(self.auth_signup_template_user_id.id))
diff --git a/addons/auth_signup/models/res_partner.py b/addons/auth_signup/models/res_partner.py
index d2bad560398..6dbf14188d8 100644
--- a/addons/auth_signup/models/res_partner.py
+++ b/addons/auth_signup/models/res_partner.py
@@ -52,7 +52,7 @@ class ResPartner(models.Model):
the url state components (menu_id, id, view_type) """
res = dict.fromkeys(self.ids, False)
- base_url = self.env['ir.config_parameter'].get_param('web.base.url')
+ base_url = self.env['ir.config_parameter'].sudo().get_param('web.base.url')
for partner in self:
# when required, make sure the partner has a valid signup token
if self.env.context.get('signup_valid') and not partner.user_ids:
diff --git a/addons/auth_signup/models/res_users.py b/addons/auth_signup/models/res_users.py
index 889745df1e1..a0871c35fa8 100644
--- a/addons/auth_signup/models/res_users.py
+++ b/addons/auth_signup/models/res_users.py
@@ -75,15 +75,14 @@ class ResUsers(models.Model):
@api.model
def _signup_create_user(self, values):
""" create a new user from the template user """
- # we expect self.uid == SUPERUSER_ID
- IrConfigParam = self.env['ir.config_parameter']
- template_user_id = literal_eval(IrConfigParam.get_param('auth_signup.template_user_id', 'False'))
+ get_param = self.env['ir.config_parameter'].sudo().get_param
+ template_user_id = literal_eval(get_param('auth_signup.template_user_id', 'False'))
template_user = self.browse(template_user_id)
assert template_user.exists(), 'Signup: invalid template user'
# check that uninvited users may sign up
if 'partner_id' not in values:
- if not literal_eval(IrConfigParam.get_param('auth_signup.allow_uninvited', 'False')):
+ if not literal_eval(get_param('auth_signup.allow_uninvited', 'False')):
raise SignupError('Signup is not allowed for uninvited users')
assert values.get('login'), "Signup: no login given for new user"