From c2a9cca4fd2a08436695d0bc9152495f75aaa4a6 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Wed, 14 Dec 2011 17:12:12 +0530 Subject: [PATCH] Change in add user dialog box: Now it includes First Name, Last Name and Password field if run as a standalone app --- erpnext/home/page/my_company/my_company.js | 43 ++++++++++++++++++++-- erpnext/home/page/my_company/my_company.py | 19 +++++++--- 2 files changed, 53 insertions(+), 9 deletions(-) diff --git a/erpnext/home/page/my_company/my_company.js b/erpnext/home/page/my_company/my_company.js index e88c45897c..6a905501eb 100644 --- a/erpnext/home/page/my_company/my_company.js +++ b/erpnext/home/page/my_company/my_company.js @@ -42,13 +42,48 @@ pscript.myc_show_erpnext_message = function() { // Add user dialog and server call // pscript.myc_add_user = function() { + var fields = [{ + fieldtype: 'Data', + fieldname: 'user', + reqd: 1, + label: 'Email Id of the user to add' + }]; + console.log(pscript.is_erpnext_saas); + + if(pscript.is_erpnext_saas==0) { + fields = fields.concat([ + { + fieldtype: 'Data', + fieldname: 'first_name', + reqd: 1, + label: 'First Name' + }, + { + fieldtype: 'Data', + fieldname: 'last_name', + reqd: 1, + label: 'Last Name' + }, + { + fieldtype: 'Data', + fieldname: 'password', + reqd: 1, + label: 'Password' + }]); + } + + fields.push({ + fieldtype: 'Button', + label: 'Add', + fieldname: 'add' + }); + + console.log(fields); + var d = new wn.widgets.Dialog({ title: 'Add User', width: 400, - fields: [ - {fieldtype:'Data', fieldname:'user',reqd:1,label:'Email Id of the user to add'}, - {fieldtype:'Button', label:'Add', fieldname:'add'} - ] + fields: fields }); d.make(); d.fields_dict.add.input.onclick = function() { diff --git a/erpnext/home/page/my_company/my_company.py b/erpnext/home/page/my_company/my_company.py index c96d99871d..ad0089dc14 100644 --- a/erpnext/home/page/my_company/my_company.py +++ b/erpnext/home/page/my_company/my_company.py @@ -57,14 +57,15 @@ def add_user(args): from server_tools.gateway_utils import add_user_gateway add_user_gateway(args['user']) - add_profile(args['user']) + add_profile(args) # # add profile record # -def add_profile(email): +def add_profile(args): from webnotes.utils import validate_email_add from webnotes.model.doc import Document + email = args['user'] sql = webnotes.conn.sql @@ -83,9 +84,17 @@ def add_profile(email): pr = Document('Profile') pr.name = email pr.email = email - pr.enabled=1 - pr.user_type='System User' - pr.save(1) + pr.first_name = args.get('first_name') + pr.last_name = args.get('last_name') + pr.enabled = 1 + pr.user_type = 'System User' + pr.save(1) + + if args.get('password'): + sql(""" + UPDATE tabProfile + SET password = PASSWORD(%s) + WHERE name = %s""", (args.get('password'), email)) # # post comment