[PATCH 2 of 2 RFC] summary: add "last comment" tooltip to status icon
Angel Ezquerra
angel.ezquerra at gmail.com
Thu Feb 18 16:36:45 UTC 2016
# HG changeset patch
# User ezquerra
# Date 1455813238 -3600
# Thu Feb 18 17:33:58 2016 +0100
# Branch stable
# Node ID e30cb2b8e73aa5917e811e8090c7c9f72d00d998
# Parent 8087e93914290771452ad99d6d6a7f57c7fa02c3
summary: add "last comment" tooltip to status icon
This adds a tooltip to the "number of comments" indicator, indicating who did
the last comment and also showing the first line (up to 80 characters) of that
last comment. This lets you quickly check who last commented and what the
comment was about.
Note that as with the previous changeset in this series this is RFC.
A final solution should be improved in several ways:
- Apply this same change to the changelog template
- Move the code that this change embeds in the HTML somewhere else
- Maybe the calculations could be done once and stored in the database?
Since this is the first time that I change this sort of code (I did not even
know what mako was an hour ago!) I send this as an RFC in the hopes of getting
pointers to where this could be changed more cleanly. I also worry whether this
could have some negative performance impact?
diff --git a/kallithea/templates/changelog/changelog_summary_data.html b/kallithea/templates/changelog/changelog_summary_data.html
--- a/kallithea/templates/changelog/changelog_summary_data.html
+++ b/kallithea/templates/changelog/changelog_summary_data.html
@@ -10,6 +10,16 @@
last_cm = cm
return last_cm
+def find_last_non_empty_comment():
+ """find the last non empty comment"""
+ # comments might be emtpy if they only change the status
+ last_cm = None
+ for cm in c.comments[cs.raw_id]:
+ if not cm.text:
+ continue
+ last_cm = cm
+ return last_cm
+
def get_comment_username(cm):
return cm.author.username
%>
@@ -49,8 +59,13 @@
</td>
<td class="compact">
%if c.comments.get(cs.raw_id,[]):
+ <%last_comment_cm = find_last_non_empty_comment()%>
<div class="comments-container">
- <div title="${('comments')}">
+ %if last_comment_cm is None:
+ <div title="status change">
+ %else:
+ <div title="last comment from ${get_comment_username(last_comment_cm)}: ${last_comment_cm.text[:80].splitlines()[0]} ...">
+ %endif
<a href="${c.comments[cs.raw_id][0].url()}">
<i class="icon-comment"></i>${len(c.comments[cs.raw_id])}
</a>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: kallithea-2.patch
Type: text/x-patch
Size: 2550 bytes
Desc: not available
URL: <http://lists.sfconservancy.org/pipermail/kallithea-general/attachments/20160218/4eb21c6e/attachment.bin>
More information about the kallithea-general
mailing list