← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~stevenk/launchpad/distroseries-edit-datereleased into lp:launchpad

 

Steve Kowalik has proposed merging lp:~stevenk/launchpad/distroseries-edit-datereleased into lp:launchpad.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #876345 in Launchpad itself: "distro series releasedate not automatically set"
  https://bugs.launchpad.net/launchpad/+bug/876345

For more details, see:
https://code.launchpad.net/~stevenk/launchpad/distroseries-edit-datereleased/+merge/81730

Correct rules for setting datereleased of an IDistroSeries when its status is set to CURRENT.

There are two ways to set the status -- IDistroSeries:+edit, and IDistroSeries:+edit. I know for a fact that for Natty and Oneiric that the LOSAs used +edit to change the status, and this is where the problem lies. The bug here is that DistroSeriesEditView uses different rules to determine if it should add the status widget to the view and then if it should set datereleased. If the admin view was used, this bug would have not been caught.
-- 
https://code.launchpad.net/~stevenk/launchpad/distroseries-edit-datereleased/+merge/81730
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~stevenk/launchpad/distroseries-edit-datereleased into lp:launchpad.
=== modified file 'lib/lp/registry/browser/distroseries.py'
--- lib/lp/registry/browser/distroseries.py	2011-10-03 08:26:47 +0000
+++ lib/lp/registry/browser/distroseries.py	2011-11-09 13:03:25 +0000
@@ -590,9 +590,10 @@
         'status' field. See `createStatusField` method.
         """
         LaunchpadEditFormView.setUpFields(self)
-        is_derivitive = not self.context.distribution.full_functionality
-        has_admin = check_permission('launchpad.Admin', self.context)
-        if has_admin or is_derivitive:
+        self.is_derivitive = (
+            not self.context.distribution.full_functionality)
+        self.has_admin = check_permission('launchpad.Admin', self.context)
+        if self.has_admin or self.is_derivitive:
             # The user is an admin or this is an IDerivativeDistribution.
             self.form_fields = (
                 self.form_fields + self.createStatusField())
@@ -600,7 +601,7 @@
     @action("Change")
     def change_action(self, action, data):
         """Update the context and redirects to its overviw page."""
-        if not self.context.distribution.full_functionality:
+        if self.has_admin or self.is_derivitive:
             self.updateDateReleased(data.get('status'))
         self.updateContextFromData(data)
         self.request.response.addInfoNotification(

=== modified file 'lib/lp/registry/browser/tests/test_distroseries.py'
--- lib/lp/registry/browser/tests/test_distroseries.py	2011-10-03 09:26:21 +0000
+++ lib/lp/registry/browser/tests/test_distroseries.py	2011-11-09 13:03:25 +0000
@@ -72,6 +72,8 @@
     DistroSeriesDifferenceStatus,
     DistroSeriesDifferenceType,
     )
+from lp.registry.interfaces.distribution import IDistributionSet
+from lp.registry.interfaces.person import IPersonSet
 from lp.registry.interfaces.pocket import PackagePublishingPocket
 from lp.registry.interfaces.series import SeriesStatus
 from lp.services.features import (
@@ -119,6 +121,7 @@
     EqualsIgnoringWhitespace,
     HasQueryCount,
     )
+from lp.testing.sampledata import ADMIN_EMAIL
 from lp.testing.views import create_initialized_view
 
 
@@ -2717,3 +2720,23 @@
         packageset_text = re.compile('\s*' + ps.name)
         self._test_packagesets(
             html, packageset_text, 'packagesets', 'Packagesets')
+
+
+class TestDistroSeriesEditView(TestCaseWithFactory):
+
+    layer = DatabaseFunctionalLayer
+
+    def test_edit_full_functionality_sets_datereleased(self):
+        # Full functionality distributions (IE: Ubuntu) have datereleased
+        # set when the +edit view is used.
+        ubuntu = getUtility(IDistributionSet).getByName('ubuntu')
+        distroseries = self.factory.makeDistroSeries(distribution=ubuntu)
+        admin = getUtility(IPersonSet).getByEmail(ADMIN_EMAIL)
+        form = {
+            'field.actions.change': 'Change',
+            'field.status': 'CURRENT'
+            }
+        with person_logged_in(admin):
+            create_initialized_view(
+                distroseries, name='+edit', principal=admin, form=form)
+        self.assertIsNot(None, distroseries.datereleased)


Follow ups