changeset b730e22cecdf in bugs.tryton.org:default
details: https://hg.tryton.org/bugs.tryton.org?cmd=changeset;node=b730e22cecdf
description:
Display gravatar profile image of user
issue9998
review323041002
diffstat:
extensions/gravatar.py | 11 +++++++++++
html/home.html | 2 +-
html/issue.index.html | 28 ++++++++++++++++++++++++++--
html/issue.item.html | 3 ++-
html/layout/navigation.html | 2 +-
html/layout/page.html | 4 ++--
6 files changed, 43 insertions(+), 7 deletions(-)
diffs (118 lines):
diff -r d2581a79398b -r b730e22cecdf extensions/gravatar.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/extensions/gravatar.py Tue Jan 19 00:11:45 2021 +0100
@@ -0,0 +1,11 @@
+import hashlib
+
+
+def gravatar(email, size=100, rating='g', default='retro'):
+ hash = hashlib.md5(str(email).encode('utf-8')).hexdigest()
+ return ('//www.tryton.org/avatar/{hash}'
+ '?s={size}&d={default}&r={rating}'.format(**locals()))
+
+
+def init(instance):
+ instance.registerUtil('gravatar', gravatar)
diff -r d2581a79398b -r b730e22cecdf html/home.html
--- a/html/home.html Wed Jan 13 19:25:11 2021 +0100
+++ b/html/home.html Tue Jan 19 00:11:45 2021 +0100
@@ -2,7 +2,7 @@
db.issue.renderWith('index',
sort=[('-', 'activity')], group=[('+', 'priority')],
filter=['status'],
- columns=['id','activity','title','creator','assignedto', 'status'],
+ columns=['id','activity','title','nosy','status'],
filterspec={'status':['-1','1','2','3','4','5','6','7']}
)|u|safe
}}
diff -r d2581a79398b -r b730e22cecdf html/issue.index.html
--- a/html/issue.index.html Wed Jan 13 19:25:11 2021 +0100
+++ b/html/issue.index.html Tue Jan 19 00:11:45 2021 +0100
@@ -51,6 +51,9 @@
{% if request.show.assignedto %}
<th scope="col">{% trans %}Assigned To{% endtrans %}</th>
{% endif %}
+ {% if request.show.nosy %}
+ <th scope="col">{% trans %}Nosy{% endtrans %}</th>
+ {% endif %}
</tr>
</thead>
{% for issue in batch %}
@@ -97,10 +100,31 @@
<td>{{ issue.status.plain()|u }}</td>
{% endif %}
{% if request.show.creator %}
- <td>{{ issue.creator.plain()|u }}</td>
+ <td>
+ <img src="{{ utils.gravatar(issue.creator.address, size=25) }}"
class="rounded-circle m-1 border border-secondary" title="{{
issue.creator.plain()|u }}">
+ </td>
{% endif %}
{% if request.show.assignedto %}
- <td>{{ issue.assignedto.plain()|u }}</td>
+ <td>
+ <img src="{{ utils.gravatar(issue.assignedto.address, size=25)
}}" class="rounded-circle m-1 border border-primary" title="{{
issue.assignedto.plain()|u }}">
+ </td>
+ {% endif %}
+ {% if request.show.nosy %}
+ <td>
+ {% for user in issue.nosy %}
+ {% if user.id == issue.assignedto.id %}
+ {% if not request.show.assignedto %}
+ <img src="{{ utils.gravatar(user.address, size=25) }}"
class="rounded-circle m-1 border border-primary" title="{{ user.username|u }}
({% trans %}Assigned To{% endtrans %}) {% if user.id == issue.creator.id %} ({%
trans %}Creator{% endtrans %}){% endif %}">
+ {% endif %}
+ {% elif user.id == issue.creator.id %}
+ {% if not request.show.creator %}
+ <img src="{{ utils.gravatar(user.address, size=25) }}"
class="rounded-circle m-1 border border-secondary" title="{{ user.username|u }}
({% trans %}Creator{% endtrans %})">
+ {% endif %}
+ {% else %}
+ <img src="{{ utils.gravatar(user.address, size=25) }}"
class="rounded-circle m-1" title="{{ user.username|u }}">
+ {% endif %}
+ {% endfor %}
+ </td>
{% endif %}
</tr>
{% endfor %}
diff -r d2581a79398b -r b730e22cecdf html/issue.item.html
--- a/html/issue.item.html Wed Jan 13 19:25:11 2021 +0100
+++ b/html/issue.item.html Tue Jan 19 00:11:45 2021 +0100
@@ -82,7 +82,7 @@
{% for msg in context.messages.reverse() %}
{% if msg.author.username not in bots %}
<div class="anchor" id="msg{{ msg.id }}"></div>
- <div class="row row-cols-1 row-cols-md-4 mt-4">
+ <div class="row row-cols-1 row-cols-md-4 mt-4" style="margin-left:
45px;">
<div class="col col-md-auto">
<a href='issue{{ context.id }}#msg{{ msg.id }}'>msg{{msg.id}}</a>
<a href='msg{{ msg.id }}'>(view)</a>
@@ -113,6 +113,7 @@
</div>
{% endif %}
<div class="{{ 'bot' if msg.author.username in bots }}">
+ <img src="{{ utils.gravatar(msg.author.address.plain(), size=45) }}"
class="rounded-circle float-left m-1">
{% if msg.type == 'text/markdown' %}
<div class="msg">{{
utils.codereview_replace(utils.mercurial_replace(msg.content.markdown()))|u|safe
}}</div>
{% elif msg.type == 'text/x-rst' %}
diff -r d2581a79398b -r b730e22cecdf html/layout/navigation.html
--- a/html/layout/navigation.html Wed Jan 13 19:25:11 2021 +0100
+++ b/html/layout/navigation.html Tue Jan 19 00:11:45 2021 +0100
@@ -147,7 +147,7 @@
'@sort': '-activity',
'@group': 'priority',
'@filter': 'status,assignedto',
- '@columns': 'id,activity,title,creator,status',
+ '@columns': 'id,activity,title,nosy,status',
'@search_text': '',
'status': status_notresolved,
'assignedto': request.user.id,
diff -r d2581a79398b -r b730e22cecdf html/layout/page.html
--- a/html/layout/page.html Wed Jan 13 19:25:11 2021 +0100
+++ b/html/layout/page.html Tue Jan 19 00:11:45 2021 +0100
@@ -1,6 +1,6 @@
{% set status_notresolved = '-1,1,2,3,4,5,6,7' -%}
-{% set columns = 'id,activity,title,creator,status' -%}
-{% set columns_showall = 'id,activity,title,creator,assignedto,status' -%}
+{% set columns = 'id,activity,title,nosy,status' -%}
+{% set columns_showall = 'id,activity,title,nosy,status' -%}
<!doctype html>
<html>
<head>