← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~wgrant/launchpad/non-ubuntu-ppas-ui into lp:launchpad

 

William Grant has proposed merging lp:~wgrant/launchpad/non-ubuntu-ppas-ui into lp:launchpad.

Commit message:
Basic UI for setting Distribution.{official_packages,supports_ppas,supports_mirrors} and DistroSeries.inherit_overrides_from_parents.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #879048 in Launchpad itself: "PPAs should be able to build against derived distros"
  https://bugs.launchpad.net/launchpad/+bug/879048

For more details, see:
https://code.launchpad.net/~wgrant/launchpad/non-ubuntu-ppas-ui/+merge/229176

Basic UI for setting Distribution.{official_packages,supports_ppas,supports_mirrors} and DistroSeries.inherit_overrides_from_parents.
-- 
https://code.launchpad.net/~wgrant/launchpad/non-ubuntu-ppas-ui/+merge/229176
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~wgrant/launchpad/non-ubuntu-ppas-ui into lp:launchpad.
=== modified file 'lib/lp/registry/browser/configure.zcml'
--- lib/lp/registry/browser/configure.zcml	2014-07-07 03:57:09 +0000
+++ lib/lp/registry/browser/configure.zcml	2014-08-01 08:48:21 +0000
@@ -1,4 +1,4 @@
-<!-- Copyright 2009-2013 Canonical Ltd.  This software is licensed under the
+<!-- Copyright 2009-2014 Canonical Ltd.  This software is licensed under the
      GNU Affero General Public License version 3 (see the file LICENSE).
 -->
 
@@ -1884,6 +1884,12 @@
         name="+edit"
         template="../../app/templates/generic-edit.pt"/>
     <browser:page
+        for="lp.registry.interfaces.distribution.IDistribution"
+        permission="launchpad.Admin"
+        class="lp.registry.browser.distribution.DistributionAdminView"
+        name="+admin"
+        template="../../app/templates/generic-edit.pt"/>
+    <browser:page
         name="+selectmemberteam"
         for="lp.registry.interfaces.distribution.IDistribution"
         class="lp.registry.browser.distribution.DistributionChangeMembersView"

=== modified file 'lib/lp/registry/browser/distribution.py'
--- lib/lp/registry/browser/distribution.py	2014-07-07 03:57:09 +0000
+++ lib/lp/registry/browser/distribution.py	2014-08-01 08:48:21 +0000
@@ -1,4 +1,4 @@
-# Copyright 2009-2013 Canonical Ltd.  This software is licensed under the
+# Copyright 2009-2014 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 """Browser views for distributions."""
@@ -7,6 +7,7 @@
 
 __all__ = [
     'DistributionAddView',
+    'DistributionAdminView',
     'DistributionArchiveMirrorsRSSView',
     'DistributionArchiveMirrorsView',
     'DistributionArchivesView',
@@ -55,6 +56,7 @@
 from lp.app.browser.launchpadform import (
     action,
     custom_widget,
+    LaunchpadEditFormView,
     LaunchpadFormView,
     )
 from lp.app.browser.lazrjs import InlinePersonEditPickerWidget
@@ -286,6 +288,11 @@
     facet = 'overview'
 
     @enabled_with_permission("launchpad.Admin")
+    def admin(self):
+        text = "Administer"
+        return Link("+admin", text, icon="edit")
+
+    @enabled_with_permission("launchpad.Admin")
     def pubconf(self):
         text = "Configure publisher"
         return Link("+pubconf", text, icon="edit")
@@ -296,8 +303,9 @@
 
     @cachedproperty
     def links(self):
-        return ['edit', 'pubconf', 'subscribe_to_bug_mail',
-                 'edit_bug_mail', 'sharing']
+        return [
+            'edit', 'admin', 'pubconf', 'subscribe_to_bug_mail',
+            'edit_bug_mail', 'sharing']
 
 
 class DistributionOverviewMenu(ApplicationMenu, DistributionLinksMixin):
@@ -960,6 +968,30 @@
         self.updateContextFromData(data)
 
 
+class DistributionAdminView(LaunchpadEditFormView):
+
+    schema = IDistribution
+    field_names = [
+        'official_packages',
+        'supports_ppas',
+        'supports_mirrors',
+        ]
+
+    @property
+    def label(self):
+        """See `LaunchpadFormView`."""
+        return 'Administer %s' % self.context.displayname
+
+    @property
+    def cancel_url(self):
+        return canonical_url(self.context)
+
+    @action("Change", name='change')
+    def change_action(self, action, data):
+        self.updateContextFromData(data)
+        self.next_url = canonical_url(self.context)
+
+
 class DistributionSeriesBaseView(LaunchpadView):
     """A base view to list distroseries."""
     @cachedproperty

=== modified file 'lib/lp/registry/browser/distroseries.py'
--- lib/lp/registry/browser/distroseries.py	2014-07-07 03:32:50 +0000
+++ lib/lp/registry/browser/distroseries.py	2014-08-01 08:48:21 +0000
@@ -619,7 +619,8 @@
     It redirects to the main distroseries page after a successful edit.
     """
     schema = IDistroSeries
-    field_names = ['name', 'version', 'changeslist']
+    field_names = [
+        'name', 'version', 'changeslist', 'inherit_overrides_from_parents']
     custom_widget('status', LaunchpadDropdownWidget)
 
     @property

=== modified file 'lib/lp/registry/browser/tests/test_distribution_views.py'
--- lib/lp/registry/browser/tests/test_distribution_views.py	2013-09-12 05:19:43 +0000
+++ lib/lp/registry/browser/tests/test_distribution_views.py	2014-08-01 08:48:21 +0000
@@ -1,9 +1,10 @@
-# Copyright 2009-2011 Canonical Ltd.  This software is licensed under the
+# Copyright 2009-2014 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 __metaclass__ = type
 
 import soupmatchers
+from testtools.matchers import MatchesStructure
 from zope.component import getUtility
 
 from lp.archivepublisher.interfaces.publisherconfig import IPublisherConfigSet
@@ -261,6 +262,38 @@
         self.assertEqual(self.distribution.package_derivatives_email, email)
 
 
+class TestDistributionAdminView(TestCaseWithFactory):
+    """Test the +admin page for a distribution."""
+
+    layer = DatabaseFunctionalLayer
+
+    def test_admin(self):
+        distribution = self.factory.makeDistribution()
+        admin = login_celebrity('admin')
+        create_initialized_view(
+            distribution, '+admin', principal=admin,
+            form={
+                'field.official_packages': 'on', 'field.supports_ppas': 'on',
+                'field.supports_mirrors': 'on',
+                'field.actions.change': 'change'})
+        self.assertThat(
+            distribution,
+            MatchesStructure.byEquality(
+                official_packages=True, supports_ppas=True,
+                supports_mirrors=True))
+        create_initialized_view(
+            distribution, '+admin', principal=admin,
+            form={
+                'field.official_packages': '', 'field.supports_ppas': '',
+                'field.supports_mirrors': '',
+                'field.actions.change': 'change'})
+        self.assertThat(
+            distribution,
+            MatchesStructure.byEquality(
+                official_packages=False, supports_ppas=False,
+                supports_mirrors=False))
+
+
 class TestDistroReassignView(TestCaseWithFactory):
     """Test the +reassign page for a new distribution."""
 


Follow ups