changeset 5068:140f2811fc6f

comments: avoid storing 'No comments' text when changing status When a general comment (with or without status change) is added to a changeset or pull request, and no text was added, Kallithea automatically used 'No comments' as text. The stub text is added to the database as if it has been entered by the user and it can thus not easily be identified as an automatic comment. This commit makes following changes: - allow adding an empty comment to the database when there is a status change. An empty comment without status change is ignored. - do not add a stub text to the database, but generate it on demand - the stub text is shown in italic font to differentiate it from user-entered text Currently there is a large amount of duplication between controllers/changeset.py and controllers/pullrequests.py, which is to be cleaned up in a later commit.
author Thomas De Schampheleire <thomas.de.schampheleire@gmail.com>
date Thu, 23 Apr 2015 21:44:19 +0200
parents 481a484b1d69
children 3105842da68f
files kallithea/controllers/changeset.py kallithea/controllers/pullrequests.py kallithea/model/comment.py kallithea/public/css/style.css kallithea/templates/changeset/changeset_file_comment.html
diffstat 5 files changed, 13 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/kallithea/controllers/changeset.py	Sat Apr 25 21:58:28 2015 +0200
+++ b/kallithea/controllers/changeset.py	Thu Apr 23 21:44:19 2015 +0200
@@ -349,7 +349,7 @@
     @jsonify
     def comment(self, repo_name, revision):
         status = request.POST.get('changeset_status')
-        text = request.POST.get('text', '').strip() or _('No comments.')
+        text = request.POST.get('text', '').strip()
 
         c.co = comm = ChangesetCommentsModel().create(
             text=text,
--- a/kallithea/controllers/pullrequests.py	Sat Apr 25 21:58:28 2015 +0200
+++ b/kallithea/controllers/pullrequests.py	Thu Apr 23 21:44:19 2015 +0200
@@ -696,7 +696,7 @@
         if allowed_to_change_status:
             status = request.POST.get('changeset_status')
             close_pr = request.POST.get('save_close')
-        text = request.POST.get('text', '').strip() or _('No comments.')
+        text = request.POST.get('text', '').strip()
         if close_pr:
             text = _('Closing.') + '\n' + text
 
--- a/kallithea/model/comment.py	Sat Apr 25 21:58:28 2015 +0200
+++ b/kallithea/model/comment.py	Thu Apr 23 21:44:19 2015 +0200
@@ -182,7 +182,7 @@
         :param closing_pr: (for emails, not for comments)
         :param send_email: also send email
         """
-        if not text:
+        if not status_change and not text:
             log.warning('Missing text for comment, skipping...')
             return
 
--- a/kallithea/public/css/style.css	Sat Apr 25 21:58:28 2015 +0200
+++ b/kallithea/public/css/style.css	Thu Apr 23 21:44:19 2015 +0200
@@ -4347,6 +4347,10 @@
     font-size: 16px;
 }
 
+.automatic-comment {
+    font-style: italic;
+}
+
 /** comment form **/
 
 .status-block {
--- a/kallithea/templates/changeset/changeset_file_comment.html	Sat Apr 25 21:58:28 2015 +0200
+++ b/kallithea/templates/changeset/changeset_file_comment.html	Thu Apr 23 21:44:19 2015 +0200
@@ -51,7 +51,13 @@
       %endif
       </div>
       <div class="text">
+        %if co.text:
           ${h.rst_w_mentions(co.text)|n}
+        %else:
+          <div class="rst-block automatic-comment">
+            <p>${_('No comments.')}</p>
+          </div>
+        %endif
       </div>
     </div>
   </div>