diff --git a/frappe/boot.py b/frappe/boot.py
index de9a14a544..bd9f524c11 100644
--- a/frappe/boot.py
+++ b/frappe/boot.py
@@ -9,6 +9,7 @@ bootstrap client session
import frappe
import frappe.defaults
import frappe.widgets.page
+from frappe.utils import get_gravatar
def get_bootinfo():
"""build and return boot info"""
@@ -92,18 +93,14 @@ def get_fullnames():
"""map of user fullnames"""
ret = frappe.db.sql("""select name,
concat(ifnull(first_name, ''),
- if(ifnull(last_name, '')!='', ' ', ''), ifnull(last_name, '')),
- user_image, gender, email
- from tabUser where ifnull(enabled, 0)=1""", as_list=1)
+ if(ifnull(last_name, '')!='', ' ', ''), ifnull(last_name, '')) as fullname,
+ user_image as image, gender, email
+ from tabUser where ifnull(enabled, 0)=1""", as_dict=1)
d = {}
for r in ret:
- if not r[2]:
- r[2] = '/assets/frappe/images/ui/avatar.png'
- else:
- r[2] = r[2]
-
- d[r[0]]= {'fullname': r[1], 'image': r[2], 'gender': r[3],
- 'email': r[4] or r[0]}
+ if not r.image:
+ r.image = get_gravatar()
+ d[r.name] = r
return d
diff --git a/frappe/core/doctype/user/user.json b/frappe/core/doctype/user/user.json
index 4003b57872..0ec305847c 100644
--- a/frappe/core/doctype/user/user.json
+++ b/frappe/core/doctype/user/user.json
@@ -3,7 +3,7 @@
"allow_copy": 0,
"allow_import": 1,
"allow_rename": 1,
- "creation": "2014-03-11 14:55:00.000000",
+ "creation": "2014-03-11 14:55:00",
"description": "Represents a User in the system.",
"docstatus": 0,
"doctype": "DocType",
@@ -116,6 +116,7 @@
"permlevel": 0
},
{
+ "description": "Get your globally recognized avatar from Gravatar.com",
"fieldname": "user_image",
"fieldtype": "Attach",
"hidden": 0,
@@ -420,7 +421,7 @@
"issingle": 0,
"istable": 0,
"max_attachments": 5,
- "modified": "2014-03-11 16:04:13.000000",
+ "modified": "2014-05-30 02:05:20.655024",
"modified_by": "Administrator",
"module": "Core",
"name": "User",
diff --git a/frappe/core/doctype/user/user.py b/frappe/core/doctype/user/user.py
index 967e4d3115..4c8501914d 100644
--- a/frappe/core/doctype/user/user.py
+++ b/frappe/core/doctype/user/user.py
@@ -3,7 +3,7 @@
from __future__ import unicode_literals
import frappe
-from frappe.utils import cint, now
+from frappe.utils import cint, now, get_gravatar
from frappe import throw, msgprint, _
from frappe.auth import _update_password
import frappe.permissions
@@ -90,10 +90,8 @@ class User(Document):
pass # email server not set, don't send email
def update_gravatar(self):
- import md5
if not self.user_image:
- self.user_image = "https://secure.gravatar.com/avatar/" + md5.md5(self.name).hexdigest() \
- + "?d=retro"
+ self.user_image = get_gravatar(self.name)
@Document.hook
def validate_reset_password(self):
diff --git a/frappe/core/page/messages/messages.js b/frappe/core/page/messages/messages.js
index fac7515f16..7856a959b0 100644
--- a/frappe/core/page/messages/messages.js
+++ b/frappe/core/page/messages/messages.js
@@ -1,5 +1,5 @@
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
-// MIT License. See license.txt
+// MIT License. See license.txt
frappe.provide('frappe.core.pages.messages');
@@ -8,9 +8,8 @@ frappe.pages.messages.onload = function(wrapper) {
parent: wrapper,
title: "Messages"
});
-
- $('
\
@@ -20,14 +19,14 @@ frappe.pages.messages.onload = function(wrapper) {
').appendTo($(wrapper).find('.layout-main-section'));
wrapper.appframe.add_module_icon("Messages");
-
+
frappe.core.pages.messages = new frappe.core.pages.messages(wrapper);
}
$(frappe.pages.messages).bind('show', function() {
// remove alerts
$('#alert-container .alert').remove();
-
+
frappe.core.pages.messages.show();
setTimeout("frappe.core.pages.messages.refresh()", 5000);
})
@@ -38,11 +37,11 @@ frappe.core.pages.messages = Class.extend({
this.show_active_users();
this.make_post_message();
this.make_list();
- //this.update_messages('reset'); //Resets notification icons
+ //this.update_messages('reset'); //Resets notification icons
},
make_post_message: function() {
var me = this;
-
+
$('#post-message .btn').click(function() {
var txt = $('#post-message textarea').val();
if(txt) {
@@ -60,7 +59,7 @@ frappe.core.pages.messages = Class.extend({
},
btn: this
});
- }
+ }
});
},
show: function() {
@@ -72,20 +71,20 @@ frappe.core.pages.messages = Class.extend({
$('#avatar-image').attr("src", frappe.utils.get_file_link(frappe.user_info(contact).image));
$("#show-everyone").toggle(contact!==user);
-
+
$("#post-message button").text(contact==user ? __("Post Publicly") : __("Post to user"))
-
+
this.contact = contact;
this.list.opts.args.contact = contact;
this.list.run();
-
+
},
// check for updates every 5 seconds if page is active
refresh: function() {
setTimeout("frappe.core.pages.messages.refresh()", 5000);
- if(frappe.container.page.label != 'Messages')
+ if(frappe.container.page.label != 'Messages')
return;
- if(!frappe.session_alive)
+ if(!frappe.session_alive)
return;
this.show();
},
@@ -110,7 +109,7 @@ frappe.core.pages.messages = Class.extend({
no_loading: true,
render_row: function(wrapper, data) {
$(wrapper).removeClass('list-row');
-
+
data.creation = dateutil.comment_when(data.creation);
data.comment_by_fullname = frappe.user_info(data.owner).fullname;
data.image = frappe.utils.get_file_link(frappe.user_info(data.owner).image);
@@ -119,7 +118,7 @@ frappe.core.pages.messages = Class.extend({
data.reply_html = '';
if(data.owner==user) {
data.cls = 'message-self';
- data.comment_by_fullname = 'You';
+ data.comment_by_fullname = 'You';
} else {
data.cls = 'message-other';
}
@@ -131,7 +130,7 @@ frappe.core.pages.messages = Class.extend({
onclick="frappe.core.pages.messages.delete(this)"\
data-name="%(name)s">×', data);
}
-
+
if(data.owner==data.comment_docname && data.parenttype!="Assignment") {
data.mark_html = "
"
@@ -171,7 +170,7 @@ frappe.core.pages.messages = Class.extend({
').appendTo($body);
$("#show-everyone").toggle(me.contact!==user);
-
+
r.message.sort(function(a, b) { return b.has_session - a.has_session; });
for(var i in r.message) {
var p = r.message[i];
@@ -186,7 +185,7 @@ frappe.core.pages.messages = Class.extend({
title="%(status)s">
s)
\
%(fullname)s\
', p))
- .appendTo($body);
+ .appendTo($body);
}
}
}
diff --git a/frappe/public/js/frappe/misc/user.js b/frappe/public/js/frappe/misc/user.js
index 43a3f337ad..e429195c33 100644
--- a/frappe/public/js/frappe/misc/user.js
+++ b/frappe/public/js/frappe/misc/user.js
@@ -4,17 +4,11 @@
// misc user functions
frappe.user_info = function(uid) {
- var def = {
- 'fullname':uid,
- 'image': 'assets/frappe/images/ui/avatar.png'
- }
- if(!frappe.boot.user_info) return def
- if(!frappe.boot.user_info[uid]) return def
- if(!frappe.boot.user_info[uid].fullname)
- frappe.boot.user_info[uid].fullname = uid;
- if(!frappe.boot.user_info[uid].image)
- frappe.boot.user_info[uid].image = def.image;
- return frappe.boot.user_info[uid];
+ if(!uid)
+ uid = user;
+ if(!frappe.boot.user_info)
+ return {fullname:"Unknown"};
+ return frappe.boot.user_info[uid] || {};
}
frappe.avatar = function(user, large, title) {
diff --git a/frappe/public/js/frappe/ui/toolbar/search.js b/frappe/public/js/frappe/ui/toolbar/search.js
index 646d20d9fa..2713d75646 100644
--- a/frappe/public/js/frappe/ui/toolbar/search.js
+++ b/frappe/public/js/frappe/ui/toolbar/search.js
@@ -54,6 +54,9 @@ frappe.search = {
response(frappe.search.options);
},
+ focus: function(event, ui) {
+ return false;
+ },
select: function(event, ui) {
if(ui.item.route_options) {
frappe.route_options = ui.item.route_options;
@@ -67,7 +70,7 @@ frappe.search = {
setTimeout(function() { $("#navbar-search").val(""); }, 100);
}
}).data('ui-autocomplete')._renderItem = function(ul, d) {
- var html = "
" + d.value + "";
+ var html = "
" + d.value + "";
if(d.description && d.value!==d.description) {
html += '
' + d.description + '';
}
@@ -97,7 +100,7 @@ frappe.search.verbs = [
var route = frappe.get_route();
if(route[0]==="List") {
frappe.search.options.push({
- value: __('Find "{0}" in {1}', [txt, route[1]]),
+ value: __('Find {0} in {1}', ["
"+txt+"", "
" + route[1] + ""]),
route_options: {"name": ["like", "%" + txt + "%"]},
onclick: function() {
frappe.container.page.doclistview.set_route_options();
@@ -113,7 +116,7 @@ frappe.search.verbs = [
if(txt.split(" ")[0]==="new") {
frappe.search.find(frappe.boot.user.can_create, txt.substr(4), function(match) {
return {
- value:__("New {0}", [match]),
+ value:__("New {0}", ["
"+match+""]),
route:["Form", match, "New " + match]
}
});
@@ -124,7 +127,7 @@ frappe.search.verbs = [
function(txt) {
frappe.search.find(frappe.boot.user.can_read, txt, function(match) {
return {
- value: __("{0} List", [match]),
+ value: __("{0} List", ["
"+match+""]),
route:["List", match]
}
});
@@ -134,7 +137,7 @@ frappe.search.verbs = [
function(txt) {
frappe.search.find(keys(frappe.boot.page_info), txt, function(match) {
return {
- value: __("Open {0}", [match]),
+ value: __("Open {0}", ["
"+match+""]),
route: [match]
}
});
@@ -144,12 +147,12 @@ frappe.search.verbs = [
function(txt) {
frappe.search.find(keys(frappe.modules), txt, function(match) {
ret = {
- value: __("Open {0}", [match]),
+ value: __("Open {0}", ["
"+match+""]),
}
if(frappe.modules[match].link) {
ret.route = [frappe.modules[match].link];
} else {
- ret.route = ["Module", match];
+ ret.route = ["Module", "
"+match+""];
}
return ret;
});
@@ -161,7 +164,7 @@ frappe.search.verbs = [
parts = txt.split(" in ");
frappe.search.find(frappe.boot.user.can_read, parts[1], function(match) {
return {
- value: __('Find "{0}" in {1}', [parts[0], match]),
+ value: __('Find {0} in {1}', ["
"+parts[0]+"", "
"+match+""]),
route_options: {"name": ["like", "%" + parts[0] + "%"]},
route: ["List", match]
}
@@ -179,17 +182,17 @@ frappe.search.verbs = [
try {
var val = eval(txt);
+ frappe.search.options.push({
+ value: $.format('{0} = {1}', [txt, "
"+val+""]),
+ match: val,
+ onclick: function(match) {
+ msgprint(match, "Result");
+ }
+ });
} catch(e) {
- var val = e.message;
+ // pass
}
- frappe.search.options.push({
- value: $.format('"{0}" = {1}', [txt, val]),
- match: val,
- onclick: function(match) {
- msgprint(match, "Result");
- }
- });
};
},
];
diff --git a/frappe/public/js/frappe/ui/toolbar/toolbar.js b/frappe/public/js/frappe/ui/toolbar/toolbar.js
index 8ad4510204..4b999b6a0f 100644
--- a/frappe/public/js/frappe/ui/toolbar/toolbar.js
+++ b/frappe/public/js/frappe/ui/toolbar/toolbar.js
@@ -131,9 +131,8 @@ frappe.ui.toolbar.Toolbar = Class.extend({
');
},
set_user_name: function() {
- var fn = user_fullname;
- if(fn.length > 15) fn = fn.substr(0,12) + '...';
- $('#toolbar-user-name').html(fn);
+ $('#toolbar-user-name').html('
.image+')
');
},
make_user_menu: function() {
diff --git a/frappe/utils/__init__.py b/frappe/utils/__init__.py
index deaabf31d6..c4d79c7ef9 100644
--- a/frappe/utils/__init__.py
+++ b/frappe/utils/__init__.py
@@ -75,6 +75,10 @@ def random_string(length):
from random import choice
return ''.join([choice(string.letters + string.digits) for i in range(length)])
+def get_gravatar(email):
+ import md5
+ return "https://secure.gravatar.com/avatar/" + md5.md5(email).hexdigest()
+
def get_traceback():
"""
Returns the traceback of the Exception