← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~wgrant/launchpad/product-branch-reviews-rename into lp:launchpad

 

William Grant has proposed merging lp:~wgrant/launchpad/product-branch-reviews-rename into lp:launchpad.

Commit message:
Rename Bazaar-specific Product views to use "branch" rather than "code".

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~wgrant/launchpad/product-branch-reviews-rename/+merge/260699

Rename various product branch-related views to say "branch" rather than "code", leaving room for ProductGitView and a ProductCodeView which shows the primary VCS.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~wgrant/launchpad/product-branch-reviews-rename into lp:launchpad.
=== modified file 'lib/lp/code/browser/branchlisting.py'
--- lib/lp/code/browser/branchlisting.py	2015-05-01 13:20:17 +0000
+++ lib/lp/code/browser/branchlisting.py	2015-06-01 10:32:04 +0000
@@ -16,10 +16,10 @@
     'PersonBranchesView',
     'PersonCodeSummaryView',
     'PersonTeamBranchesView',
+    'ProductAllBranchesView',
     'ProductBranchListingView',
     'ProductBranchesMenu',
     'ProductBranchesView',
-    'ProductCodeIndexView',
     'ProjectBranchesView',
     'RecentlyChangedBranchesView',
     'RecentlyImportedBranchesView',
@@ -1157,11 +1157,8 @@
         return text.capitalize()
 
 
-class ProductCodeIndexView(ProductBranchListingView, SortSeriesMixin,
-                           ProductDownloadFileMixin, BranchMirrorMixin):
-    """Initial view for products on the code virtual host."""
-
-    show_set_development_focus = True
+class ProductBranchSummaryView(ProductBranchListingView, SortSeriesMixin,
+                               ProductDownloadFileMixin, BranchMirrorMixin):
 
     def initialize(self):
         ProductBranchListingView.initialize(self)
@@ -1172,17 +1169,6 @@
     def branch(self):
         return self.development_focus_branch
 
-    @property
-    def form_action(self):
-        return "+all-branches"
-
-    @property
-    def initial_values(self):
-        return {
-            'lifecycle': BranchLifecycleStatusFilter.CURRENT,
-            'sort_by': BranchListingSort.DEFAULT,
-            }
-
     @cachedproperty
     def commit_count(self):
         """The number of new revisions in the last 30 days."""
@@ -1213,6 +1199,56 @@
         return len([person for person in self._branch_owners
                     if person.is_team])
 
+    @property
+    def has_development_focus_branch(self):
+        """Is there a branch assigned as development focus?"""
+        return self.development_focus_branch is not None
+
+    @property
+    def branch_text(self):
+        return get_plural_text(self.branch_count, _('branch'), _('branches'))
+
+    @property
+    def person_text(self):
+        return get_plural_text(
+            self.person_owner_count, _('person'), _('people'))
+
+    @property
+    def team_text(self):
+        return get_plural_text(self.team_owner_count, _('team'), _('teams'))
+
+    @property
+    def commit_text(self):
+        return get_plural_text(self.commit_count, _('commit'), _('commits'))
+
+    @property
+    def committer_text(self):
+        return get_plural_text(self.committer_count, _('person'), _('people'))
+
+    @property
+    def external_visible(self):
+        return (
+            self.context.codehosting_usage == ServiceUsage.EXTERNAL
+            and self.branch)
+
+
+class ProductBranchesView(ProductBranchListingView, SortSeriesMixin,
+                          ProductDownloadFileMixin, BranchMirrorMixin):
+    """Initial view for products on the code virtual host."""
+
+    show_set_development_focus = True
+
+    @property
+    def form_action(self):
+        return "+all-branches"
+
+    @property
+    def initial_values(self):
+        return {
+            'lifecycle': BranchLifecycleStatusFilter.CURRENT,
+            'sort_by': BranchListingSort.DEFAULT,
+            }
+
     def _getSeriesBranches(self):
         """Get the series branches for the product, dev focus first."""
         # We want to show each series branch only once, always show the
