[PATCH v2] comments: avoid confusing 'No comments' on empty general comments
Thomas De Schampheleire
patrickdepinguin at gmail.com
Sat Apr 25 14:34:14 EDT 2015
# HG changeset patch
# User Thomas De Schampheleire <thomas.de.schampheleire at gmail.com>
# Date 1429818259 -7200
# Thu Apr 23 21:44:19 2015 +0200
# Node ID 471b0adcad4cb7e40db3599340fe1b6242d3a7b8
# Parent accdfd58edfb0687cfb2e59e619e2f90ed8f0d35
comments: avoid confusing 'No comments' on empty general comments
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. This is confusing when the reviewer has added
one or more inline comments.
Moreover, the stub text is added to the database, and not generated on
demand.
This commit makes following changes:
- do not add a stub text to the database, but generate it on demand
- allow adding an empty comment to the database when there is a status
change. An empty comment without status change is ignored.
- the stub text is marked with 'Automatic comment' and 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.
diff --git a/kallithea/controllers/changeset.py b/kallithea/controllers/changeset.py
--- a/kallithea/controllers/changeset.py
+++ b/kallithea/controllers/changeset.py
@@ -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,
diff --git a/kallithea/controllers/pullrequests.py b/kallithea/controllers/pullrequests.py
--- a/kallithea/controllers/pullrequests.py
+++ b/kallithea/controllers/pullrequests.py
@@ -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
diff --git a/kallithea/model/comment.py b/kallithea/model/comment.py
--- a/kallithea/model/comment.py
+++ b/kallithea/model/comment.py
@@ -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
diff --git a/kallithea/public/css/style.css b/kallithea/public/css/style.css
--- a/kallithea/public/css/style.css
+++ b/kallithea/public/css/style.css
@@ -4347,6 +4347,10 @@
font-size: 16px;
}
+.automatic-comment {
+ font-style: italic;
+}
+
/** comment form **/
.status-block {
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
@@ -51,7 +51,13 @@
%endif
</div>
<div class="text">
+ %if not co.text:
+ <div class="rst-block automatic-comment">
+ <p>[ Automatic comment: status change ]</p>
+ </div>
+ %else:
${h.rst_w_mentions(co.text)|n}
+ %endif
</div>
</div>
</div>
More information about the kallithea-general
mailing list