Some more refactoring to use @route()

bzr revid: nicolas.vanhoren@openerp.com-20130620100122-3mtvqr1w5yrikitk
This commit is contained in:
niv-openerp 2013-06-20 12:01:22 +02:00
parent f3bd6b3baf
commit 56f2e7631f
1 changed files with 13 additions and 14 deletions

View File

@ -23,16 +23,15 @@ import logging
import openerp
from openerp.modules.registry import RegistryManager
from ..res_users import SignupError
from openerp.addons.web.http import nodb, noauth
import openerp.addons.web.http as http
from openerp.addons.web.http import request
_logger = logging.getLogger(__name__)
class Controller(openerp.addons.web.http.Controller):
_cp_path = '/auth_signup'
class Controller(http.Controller):
@openerp.addons.web.http.jsonrequest
@nodb
def get_config(self, req, dbname):
@http.route('/auth_signup/get_config', type='json', authentication="nodb")
def get_config(self, dbname):
""" retrieve the module config (which features are enabled) for the login page """
registry = RegistryManager.get(dbname)
with registry.cursor() as cr:
@ -43,8 +42,8 @@ class Controller(openerp.addons.web.http.Controller):
}
return config
@openerp.addons.web.http.jsonrequest
def retrieve(self, req, dbname, token):
@http.route('/auth_signup/retrieve', type='json', authentication="auth")
def retrieve(self, dbname, token):
""" retrieve the user info (name, login or email) corresponding to a signup token """
registry = RegistryManager.get(dbname)
with registry.cursor() as cr:
@ -52,23 +51,23 @@ class Controller(openerp.addons.web.http.Controller):
user_info = res_partner.signup_retrieve_info(cr, openerp.SUPERUSER_ID, token)
return user_info
@openerp.addons.web.http.jsonrequest
def signup(self, req, dbname, token, **values):
@http.route('/auth_signup/signup', type='json', authentication="auth")
def signup(self, dbname, token, **values):
""" sign up a user (new or existing)"""
try:
self._signup_with_values(req, dbname, token, values)
self._signup_with_values(dbname, token, values)
except SignupError, e:
return {'error': openerp.tools.exception_to_unicode(e)}
return {}
def _signup_with_values(self, req, dbname, token, values):
def _signup_with_values(self, dbname, token, values):
registry = RegistryManager.get(dbname)
with registry.cursor() as cr:
res_users = registry.get('res.users')
res_users.signup(cr, openerp.SUPERUSER_ID, values, token)
@openerp.addons.web.http.jsonrequest
def reset_password(self, req, dbname, login):
@http.route('/auth_signup/reset_password', type='json', authentication="auth")
def reset_password(self, dbname, login):
""" retrieve user, and perform reset password """
registry = RegistryManager.get(dbname)
with registry.cursor() as cr: