Changeset - 930caa6a4e5f
[Not reviewed]
default
0 1 0
Thomas De Schampheleire - 11 years ago 2015-04-17 14:58:44
thomas.de.schampheleire@gmail.com
changeset status: simplify status calculation logic
1 file changed with 5 insertions and 8 deletions:
0 comments (0 inline, 0 general)
kallithea/model/changeset_status.py
Show inline comments
 
@@ -69,22 +69,19 @@ class ChangesetStatusModel(BaseModel):
 
    def _calculate_status(self, statuses):
 
        """
 
        Given a list of statuses, calculate the resulting status, according to
 
        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):
 
        """
 
        Return a tuple (reviewers, pending reviewers, pull request status)
 
        Only approve and reject counts as valid votes.
 
        """
0 comments (0 inline, 0 general)