Changeset - 140f2811fc6f
[Not reviewed]
default
0 5 0
Thomas De Schampheleire - 11 years ago 2015-04-23 21:44:19
thomas.de.schampheleire@gmail.com
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.
5 files changed with 13 insertions and 3 deletions:
0 comments (0 inline, 0 general)
kallithea/controllers/changeset.py
Show inline comments
 
@@ -346,13 +346,13 @@ class ChangesetController(BaseRepoContro
 
    @NotAnonymous()
 
    @HasRepoPermissionAnyDecorator('repository.read', 'repository.write',
 
                                   'repository.admin')
 
    @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,
 
            repo=c.db_repo.repo_id,
 
            user=c.authuser.user_id,
 
            revision=revision,
kallithea/controllers/pullrequests.py
Show inline comments
 
@@ -693,13 +693,13 @@ class PullrequestsController(BaseRepoCon
 
        status = 0
 
        close_pr = False
 
        allowed_to_change_status = self._get_is_allowed_change_status(pull_request)
 
        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
 

	
 
        comm = ChangesetCommentsModel().create(
 
            text=text,
 
            repo=c.db_repo.repo_id,
kallithea/model/comment.py
Show inline comments
 
@@ -179,13 +179,13 @@ class ChangesetCommentsModel(BaseModel):
 
        :param f_path:
 
        :param line_no:
 
        :param status_change: (for emails, not for comments)
 
        :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
 

	
 
        repo = self._get_repo(repo)
 
        user = self._get_user(user)
 
        comment = ChangesetComment()
kallithea/public/css/style.css
Show inline comments
 
@@ -4344,12 +4344,16 @@ div.rst-block pre {
 
    padding: 0px 0px 10px 0px;
 
    font-weight: bold;
 
    color: #666;
 
    font-size: 16px;
 
}
 

	
 
.automatic-comment {
 
    font-style: italic;
 
}
 

	
 
/** comment form **/
 

	
 
.status-block {
 
    margin: 5px;
 
    clear: both
 
}
kallithea/templates/changeset/changeset_file_comment.html
Show inline comments
 
@@ -48,13 +48,19 @@
 
      <a class="permalink" href="#comment-${co.comment_id}">&para;</a>
 
      %if h.HasPermissionAny('hg.admin')() or h.HasRepoPermissionAny('repository.admin')(c.repo_name) or co.author.user_id == c.authuser.user_id:
 
          <div onClick="confirm('${_("Delete comment?")}') && deleteComment(${co.comment_id})" class="buttons delete-comment btn btn-mini">${_('Delete')}</div>
 
      %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>
 
</%def>
 

	
 

	
0 comments (0 inline, 0 general)