[minor] get_gravatar in templates to not query and show
This commit is contained in:
parent
9e008ce1ca
commit
620b2f82b3
7 changed files with 15 additions and 13 deletions
|
|
@ -180,7 +180,7 @@ def serve(port=8000, profile=False, site=None, sites_path='.'):
|
|||
from werkzeug.serving import run_simple
|
||||
|
||||
if profile:
|
||||
application = ProfilerMiddleware(application, sort_by=('tottime', 'calls'))
|
||||
application = ProfilerMiddleware(application, sort_by=('cumtime', 'calls'))
|
||||
|
||||
if not os.environ.get('NO_STATICS'):
|
||||
application = SharedDataMiddleware(application, {
|
||||
|
|
|
|||
|
|
@ -77,6 +77,14 @@ frappe.get_abbr = function(txt, max_length) {
|
|||
return abbr || "?";
|
||||
}
|
||||
|
||||
frappe.gravatars = {};
|
||||
frappe.get_gravatar = function(email_id) {
|
||||
if(!frappe.gravatars[email_id]) {
|
||||
frappe.gravatars[email_id] = "https://secure.gravatar.com/avatar/" + md5(email_id) + "?d=retro";
|
||||
}
|
||||
return frappe.gravatars[email_id];
|
||||
}
|
||||
|
||||
// string commons
|
||||
|
||||
function repl(s, dict) {
|
||||
|
|
|
|||
|
|
@ -29,15 +29,6 @@ frappe.user_info = function(uid) {
|
|||
return user_info;
|
||||
}
|
||||
|
||||
|
||||
frappe.gravatars = {};
|
||||
frappe.get_gravatar = function(email_id) {
|
||||
if(!frappe.gravatars[email_id]) {
|
||||
frappe.gravatars[email_id] = "https://secure.gravatar.com/avatar/" + md5(email_id) + "?d=retro";
|
||||
}
|
||||
return frappe.gravatars[email_id];
|
||||
}
|
||||
|
||||
frappe.ui.set_user_background = function(src, selector, style) {
|
||||
if(!selector) selector = "#page-desktop";
|
||||
if(!style) style = "Fill Screen";
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
<a href="/me">My Account</a>
|
||||
</li>
|
||||
{% for item in my_account_list -%}
|
||||
{% if item.count or (not item.reference_doctype) %}
|
||||
{% if item.count or (not item.reference_doctype) or item.show_always %}
|
||||
<li class="sidebar-item">
|
||||
<a href="{{ item.route }}" class="text-muted {{ 'active' if pathname==item.route else '' }}"
|
||||
{% if item.target %}target="{{ item.target }}"{% endif %}>
|
||||
|
|
|
|||
|
|
@ -137,6 +137,9 @@ def has_gravatar(email):
|
|||
except requests.exceptions.ConnectionError:
|
||||
return ''
|
||||
|
||||
def get_gravatar_url(email):
|
||||
return "https://secure.gravatar.com/avatar/{hash}?d=mm&s=200".format(hash=md5.md5(email).hexdigest())
|
||||
|
||||
def get_gravatar(email):
|
||||
gravatar_url = has_gravatar(email)
|
||||
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ def get_allowed_functions_for_jenv():
|
|||
"user": getattr(frappe.local, "session", None) and frappe.local.session.user or "Guest",
|
||||
"date_format": frappe.db.get_default("date_format") or "yyyy-mm-dd",
|
||||
"get_fullname": frappe.utils.get_fullname,
|
||||
"get_gravatar": frappe.utils.get_gravatar,
|
||||
"get_gravatar": frappe.utils.get_gravatar_url,
|
||||
"full_name": getattr(frappe.local, "session", None) and frappe.local.session.data.full_name or "Guest",
|
||||
"render_template": frappe.render_template
|
||||
},
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ def add_sidebar_data(context):
|
|||
import frappe.templates.pages.list
|
||||
|
||||
context.my_account_list = frappe.get_all('Portal Menu Item',
|
||||
fields=['title', 'route', 'reference_doctype'], filters={'enabled': 1}, order_by='idx asc')
|
||||
fields=['title', 'route', 'reference_doctype', 'show_always'], filters={'enabled': 1}, order_by='idx asc')
|
||||
|
||||
for item in context.my_account_list:
|
||||
if item.reference_doctype:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue