~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/code/browser/branchlisting.py

[rs=buildbot-poller] automatic merge from stable. Revisions: 14253,
        14254, 14255, 14256, 14257, 14258, 14259 included.

Show diffs side-by-side

added added

removed removed

Lines of Context:
613
613
 
614
614
    def hasAnyBranchesVisibleByUser(self):
615
615
        """Does the context have any branches that are visible to the user?"""
616
 
        return self.branch_count > 0
 
616
        return not self.is_branch_count_zero
617
617
 
618
618
    def _getCollection(self):
619
619
        """Override this to say what branches will be in the listing."""
624
624
        """The number of total branches the user can see."""
625
625
        return self._getCollection().visibleByUser(self.user).count()
626
626
 
 
627
    @cachedproperty
 
628
    def is_branch_count_zero(self):
 
629
        """Is the number of total branches the user can see zero?."""
 
630
        # If the batch itself is not empty, we don't need to check
 
631
        # the whole collection count (it might be expensive to compute if the
 
632
        # total number of branches is huge).
 
633
        return (
 
634
            len(self.branches().visible_branches_for_view) == 0 and
 
635
            not self.branch_count)
 
636
 
627
637
    def _branches(self, lifecycle_status):
628
638
        """Return a sequence of branches.
629
639
 
885
895
        """
886
896
        return self.context
887
897
 
888
 
    @cachedproperty
889
 
    def has_branches(self):
890
 
        """Should the template show the summary view with the links."""
891
 
 
892
898
    @property
893
899
    def show_summary(self):
894
900
        """Should the template show the summary view with the links."""
916
922
            not self._getCountCollection().registeredBy(
917
923
                self.person).is_empty())
918
924
 
919
 
    @cachedproperty
920
 
    def active_reviews_not_empty(self):
921
 
        """Return the number of active reviews for self.person's branches."""
922
 
        active_reviews = PersonActiveReviewsView(self.context, self.request)
923
 
        return not active_reviews.getProposals().is_empty()
924
 
 
925
925
    def simplified_owned(self):
926
926
        return Link(
927
927
            canonical_url(self.context, rootsite='code'),
944
944
    def simplified_active_reviews(self):
945
945
        return Link(
946
946
            '+activereviews',
947
 
            'Active reviews',
948
 
            enabled=self.active_reviews_not_empty)
 
947
            'Active reviews')
949
948
 
950
949
    @cachedproperty
951
950
    def registered_branch_count(self):