@@ -1248,7 +1284,7 @@
     def initial_branches(self):
         """Return the series branches, followed by most recently changed."""
         series_branches = self._getSeriesBranches()
-        branch_query = super(ProductCodeIndexView, self)._branches(
+        branch_query = super(ProductBranchesView, self)._branches(
             self.selected_lifecycle_status)
         branch_query.order_by(self._listingSortToOrderBy(
             BranchListingSort.MOST_RECENTLY_CHANGED_FIRST))
@@ -1269,11 +1305,6 @@
         # The params are ignored, and only used by the listing view.
         return self.initial_branches
 
-    @property
-    def unseen_branch_count(self):
-        """How many branches are not shown."""
-        return self.branch_count - len(self.initial_branches)
-
     def hasAnyBranchesVisibleByUser(self):
         """See `BranchListingView`."""
         return self.branch_count > 0
@@ -1284,27 +1315,6 @@
         return self.development_focus_branch is not None
 
     @property
-    def branch_text(self):
-        return get_plural_text(self.branch_count, _('branch'), _('branches'))
-
-    @property
-    def person_text(self):
-        return get_plural_text(
-            self.person_owner_count, _('person'), _('people'))
-
-    @property
-    def team_text(self):
-        return get_plural_text(self.team_owner_count, _('team'), _('teams'))
-
-    @property
-    def commit_text(self):
-        return get_plural_text(self.commit_count, _('commit'), _('commits'))
-
-    @property
-    def committer_text(self):
-        return get_plural_text(self.committer_count, _('person'), _('people'))
-
-    @property
     def configure_codehosting(self):
         """Get the menu link for configuring code hosting."""
         if not check_permission(
@@ -1315,14 +1325,8 @@
         set_branch.text = 'Configure code hosting'
         return set_branch
 
-    @property
-    def external_visible(self):
-        return (
-            self.context.codehosting_usage == ServiceUsage.EXTERNAL
-            and self.branch)
-
-
-class ProductBranchesView(ProductBranchListingView):
+
+class ProductAllBranchesView(ProductBranchListingView):
     """View for branch listing for a product."""
 
     def initialize(self):

=== modified file 'lib/lp/code/browser/configure.zcml'
--- lib/lp/code/browser/configure.zcml	2015-05-26 07:39:49 +0000
+++ lib/lp/code/browser/configure.zcml	2015-06-01 10:32:04 +0000
@@ -712,25 +712,25 @@
 
     <browser:page
         for="lp.registry.interfaces.product.IProduct"
+        class="lp.code.browser.branchlisting.ProductAllBranchesView"
+        permission="zope.Public"
+        name="+all-branches"
+        template="../templates/product-branches.pt"/>
+    <browser:page
+        for="lp.registry.interfaces.product.IProduct"
         class="lp.code.browser.branchlisting.ProductBranchesView"
         permission="zope.Public"
-        name="+all-branches"
-        template="../templates/product-branches.pt"/>
-    <browser:page
-        for="lp.registry.interfaces.product.IProduct"
-        class="lp.code.browser.branchlisting.ProductCodeIndexView"
-        permission="zope.Public"
         name="+branches"
         template="../templates/product-branches.pt"/>
    <browser:page
       for="lp.registry.interfaces.product.IProduct"
       class="lp.code.browser.branchlisting.ProductBranchStatisticsView"
       permission="zope.Public"
-      name="+portlet-product-codestatistics"
-      template="../templates/product-portlet-codestatistics.pt"/>
+      name="+portlet-product-branchstatistics"
+      template="../templates/product-portlet-branchstatistics.pt"/>
     <browser:page
         for="lp.registry.interfaces.product.IProduct"
-        class="lp.code.browser.branchlisting.ProductCodeIndexView"
+        class="lp.code.browser.branchlisting.ProductBranchSummaryView"
         permission="zope.Public"
         name="+branch-summary"
         template="../templates/product-branch-summary.pt"/>

=== modified file 'lib/lp/code/browser/tests/test_product.py'
--- lib/lp/code/browser/tests/test_product.py	2015-05-14 13:57:51 +0000
+++ lib/lp/code/browser/tests/test_product.py	2015-06-01 10:32:04 +0000
@@ -61,7 +61,7 @@
         return product, branch
 
 
-class TestProductCodeIndexView(ProductTestBase):
+class TestProductBranchesView(ProductTestBase):
     """Tests for the product code home page."""
 
     def getBranchSummaryBrowseLinkForProduct(self, product):
@@ -125,68 +125,6 @@
             product, '+branches', rootsite='code')
         self.assertNotIn(branch, view.initial_branches)
 
-    def test_committer_count_with_revision_authors(self):
-        # Test that the code pathing for calling committer_count with
-        # valid revision authors is truly tested.
-        self.factory.makePerson(email='cthulu@xxxxxxxxxxx')
-        product, branch = self.makeProductAndDevelopmentFocusBranch()
-        date_generator = time_counter(
-            datetime.now(pytz.UTC) - timedelta(days=30),
-            timedelta(days=1))
-        self.factory.makeRevisionsForBranch(
-            branch, author='cthulu@xxxxxxxxxxx',
-            date_generator=date_generator)
-        getUtility(IRevisionSet).updateRevisionCacheForBranch(branch)
-
-        view = create_initialized_view(product, '+branches', rootsite='code')
-        self.assertEqual(view.committer_count, 1)
-
-    def test_committers_count_private_branch(self):
-        # Test that calling committer_count will return the proper value
-        # for a private branch.
-        fsm = self.factory.makePerson(email='flyingpasta@xxxxxxxxxxx')
-        product, branch = self.makeProductAndDevelopmentFocusBranch(
-            owner=fsm, information_type=InformationType.USERDATA)
-        date_generator = time_counter(
-            datetime.now(pytz.UTC) - timedelta(days=30),
-            timedelta(days=1))
-        login_person(fsm)
-        self.factory.makeRevisionsForBranch(
-            branch, author='flyingpasta@xxxxxxxxxxx',
-            date_generator=date_generator)
-        getUtility(IRevisionSet).updateRevisionCacheForBranch(branch)
-
-        view = create_initialized_view(product, '+branches',
-                                       rootsite='code', principal=fsm)
-        self.assertEqual(view.committer_count, 1)
-
-        commit_section = find_tag_by_id(view.render(), 'commits')
-        self.assertIsNot(None, commit_section)
-
-    def test_committers_count_private_branch_non_subscriber(self):
-        # Test that calling committer_count will return the proper value
-        # for a private branch.
-        fsm = self.factory.makePerson(email='flyingpasta@xxxxxxxxxxx')
-        product, branch = self.makeProductAndDevelopmentFocusBranch(
-            owner=fsm, information_type=InformationType.USERDATA)
-        date_generator = time_counter(
-            datetime.now(pytz.UTC) - timedelta(days=30),
-            timedelta(days=1))
-        login_person(fsm)
-        self.factory.makeRevisionsForBranch(
-            branch, author='flyingpasta@xxxxxxxxxxx',
-            date_generator=date_generator)
-        getUtility(IRevisionSet).updateRevisionCacheForBranch(branch)
-
-        observer = self.factory.makePerson()
-        login_person(observer)
-        view = create_initialized_view(product, '+branches',
-                                       rootsite='code', principal=observer)
-        self.assertEqual(view.branch_count, 0)
-        self.assertEqual(view.committer_count, 1)
-        commit_section = find_tag_by_id(view.render(), 'commits')
-        self.assertIs(None, commit_section)
-
     def test_initial_branches_contains_push_instructions(self):
         product, branch = self.makeProductAndDevelopmentFocusBranch()
         view = create_initialized_view(
@@ -241,7 +179,7 @@
         self.assertIn('another-branch', content)
 
 
-class TestProductCodeIndexServiceUsages(ProductTestBase, BrowserTestCase):
+class TestProductBranchesServiceUsages(ProductTestBase, BrowserTestCase):
     """Tests for the product code page, especially the usage messasges."""
 
     def test_external_imported(self):
@@ -349,10 +287,84 @@
         url = "http://example.com/mybranch";
         product, branch = self.makeProductAndDevelopmentFocusBranch(
             branch_type=BranchType.MIRRORED, url=url)
-        view = create_initialized_view(product, '+branches', rootsite='code')
+        view = create_initialized_view(
+            product, '+branch-summary', rootsite='code')
         self.assertEqual(url, view.mirror_location)
 
 
+class TestProductBranchSummaryView(ProductTestBase):
+
+    def test_committer_count_with_revision_authors(self):
+        # Test that the code pathing for calling committer_count with
+        # valid revision authors is truly tested.
+        self.factory.makePerson(email='cthulu@xxxxxxxxxxx')
+        product, branch = self.makeProductAndDevelopmentFocusBranch()
+        date_generator = time_counter(
+            datetime.now(pytz.UTC) - timedelta(days=30),
+            timedelta(days=1))
+        self.factory.makeRevisionsForBranch(
+            branch, author='cthulu@xxxxxxxxxxx',
+            date_generator=date_generator)
+        getUtility(IRevisionSet).updateRevisionCacheForBranch(branch)
+
+        view = create_initialized_view(
+            product, '+branch-summary', rootsite='code')
+        self.assertEqual(view.committer_count, 1)
+
+    def test_committers_count_private_branch(self):
+        # Test that calling committer_count will return the proper value
+        # for a private branch.
+        fsm = self.factory.makePerson(email='flyingpasta@xxxxxxxxxxx')
+        product, branch = self.makeProductAndDevelopmentFocusBranch(
+            owner=fsm, information_type=InformationType.USERDATA)
+        date_generator = time_counter(
+            datetime.now(pytz.UTC) - timedelta(days=30),
+            timedelta(days=1))
+        login_person(fsm)
+        self.factory.makeRevisionsForBranch(
+            branch, author='flyingpasta@xxxxxxxxxxx',
+            date_generator=date_generator)
+        getUtility(IRevisionSet).updateRevisionCacheForBranch(branch)
+
+        view = create_initialized_view(product, '+branch-summary',
+                                       rootsite='code', principal=fsm)
+        self.assertEqual(view.committer_count, 1)
+
+        view = create_initialized_view(
+            product, '+portlet-product-branchstatistics', rootsite='code',
+            principal=fsm)
+        commit_section = find_tag_by_id(view.render(), 'commits')
+        self.assertIsNot(None, commit_section)
+
+    def test_committers_count_private_branch_non_subscriber(self):
+        # Test that calling committer_count will return the proper value
+        # for a private branch.
+        fsm = self.factory.makePerson(email='flyingpasta@xxxxxxxxxxx')
+        product, branch = self.makeProductAndDevelopmentFocusBranch(
+            owner=fsm, information_type=InformationType.USERDATA)
+        date_generator = time_counter(
+            datetime.now(pytz.UTC) - timedelta(days=30),
+            timedelta(days=1))
+        login_person(fsm)
+        self.factory.makeRevisionsForBranch(
+            branch, author='flyingpasta@xxxxxxxxxxx',
+            date_generator=date_generator)
+        getUtility(IRevisionSet).updateRevisionCacheForBranch(branch)
+
+        observer = self.factory.makePerson()
+        login_person(observer)
+        view = create_initialized_view(product, '+branch-summary',
+                                       rootsite='code', principal=observer)
+        self.assertEqual(view.branch_count, 0)
+        self.assertEqual(view.committer_count, 1)
+
+        view = create_initialized_view(
+            product, '+portlet-product-branchstatistics', rootsite='code',
+            principal=observer)
+        commit_section = find_tag_by_id(view.render(), 'commits')
+        self.assertIs(None, commit_section)
+
+
 class TestProductBranchesViewPortlets(ProductTestBase, BrowserTestCase):
     """Tests for the portlets."""
 
@@ -366,7 +378,7 @@
         self.assertIs(None, find_tag_by_id(contents, 'privacy'))
         self.assertIs(None, find_tag_by_id(contents, 'involvement'))
         self.assertIs(None, find_tag_by_id(
-            contents, 'portlet-product-codestatistics'))
+            contents, 'portlet-product-branchstatistics'))
 
     def test_portlets_shown_for_HOSTED(self):
         # If the BranchUsage is HOSTED then the portlets are shown.
@@ -378,7 +390,7 @@
         self.assertIsNot(None, find_tag_by_id(contents, 'privacy'))
         self.assertIsNot(None, find_tag_by_id(contents, 'involvement'))
         self.assertIsNot(None, find_tag_by_id(
-            contents, 'portlet-product-codestatistics'))
+            contents, 'portlet-product-branchstatistics'))
 
     def test_portlets_shown_for_EXTERNAL(self):
         # If the BranchUsage is EXTERNAL then the portlets are shown.
@@ -391,7 +403,7 @@
         self.assertIsNot(None, find_tag_by_id(contents, 'privacy'))
         self.assertIsNot(None, find_tag_by_id(contents, 'involvement'))
         self.assertIsNot(None, find_tag_by_id(
-            contents, 'portlet-product-codestatistics'))
+            contents, 'portlet-product-branchstatistics'))
 
     def test_is_private(self):
         product = self.factory.makeProduct(

=== modified file 'lib/lp/code/stories/branches/xx-product-branches.txt'
--- lib/lp/code/stories/branches/xx-product-branches.txt	2014-02-25 06:38:58 +0000
+++ lib/lp/code/stories/branches/xx-product-branches.txt	2015-06-01 10:32:04 +0000
@@ -254,7 +254,7 @@
     >>> def get_stats_portlet(browser):
     ...     return find_tag_by_id(
     ...         browser.contents,
-    ...         'portlet-product-codestatistics')
+    ...         'portlet-product-branchstatistics')
     >>> def print_portlet(product):
     ...     browser.open('http://code.launchpad.dev/%s' % product)
     ...     portlet = get_stats_portlet(browser)

