launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #03911
[Merge] lp:~rvb/launchpad/initseries-bug-795537 into lp:launchpad
Raphaël Victor Badin has proposed merging lp:~rvb/launchpad/initseries-bug-795537 into lp:launchpad.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
Related bugs:
Bug #795537 in Launchpad itself: "A series homepage should have a link to +initseries."
https://bugs.launchpad.net/launchpad/+bug/795537
For more details, see:
https://code.launchpad.net/~rvb/launchpad/initseries-bug-795537/+merge/64231
This branch adds the link +initseries to the home page of a distroseries.
This link is only displayed:
- if the feature flag (soyuz.derived_series_ui.enabled) is enabled;
- to users with lp.Admin;
- if the series is not already initialized or currently initializing.
= Tests =
./bin/test -cvv test_distroseries test_differences_init_link_no_feature
./bin/test -cvv test_distroseries test_differences_init_link_admin
./bin/test -cvv test_distroseries test_differences_init_link_not_admin
./bin/test -cvv test_distroseries test_differences_init_link_initialized
./bin/test -cvv test_distroseries test_differences_init_link_series_initializing
= Q/A =
On DF:
- as admin: make sure that the link is present on a series homepage.
- as non admin: make sure that the link is not present on a series homepage.
- as admin: the link should not be present for a series already initialized, or a series initializing.
--
https://code.launchpad.net/~rvb/launchpad/initseries-bug-795537/+merge/64231
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~rvb/launchpad/initseries-bug-795537 into lp:launchpad.
=== modified file 'lib/lp/registry/browser/distroseries.py'
--- lib/lp/registry/browser/distroseries.py 2011-06-09 13:11:57 +0000
+++ lib/lp/registry/browser/distroseries.py 2011-06-10 18:09:50 +0000
@@ -220,6 +220,8 @@
'create_milestone',
]
add_subscribe_link(links)
+ if getFeatureFlag('soyuz.derived_series_ui.enabled') is not None:
+ links.append('initseries')
links.append('admin')
return links
@@ -275,6 +277,13 @@
text = 'Show uploads'
return Link('+queue', text, icon='info')
+ @enabled_with_permission('launchpad.Admin')
+ def initseries(self):
+ enabled = (not self.context.is_initialising and
+ not self.context.is_derived_series)
+ text = 'Initialize series'
+ return Link('+initseries', text, icon='edit', enabled=enabled)
+
class DistroSeriesBugsMenu(ApplicationMenu, StructuralSubscriptionMenuMixin):
=== modified file 'lib/lp/registry/browser/tests/test_distroseries.py'
--- lib/lp/registry/browser/tests/test_distroseries.py 2011-06-09 13:11:57 +0000
+++ lib/lp/registry/browser/tests/test_distroseries.py 2011-06-10 18:09:50 +0000
@@ -328,6 +328,80 @@
self.assertTrue(derived_series.isInitializing())
self.assertThat(html_content, portlet_display)
+ def assertInitSeriesLinkPresent(self, series, person):
+ self._assertInitSeriesLink(series, person, True)
+
+ def assertInitSeriesLinkNotPresent(self, series, person):
+ self._assertInitSeriesLink(series, person, False)
+
+ def _assertInitSeriesLink(self, series, person, present=True):
+ # Helper method to check the presence/absence of the link to
+ # +iniseries.
+ if person == 'admin':
+ person = getUtility(ILaunchpadCelebrities).admin.teamowner
+
+ init_link_matcher = soupmatchers.HTMLContains(
+ soupmatchers.Tag(
+ 'Initialize series', 'a',
+ text='Initialize series',
+ attrs={'href': '%s/+initseries' %canonical_url(series)}))
+
+ with person_logged_in(person):
+ view = create_initialized_view(
+ series,
+ '+index',
+ principal=person)
+ html_content = view()
+
+ if present:
+ self.assertThat(html_content, init_link_matcher)
+ else:
+ self.assertThat(html_content, Not(init_link_matcher))
+
+ def test_differences_init_link_no_feature(self):
+ # The link to +initseries is not displayed if the feature flag
+ # is not enabled.
+ series = self.factory.makeDistroSeries()
+
+ self.assertInitSeriesLinkNotPresent(series, 'admin')
+
+ def test_differences_init_link_admin(self):
+ # The link to +initseries is displayed to admin users if the
+ # feature flag is enabled.
+ set_derived_series_ui_feature_flag(self)
+ series = self.factory.makeDistroSeries()
+
+ self.assertInitSeriesLinkPresent(series, 'admin')
+
+ def test_differences_init_link_not_admin(self):
+ # The link to +initseries is not displayed to not admin users if the
+ # feature flag is enabled.
+ set_derived_series_ui_feature_flag(self)
+ series = self.factory.makeDistroSeries()
+ person = self.factory.makePerson()
+
+ self.assertInitSeriesLinkNotPresent(series, person)
+
+ def test_differences_init_link_initialized(self):
+ # The link to +initseries is not displayed if the series is
+ # already initialized.
+ set_derived_series_ui_feature_flag(self)
+ series = self.factory.makeDistroSeries()
+ self.factory.makeDistroSeriesParent(derived_series=series)
+
+ self.assertInitSeriesLinkNotPresent(series, 'admin')
+
+ def test_differences_init_link_series_initializing(self):
+ # The link to +initseries is not displayed if the series is
+ # initializing.
+ set_derived_series_ui_feature_flag(self)
+ series = self.factory.makeDistroSeries()
+ parent_series = self.factory.makeDistroSeries()
+ job_source = getUtility(IInitialiseDistroSeriesJobSource)
+ job_source.create(series, [parent_series.id])
+
+ self.assertInitSeriesLinkNotPresent(series, 'admin')
+
class TestMilestoneBatchNavigatorAttribute(TestCaseWithFactory):
"""Test the series.milestone_batch_navigator attribute."""
=== modified file 'lib/lp/registry/templates/distroseries-index.pt'
--- lib/lp/registry/templates/distroseries-index.pt 2011-06-09 12:00:48 +0000
+++ lib/lp/registry/templates/distroseries-index.pt 2011-06-10 18:09:50 +0000
@@ -147,6 +147,9 @@
<li tal:condition="overview_menu/admin/enabled">
<a tal:replace="structure overview_menu/admin/fmt:link" />
</li>
+ <li tal:condition="overview_menu/initseries/enabled|nothing">
+ <a tal:replace="structure overview_menu/initseries/fmt:link" />
+ </li>
<li tal:condition="overview_menu/subscribe/enabled|nothing">
<a tal:replace="structure overview_menu/subscribe/fmt:link" />
</li>