Merge lp:~rvb/launchpad/initseries-bug-795537 into lp:launchpad

Proposed by Raphaël Badin
Status: Merged
Approved by: Raphaël Badin
Approved revision: no longer in the source branch.
Merged at revision: 13216
Proposed branch: lp:~rvb/launchpad/initseries-bug-795537
Merge into: lp:launchpad
Diff against target: 128 lines (+89/-0)
3 files modified
lib/lp/registry/browser/distroseries.py (+10/-0)
lib/lp/registry/browser/tests/test_distroseries.py (+76/-0)
lib/lp/registry/templates/distroseries-index.pt (+3/-0)
To merge this branch: bzr merge lp:~rvb/launchpad/initseries-bug-795537
Reviewer Review Type Date Requested Status
Benji York (community) code Approve
Review via email: mp+64231@code.launchpad.net

Commit message

[r=benji][bug=795537] Add the link +initseries to a distroseries' index page.

Description of the change

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.

To post a comment you must log in.
Revision history for this message
Benji York (benji) wrote :

This looks good.

review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== 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-13 09:27:22 +0000
@@ -218,6 +218,7 @@
218 'queue',218 'queue',
219 'add_port',219 'add_port',
220 'create_milestone',220 'create_milestone',
221 'initseries',
221 ]222 ]
222 add_subscribe_link(links)223 add_subscribe_link(links)
223 links.append('admin')224 links.append('admin')
@@ -275,6 +276,15 @@
275 text = 'Show uploads'276 text = 'Show uploads'
276 return Link('+queue', text, icon='info')277 return Link('+queue', text, icon='info')
277278
279 @enabled_with_permission('launchpad.Admin')
280 def initseries(self):
281 enabled = (
282 getFeatureFlag('soyuz.derived_series_ui.enabled') is not None and
283 not self.context.isInitializing() and
284 not self.context.isInitialized())
285 text = 'Initialize series'
286 return Link('+initseries', text, icon='edit', enabled=enabled)
287
278288
279class DistroSeriesBugsMenu(ApplicationMenu, StructuralSubscriptionMenuMixin):289class DistroSeriesBugsMenu(ApplicationMenu, StructuralSubscriptionMenuMixin):
280290
281291
=== 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-13 09:27:22 +0000
@@ -328,6 +328,82 @@
328 self.assertTrue(derived_series.isInitializing())328 self.assertTrue(derived_series.isInitializing())
329 self.assertThat(html_content, portlet_display)329 self.assertThat(html_content, portlet_display)
330330
331 def assertInitSeriesLinkPresent(self, series, person):
332 self._assertInitSeriesLink(series, person, True)
333
334 def assertInitSeriesLinkNotPresent(self, series, person):
335 self._assertInitSeriesLink(series, person, False)
336
337 def _assertInitSeriesLink(self, series, person, present=True):
338 # Helper method to check the presence/absence of the link to
339 # +iniseries.
340 if person == 'admin':
341 person = getUtility(ILaunchpadCelebrities).admin.teamowner
342
343 init_link_matcher = soupmatchers.HTMLContains(
344 soupmatchers.Tag(
345 'Initialize series', 'a',
346 text='Initialize series',
347 attrs={'href': '%s/+initseries' % canonical_url(series)}))
348
349 with person_logged_in(person):
350 view = create_initialized_view(
351 series,
352 '+index',
353 principal=person)
354 html_content = view()
355
356 if present:
357 self.assertThat(html_content, init_link_matcher)
358 else:
359 self.assertThat(html_content, Not(init_link_matcher))
360
361 def test_differences_init_link_no_feature(self):
362 # The link to +initseries is not displayed if the feature flag
363 # is not enabled.
364 series = self.factory.makeDistroSeries()
365
366 self.assertInitSeriesLinkNotPresent(series, 'admin')
367
368 def test_differences_init_link_admin(self):
369 # The link to +initseries is displayed to admin users if the
370 # feature flag is enabled.
371 set_derived_series_ui_feature_flag(self)
372 series = self.factory.makeDistroSeries()
373
374 self.assertInitSeriesLinkPresent(series, 'admin')
375
376 def test_differences_init_link_not_admin(self):
377 # The link to +initseries is not displayed to not admin users if the
378 # feature flag is enabled.
379 set_derived_series_ui_feature_flag(self)
380 series = self.factory.makeDistroSeries()
381 person = self.factory.makePerson()
382
383 self.assertInitSeriesLinkNotPresent(series, person)
384
385 def test_differences_init_link_initialized(self):
386 # The link to +initseries is not displayed if the series is
387 # already initialized (i.e. has any published package).
388 set_derived_series_ui_feature_flag(self)
389 series = self.factory.makeDistroSeries()
390 self.factory.makeSourcePackagePublishingHistory(
391 archive=series.main_archive,
392 distroseries=series)
393
394 self.assertInitSeriesLinkNotPresent(series, 'admin')
395
396 def test_differences_init_link_series_initializing(self):
397 # The link to +initseries is not displayed if the series is
398 # initializing.
399 set_derived_series_ui_feature_flag(self)
400 series = self.factory.makeDistroSeries()
401 parent_series = self.factory.makeDistroSeries()
402 job_source = getUtility(IInitialiseDistroSeriesJobSource)
403 job_source.create(series, [parent_series.id])
404
405 self.assertInitSeriesLinkNotPresent(series, 'admin')
406
331407
332class TestMilestoneBatchNavigatorAttribute(TestCaseWithFactory):408class TestMilestoneBatchNavigatorAttribute(TestCaseWithFactory):
333 """Test the series.milestone_batch_navigator attribute."""409 """Test the series.milestone_batch_navigator attribute."""
334410
=== 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-13 09:27:22 +0000
@@ -147,6 +147,9 @@
147 <li tal:condition="overview_menu/admin/enabled">147 <li tal:condition="overview_menu/admin/enabled">
148 <a tal:replace="structure overview_menu/admin/fmt:link" />148 <a tal:replace="structure overview_menu/admin/fmt:link" />
149 </li>149 </li>
150 <li tal:condition="overview_menu/initseries/enabled|nothing">
151 <a tal:replace="structure overview_menu/initseries/fmt:link" />
152 </li>
150 <li tal:condition="overview_menu/subscribe/enabled|nothing">153 <li tal:condition="overview_menu/subscribe/enabled|nothing">
151 <a tal:replace="structure overview_menu/subscribe/fmt:link" />154 <a tal:replace="structure overview_menu/subscribe/fmt:link" />
152 </li>155 </li>