[PATCH V2] changeset: improve the comment count information display

Angel Ezquerra angel.ezquerra at gmail.com
Sat Feb 27 15:49:56 UTC 2016


# HG changeset patch
# User Angel Ezquerra <angel.ezquerra at gmail.com>
# Date 1456572240 -3600
#      Sat Feb 27 12:24:00 2016 +0100
# Node ID 40af58461b7a72f3bccc5ff8bf88da942b5931c1
# Parent  c71b5a31fd80f5f4e8b0ce8da47aec2fff354891
changeset: improve the comment count information display

Some recent revisions have changed the way comments are counted. We no longer
count "status change only comments" as comments on the changelog, etc. This
change tries to make the way we count comments on the changest details page
match the way we count them everywhere else. At the same time this tries to

Change the way the comment count information is displayed as follows:

- Separately count the number of status changes and the number of comment
changes (to match how comments are counted everywhere else)
- Only show the status and comment counts when needed (i.e. show nothing when
there are no comments or status changes)
- Visually separate the counts from the "First comment" link by adding a "|"
separator.

diff --git a/kallithea/templates/changeset/changeset.html b/kallithea/templates/changeset/changeset.html
--- a/kallithea/templates/changeset/changeset.html
+++ b/kallithea/templates/changeset/changeset.html
@@ -64,7 +64,7 @@
                   ${c.context_url(request.GET)}
                 </div>
                 <div class="comments-number" style="float:right;padding-right:5px">
-                    ${comment.comment_count(c.inline_cnt, len(c.comments))}
+                    ${comment.comment_count(c.inline_cnt, c.comments)}
                 </div>
             </div>
         </div>
diff --git a/kallithea/templates/changeset/changeset_file_comment.html b/kallithea/templates/changeset/changeset_file_comment.html
--- a/kallithea/templates/changeset/changeset_file_comment.html
+++ b/kallithea/templates/changeset/changeset_file_comment.html
@@ -122,13 +122,33 @@
 </%def>
 
 
-## show comment count as "x comments (y inline, z general)"
-<%def name="comment_count(inline_cnt, general_cnt)">
-    ${'%s (%s, %s)' % (
-        ungettext("%d comment", "%d comments", inline_cnt + general_cnt) % (inline_cnt + general_cnt),
-        ungettext("%d inline", "%d inline", inline_cnt) % inline_cnt,
-        ungettext("%d general", "%d general", general_cnt) % general_cnt
-    )}
+## show comment count as "w comments (x inline, y general), z status changes"
+<%def name="comment_count(inline_cnt, comments)">
+    <%
+    general_cnt = len([cm for cm in comments if cm.text])
+    status_cnt = len([cm for cm in comments if cm.status_change])
+    comment_cnt = inline_cnt + general_cnt
+    %>
+    %if status_cnt:
+        ${ungettext("%d status change", "%d status changes", status_cnt) % status_cnt}
+        %if comment_cnt:
+            ${", "}
+        %endif
+    %endif
+    %if inline_cnt > 0 and general_cnt > 0:
+        ${'%s (%s, %s)' % (
+            ungettext("%d comment", "%d comments", inline_cnt + general_cnt) % (inline_cnt + general_cnt),
+            ungettext("%d inline", "%d inline", inline_cnt) % inline_cnt,
+            ungettext("%d general", "%d general", general_cnt) % general_cnt,
+        )}
+    %elif inline_cnt > 0:
+        ${ungettext("%d inline comment", "%d inline comments", inline_cnt) % inline_cnt,}
+    %elif general_cnt > 0:
+        ${ungettext("%d general comment", "%d general comments", general_cnt) % general_cnt,}
+    %endif
+    %if status_cnt + comment_cnt:
+        |
+    %endif
     <span class="firstlink"></span>
 </%def>
 
@@ -154,7 +174,7 @@
       </div>
 </div>
 <div class="comments-number">
-    ${comment_count(c.inline_cnt, len(c.comments))}
+    ${comment_count(c.inline_cnt, c.comments)}
 </div>
 </%def>
 
diff --git a/kallithea/templates/pullrequests/pullrequest_show.html b/kallithea/templates/pullrequests/pullrequest_show.html
--- a/kallithea/templates/pullrequests/pullrequest_show.html
+++ b/kallithea/templates/pullrequests/pullrequest_show.html
@@ -309,7 +309,7 @@
     <div class="table">
           <div id="changeset_compare_view_content">
               <div style="font-size:1.1em;font-weight: bold;clear:both;padding-top:10px">
-                  ${comment.comment_count(c.inline_cnt, len(c.comments))}
+                  ${comment.comment_count(c.inline_cnt, c.comments)}
               </div>
               ##CS
               <div style="font-size:1.1em;font-weight: bold;clear:both;padding-top:10px">
-------------- next part --------------
A non-text attachment was scrubbed...
Name: kallithea.patch
Type: text/x-patch
Size: 4409 bytes
Desc: not available
URL: <http://lists.sfconservancy.org/pipermail/kallithea-general/attachments/20160227/89d0604a/attachment.bin>


More information about the kallithea-general mailing list