=== modified file 'lib/lp/code/templates/product-branches.pt'
--- lib/lp/code/templates/product-branches.pt	2015-05-01 13:18:54 +0000
+++ lib/lp/code/templates/product-branches.pt	2015-06-01 10:32:04 +0000
@@ -58,7 +58,7 @@
 
     <tal:code-statistics
       condition="not: view/context/codehosting_usage/enumvalue:UNKNOWN"
-      replace="structure context/@@+portlet-product-codestatistics" />
+      replace="structure context/@@+portlet-product-branchstatistics" />
 
     <tal:has-default-git-repository condition="view/has_default_git_repository">
       <div id="default-repository-branches" class="portlet"

=== renamed file 'lib/lp/code/templates/product-portlet-codestatistics.pt' => 'lib/lp/code/templates/product-portlet-branchstatistics.pt'
--- lib/lp/code/templates/product-portlet-codestatistics.pt	2011-09-16 14:18:11 +0000
+++ lib/lp/code/templates/product-portlet-branchstatistics.pt	2015-06-01 10:32:04 +0000
@@ -2,7 +2,7 @@
   xmlns:tal="http://xml.zope.org/namespaces/tal";
   xmlns:metal="http://xml.zope.org/namespaces/metal";
   xmlns:i18n="http://xml.zope.org/namespaces/i18n";
-  id="portlet-product-codestatistics">
+  id="portlet-product-branchstatistics">
 
     <p id="active-review-count"
        tal:define="count context/menu:branches/active_review_count;


Follow ups