From ea8ea41fcd164761cbbd3f4d0625e0fe68bc9dbc Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Wed, 29 Feb 2012 19:09:26 +0530 Subject: [PATCH] background, user_info --- js/core.min.js | 9 +++++++++ js/legacy/app.js | 2 +- py/webnotes/boot.py | 14 ++++++++++---- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/js/core.min.js b/js/core.min.js index ffde7ae92e..168ae5a691 100644 --- a/js/core.min.js +++ b/js/core.min.js @@ -59,6 +59,15 @@ wn.page={set:function(src){var new_selection=$('.inner div.content[_src="'+src+' $('.inner .current_page').removeClass('current_page');new_selection.addClass('current_page');var title=$('nav ul li a[href*="'+src+'"]').attr('title')||'No Title' state=window.location.hash;if(state!=src){window.location.hash=state;} else{document.title=title;}}} +/* + * lib/js/wn/misc/user.js + */ +wn.user_info=function(uid){var def={'fullname':uid,'image':'lib/images/ui/no_img_m.gif'} +if(!wn.boot.user_info)return def +if(!wn.boot.user_info[uid])return def +if(!wn.boot.user_info[uid].fullname) +wn.boot.user_info[uid].fullname=uid;if(!wn.boot.user_info[uid].image) +wn.boot.user_info[uid].image=def.image;return wn.boot.user_info[uid];} /* * lib/js/lib/json2.js */ diff --git a/js/legacy/app.js b/js/legacy/app.js index 3a6eafdeb1..979cd77250 100644 --- a/js/legacy/app.js +++ b/js/legacy/app.js @@ -19,7 +19,7 @@ function startup() { profile = r.profile; user = r.profile.name; - user_fullname = wn.boot.user_fullnames ? wn.boot.user_fullnames[user] : 'Guest'; + user_fullname = wn.user_info(user).fullname; user_defaults = profile.defaults; user_roles = profile.roles; user_email = profile.email; diff --git a/py/webnotes/boot.py b/py/webnotes/boot.py index 9c286bea8e..ea6b6049dc 100644 --- a/py/webnotes/boot.py +++ b/py/webnotes/boot.py @@ -77,13 +77,19 @@ def get_fullnames(): import webnotes ret = webnotes.conn.sql("""select name, concat(ifnull(first_name, ''), - if(ifnull(first_name, '')!='', ' ', ''), ifnull(last_name, '')), user_image - from tabProfile where ifnull(enabled, 0)=1""") + if(ifnull(first_name, '')!='', ' ', ''), ifnull(last_name, '')), + user_image, gender + from tabProfile where ifnull(enabled, 0)=1""", as_list=1) d = {} for r in ret: - d[r[0]]= {'fullname': r[1], 'image': r[2]} + if not r[2]: + r[2] = 'lib/images/ui/no_img_m.gif' + else: + r[2] = 'files/' + r[2] + + d[r[0]]= {'fullname': r[1], 'image': r[2], 'gender': r[3]} - return ret + return d def get_profile(bootinfo): """get profile info"""