[PATCH 2 of 3] changeset status: simplify status calculation logic

Thomas De Schampheleire patrickdepinguin at gmail.com
Sat Apr 18 16:11:52 EDT 2015


# HG changeset patch
# User Thomas De Schampheleire <thomas.de.schampheleire at gmail.com>
# Date 1429275524 -7200
#      Fri Apr 17 14:58:44 2015 +0200
# Node ID a37093840d5181cfbfe3e3b730525945054c15a2
# Parent  928837725c3c0d8e7e8fbef23b7e12d5a4ddb66c
changeset status: simplify status calculation logic

diff --git a/kallithea/model/changeset_status.py b/kallithea/model/changeset_status.py
--- a/kallithea/model/changeset_status.py
+++ b/kallithea/model/changeset_status.py
@@ -72,16 +72,13 @@
         the policy: approve if consensus.
         """
 
-        approved_votes = 0
-        for st in statuses:
-            if st and st.status == ChangesetStatus.STATUS_APPROVED:
-                approved_votes += 1
+        if not statuses:
+            return ChangesetStatus.STATUS_UNDER_REVIEW
 
-        result = ChangesetStatus.STATUS_UNDER_REVIEW
-        if approved_votes and approved_votes == len(statuses):
-            result = ChangesetStatus.STATUS_APPROVED
+        if all(st.status == ChangesetStatus.STATUS_APPROVED for st in statuses):
+            return ChangesetStatus.STATUS_APPROVED
 
-        return result
+        return ChangesetStatus.STATUS_UNDER_REVIEW
 
     def calculate_pull_request_result(self, pull_request):
         """


More information about the kallithea-general mailing list