changeset 4454:9cfc66a665ae

pull requests: rework handling of comments and texts when voting and closing Close did not leave any records - now it does. Status changes without comments repeated the status change in text - now it doesn't repeat itself.
author Mads Kiilerich <madski@unity3d.com>
date Thu, 21 Aug 2014 23:46:55 +0200
parents 9fdd5ec8bc11
children 97f8ae90566a
files kallithea/controllers/changeset.py kallithea/controllers/pullrequests.py
diffstat 2 files changed, 10 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/kallithea/controllers/changeset.py	Thu Aug 21 23:46:55 2014 +0200
+++ b/kallithea/controllers/changeset.py	Thu Aug 21 23:46:55 2014 +0200
@@ -349,10 +349,7 @@
     @jsonify
     def comment(self, repo_name, revision):
         status = request.POST.get('changeset_status')
-        text = request.POST.get('text')
-        if status:
-            text = text or (_('Status change -> %s')
-                            % ChangesetStatus.get_status_lbl(status))
+        text = request.POST.get('text', '').strip() or _('No comments.')
 
         c.co = comm = ChangesetCommentsModel().create(
             text=text,
--- a/kallithea/controllers/pullrequests.py	Thu Aug 21 23:46:55 2014 +0200
+++ b/kallithea/controllers/pullrequests.py	Thu Aug 21 23:46:55 2014 +0200
@@ -687,17 +687,16 @@
     def comment(self, repo_name, pull_request_id):
         pull_request = PullRequest.get_or_404(pull_request_id)
 
-        status = request.POST.get('changeset_status')
-        text = request.POST.get('text')
-        close_pr = request.POST.get('save_close')
-
+        status = 0
+        close_pr = False
         allowed_to_change_status = self._get_is_allowed_change_status(pull_request)
-        if status and allowed_to_change_status:
-            _def = (_('Status change -> %s')
-                            % ChangesetStatus.get_status_lbl(status))
-            if close_pr:
-                _def = _('Closing with') + ' ' + _def
-            text = text or _def
+        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.')
+        if close_pr:
+            text = _('Closing.') + '\n' + text
+
         comm = ChangesetCommentsModel().create(
             text=text,
             repo=c.db_repo.repo_id,