def getProposals(self):
     """Get the proposals for the view."""
     collection = IBranchCollection(self.context)
     collection = collection.visibleByUser(self.user)
     proposals = collection.getMergeProposals(
         [BranchMergeProposalStatus.CODE_APPROVED, BranchMergeProposalStatus.NEEDS_REVIEW], eager_load=True
     )
     return proposals
Esempio n. 2
0
 def getProposals(self):
     """Get the proposals for the view."""
     collection = IBranchCollection(self.context)
     collection = collection.visibleByUser(self.user)
     proposals = collection.getMergeProposals([
         BranchMergeProposalStatus.CODE_APPROVED,
         BranchMergeProposalStatus.NEEDS_REVIEW
     ],
                                              eager_load=True)
     return proposals
Esempio n. 3
0
    def getMergeProposals(self, status=None, visible_by_user=None,
                          eager_load=False):
        """See `IHasMergeProposals`."""
        if not status:
            status = (
                BranchMergeProposalStatus.CODE_APPROVED,
                BranchMergeProposalStatus.NEEDS_REVIEW,
                BranchMergeProposalStatus.WORK_IN_PROGRESS)

        collection = IBranchCollection(self).visibleByUser(visible_by_user)
        return collection.getMergeProposals(status, eager_load=eager_load)
Esempio n. 4
0
    def getBranches(self, status=None, visible_by_user=None,
                    modified_since=None, eager_load=False):
        """See `IHasBranches`."""
        if status is None:
            status = DEFAULT_BRANCH_STATUS_IN_LISTING

        collection = IBranchCollection(self).visibleByUser(visible_by_user)
        collection = collection.withLifecycleStatus(*status)
        if modified_since is not None:
            collection = collection.modifiedSince(modified_since)
        return collection.getBranches(eager_load=eager_load)
Esempio n. 5
0
    def getMergeProposals(self,
                          status=None,
                          visible_by_user=None,
                          eager_load=False):
        """See `IHasMergeProposals`."""
        if not status:
            status = (BranchMergeProposalStatus.CODE_APPROVED,
                      BranchMergeProposalStatus.NEEDS_REVIEW,
                      BranchMergeProposalStatus.WORK_IN_PROGRESS)

        collection = IBranchCollection(self).visibleByUser(visible_by_user)
        return collection.getMergeProposals(status, eager_load=eager_load)
Esempio n. 6
0
    def getBranches(self,
                    status=None,
                    visible_by_user=None,
                    modified_since=None,
                    eager_load=False):
        """See `IHasBranches`."""
        if status is None:
            status = DEFAULT_BRANCH_STATUS_IN_LISTING

        collection = IBranchCollection(self).visibleByUser(visible_by_user)
        collection = collection.withLifecycleStatus(*status)
        if modified_since is not None:
            collection = collection.modifiedSince(modified_since)
        return collection.getBranches(eager_load=eager_load)
Esempio n. 7
0
    def test_person_product(self):
        """A PersonProduct can be adapted to a collection.

        The collection will only find branches matching both the person and
        the product.
        """
        product = self.factory.makeProduct()
        person = self.factory.makePerson()
        person_product = PersonProduct(person, product)
        self.factory.makeBranch()
        self.factory.makeProductBranch(product=product)
        self.factory.makeBranch(owner=person)
        person_product_branch = self.factory.makeProductBranch(
            owner=person, product=product)
        branches = IBranchCollection(person_product).getBranches()
        self.assertEqual([person_product_branch], [b for b in branches])
Esempio n. 8
0
 def _collection(self):
     """Return the branch collection for this context."""
     collection = IBranchCollection(self.context).visibleByUser(self.user)
     collection = collection.withLifecycleStatus(
         *DEFAULT_BRANCH_STATUS_IN_LISTING)
     return collection
Esempio n. 9
0
 def _collection(self):
     """Return the branch collection for this context."""
     collection = IBranchCollection(self.context).visibleByUser(self.user)
     collection = collection.withLifecycleStatus(
         *DEFAULT_BRANCH_STATUS_IN_LISTING)
     return collection
Esempio n. 10
0
 def show_bzr_link(self):
     collection = IBranchCollection(self.context)
     return not collection.visibleByUser(self.user).is_empty()