[MERGE] minor cleanups
bzr revid: al@openerp.com-20120725195540-a9pmm432dae9s8pd
This commit is contained in:
parent
ff4342dc4f
commit
4e21ad0fdc
|
@ -36,7 +36,7 @@ openerp.anonymous = function(instance) {
|
|||
var p = self.getParent();
|
||||
var am = p.action_manager;
|
||||
am.do_action({type:'ir.actions.client', tag:'login'});
|
||||
am.client_widget.on('login', p, p.show_application);
|
||||
am.inner_widget.on('login', p, p.show_application);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
import signup_wizard
|
||||
import res_config
|
||||
import signup
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
'name': 'Signup',
|
||||
'description': 'Allow users to register',
|
||||
'description': 'Allow users to sign up',
|
||||
'author': 'OpenERP SA',
|
||||
'version': '1.0',
|
||||
'category': 'Tools',
|
||||
|
@ -8,15 +8,12 @@
|
|||
'installable': True,
|
||||
'depends': ['anonymous', 'base_setup'],
|
||||
'data': [
|
||||
'signup_wizard.xml',
|
||||
'res_config.xml',
|
||||
'signup.xml',
|
||||
],
|
||||
'js': [
|
||||
'static/src/js/signup.js',
|
||||
],
|
||||
#'css': [
|
||||
# 'static/src/css/reset_password.css',
|
||||
#],
|
||||
'qweb': [
|
||||
'static/src/xml/signup.xml',
|
||||
],
|
||||
|
|
|
@ -1,19 +1,20 @@
|
|||
from openerp.osv import osv, fields
|
||||
|
||||
class ResConfig(osv.TransientModel):
|
||||
class base_config_settings(osv.TransientModel):
|
||||
_inherit = 'base.config.settings'
|
||||
|
||||
_columns = {
|
||||
'signup_user_template_id': fields.many2one('res.users', 'Template user for account creation')
|
||||
'signup_template_user_id': fields.many2one('res.users', 'Template user for signup')
|
||||
}
|
||||
|
||||
def get_default_user_tpl(self, cr, uid, fields, context=None):
|
||||
def get_default_signup(self, cr, uid, fields, context=None):
|
||||
icp = self.pool.get('ir.config_parameter')
|
||||
return {
|
||||
'signup_user_template_id': icp.get_param(cr, uid, 'signup.user_template_id', 0) or False
|
||||
'signup_template_user_id': icp.get_param(cr, uid, 'signup.template_user_id', 0) or False
|
||||
}
|
||||
|
||||
def set_user_template(self, cr, uid, ids, context=None):
|
||||
def set_signup(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, 'signup.user_template_id', config.signup_user_template_id.id)
|
||||
icp.set_param(cr, uid, 'signup.template_user_id', config.signup_user_template_id.id)
|
||||
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
<openerp>
|
||||
<data>
|
||||
<record id="view_gen_conf_inherit" model="ir.ui.view">
|
||||
<field name="name">Inherit General Settings</field>
|
||||
<record id="view_general_configuration" model="ir.ui.view">
|
||||
<field name="name">base.config.settings.signup</field>
|
||||
<field name="model">base.config.settings</field>
|
||||
<field name="inherit_id" ref="base_setup.view_general_configuration"/>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<field name="module_portal" position="after">
|
||||
<field name="signup_user_template_id"/>
|
||||
<field name="signup_template_user_id"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
from functools import partial
|
||||
from openerp.osv import osv, fields
|
||||
|
||||
class res_users(osv.Model):
|
||||
|
@ -8,14 +7,13 @@ class res_users(osv.Model):
|
|||
('email_uniq', 'UNIQUE (user_email)', 'You can not have two users with the same email!')
|
||||
]
|
||||
|
||||
|
||||
class signup_wizard(osv.TransientModel):
|
||||
_name = 'signup.wizard'
|
||||
class signup_signup(osv.TransientModel):
|
||||
_name = 'signup.signup'
|
||||
_columns = {
|
||||
'name': fields.char('Name', size=64),
|
||||
'email': fields.char('Email', size=64),
|
||||
'pw': fields.char('Password', size=64),
|
||||
'cpw': fields.char('Confirm Password', size=64),
|
||||
'password': fields.char('Password', size=64),
|
||||
'password_confirmation': fields.char('Confirm Password', size=64),
|
||||
'state': fields.selection([(x, x) for x in 'draft done missmatch'.split()], required=True),
|
||||
}
|
||||
_defaults = {
|
||||
|
@ -25,33 +23,26 @@ class signup_wizard(osv.TransientModel):
|
|||
def create(self, cr, uid, values, context=None):
|
||||
# NOTE here, invalid values raises exceptions to avoid storing
|
||||
# sensitive data into the database (which then are available to anyone)
|
||||
|
||||
name = values.get('name')
|
||||
email = values.get('email')
|
||||
pw = values.get('pw')
|
||||
cpw = values.get('cpw')
|
||||
|
||||
if pw != cpw:
|
||||
if values['password'] != values['password_confirmation']:
|
||||
raise osv.except_osv('Error', 'Passwords missmatch')
|
||||
|
||||
Users = self.pool.get('res.users')
|
||||
new_user = {
|
||||
'name': values['name'],
|
||||
'login': values['email'],
|
||||
'user_email': values['email'],
|
||||
'password': values['password'],
|
||||
'active': True,
|
||||
}
|
||||
|
||||
user_template_id = self.pool.get('ir.config_parameter').get_param(cr, uid, 'signup.user_template_id', 0)
|
||||
if user_template_id:
|
||||
func = partial(Users.copy, cr, 1, user_template_id, context=context)
|
||||
self.pool.get('res.users').copy(cr, 1, user_template_id, new_user, context=context)
|
||||
else:
|
||||
func = partial(Users.create, cr, 1, context=context)
|
||||
|
||||
func({
|
||||
'name': name,
|
||||
'login': email,
|
||||
'user_email': email,
|
||||
'password': pw,
|
||||
'active': True,
|
||||
})
|
||||
self.pool.get('res.users').create(cr, 1, new_user, context=context)
|
||||
|
||||
# Dont store the password
|
||||
values = {'state': 'done'}
|
||||
return super(signup_wizard, self).create(cr, uid, values, context)
|
||||
return super(signup_signup, self).create(cr, uid, values, context)
|
||||
|
||||
def signup(self, cr, uid, ids, context=None):
|
||||
return {
|
||||
|
@ -63,3 +54,4 @@ class signup_wizard(osv.TransientModel):
|
|||
if pw != cpw:
|
||||
return {'value': {'state': 'missmatch'}}
|
||||
return {'value': {'state': 'draft'}}
|
||||
|
|
@ -1,25 +1,25 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
<record id="signup_wizard_form_view" model="ir.ui.view">
|
||||
<field name="name">signup.wizard.form</field>
|
||||
<field name="model">signup.wizard</field>
|
||||
<record id="signup_form_view" model="ir.ui.view">
|
||||
<field name="name">signup.signup.form</field>
|
||||
<field name="model">signup.signup</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Signup" version="7.0">
|
||||
<field name="state" invisible="1"/>
|
||||
<group colspan="4" states="draft,missmatch">
|
||||
<group colspan="4" states="draft,missmatch">
|
||||
<field name="name" required="1"/>
|
||||
<field name="email" required="1"/>
|
||||
<field name="pw" required='1' on_change="onchange_pw(pw,cpw)"/>
|
||||
<field name="cpw" required='1' on_change="onchange_pw(pw,cpw)"/>
|
||||
<field name="password" required='1' on_change="onchange_pw(password,password_confirmation)"/>
|
||||
<field name="password_confirmation" required='1' on_change="onchange_pw(password,password_confirmation)"/>
|
||||
<group colspan="4" states="missmatch">
|
||||
<div>Passwords missmatch</div>
|
||||
</group>
|
||||
<group colspan="2" col="1">
|
||||
<button string="Sign Up" name="signup" icon="gtk-connect" attrs="{'readonly': [('state', '=', 'missmatch')]}" type="object"/>
|
||||
<button string="Sign Up" name="signup" attrs="{'readonly': [('state', '=', 'missmatch')]}" type="object"/>
|
||||
</group>
|
||||
</group>
|
||||
</group>
|
||||
<group colspan="4" states="done" col="1">
|
||||
<div>You can now login.</div>
|
||||
<button special="cancel" string="Close"/>
|
||||
|
@ -28,10 +28,10 @@
|
|||
</field>
|
||||
</record>
|
||||
|
||||
<record id="action_reset" model="ir.actions.act_window">
|
||||
<field name="name">Reset Password</field>
|
||||
<record id="signup_action" model="ir.actions.act_window">
|
||||
<field name="name">signup.signup</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">signup.wizard</field>
|
||||
<field name="res_model">signup.signup</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="target">new</field>
|
|
@ -9,7 +9,7 @@ openerp.signup = function(instance) {
|
|||
var am = p.action_manager;
|
||||
am.do_action({
|
||||
type:'ir.actions.act_window',
|
||||
res_model: 'signup.wizard',
|
||||
res_model: 'signup.signup',
|
||||
views: [[false, 'form']],
|
||||
target: 'new',
|
||||
name: 'Sign Up'
|
||||
|
|
Loading…
Reference in New Issue