changeset 4329:f54dca244402

changeset: refactor set_status so a comment always must be specified
author Mads Kiilerich <madski@unity3d.com>
date Tue, 10 Dec 2013 19:30:37 +0100
parents 93e5683e3d2e
children 773980a93cdd
files kallithea/model/changeset_status.py kallithea/model/pull_request.py
diffstat 2 files changed, 12 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/kallithea/model/changeset_status.py	Fri Jul 18 18:44:54 2014 +0200
+++ b/kallithea/model/changeset_status.py	Tue Dec 10 19:30:37 2013 +0100
@@ -112,7 +112,7 @@
             return str(status.status) if status else ChangesetStatus.DEFAULT
         return status
 
-    def set_status(self, repo, status, user, comment=None, revision=None,
+    def set_status(self, repo, status, user, comment, revision=None,
                    pull_request=None, dont_allow_on_closed_pull_request=False):
         """
         Creates new status for changeset or updates the old ones bumping their
@@ -130,15 +130,6 @@
         repo = self._get_repo(repo)
 
         q = ChangesetStatus.query()
-        if not comment:
-            from kallithea.model.comment import ChangesetCommentsModel
-            comment = ChangesetCommentsModel().create(
-                text=u'Auto status change to %s' % (ChangesetStatus.get_status_lbl(status)),
-                repo=repo,
-                user=user,
-                pull_request=pull_request,
-                send_email=False
-            )
         if revision:
             q = q.filter(ChangesetStatus.repo == repo)
             q = q.filter(ChangesetStatus.revision == revision)
--- a/kallithea/model/pull_request.py	Fri Jul 18 18:44:54 2014 +0200
+++ b/kallithea/model/pull_request.py	Tue Dec 10 19:30:37 2013 +0100
@@ -91,10 +91,19 @@
         Session().flush()
 
         #reset state to under-review
-        ChangesetStatusModel().set_status(
+        from kallithea.model.comment import ChangesetCommentsModel
+        comment = ChangesetCommentsModel().create(
+            text=u'Auto status change to %s' % (ChangesetStatus.get_status_lbl(ChangesetStatus.STATUS_UNDER_REVIEW)),
             repo=org_repo,
-            status=ChangesetStatus.STATUS_UNDER_REVIEW,
             user=new.author,
+            pull_request=new,
+            send_email=False
+        )
+        ChangesetStatusModel().set_status(
+            org_repo,
+            ChangesetStatus.STATUS_UNDER_REVIEW,
+            new.author,
+            comment,
             pull_request=new
         )
         self.__add_reviewers(new, reviewers)