launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #18581
[Merge] lp:~wgrant/launchpad/archive-processors-forms into lp:launchpad
William Grant has proposed merging lp:~wgrant/launchpad/archive-processors-forms into lp:launchpad with lp:~wgrant/launchpad/archive-processors as a prerequisite.
Commit message:
Port Archive:+admin, Distribution:+edit and DistributionSet:+add to Archive.processors.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~wgrant/launchpad/archive-processors-forms/+merge/259353
Port Archive:+admin, Distribution:+edit and DistributionSet:+add to Archive.processors.
--
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~wgrant/launchpad/archive-processors-forms into lp:launchpad.
=== modified file 'lib/lp/registry/browser/distribution.py'
--- lib/lp/registry/browser/distribution.py 2015-04-20 09:48:57 +0000
+++ lib/lp/registry/browser/distribution.py 2015-05-18 07:05:39 +0000
@@ -129,7 +129,7 @@
from lp.services.webapp.batching import BatchNavigator
from lp.services.webapp.breadcrumb import Breadcrumb
from lp.services.webapp.interfaces import ILaunchBag
-from lp.soyuz.browser.archive import EnableRestrictedProcessorsMixin
+from lp.soyuz.browser.archive import EnableProcessorsMixin
from lp.soyuz.browser.packagesearch import PackageSearchViewBase
from lp.soyuz.enums import ArchivePurpose
from lp.soyuz.interfaces.archive import IArchiveSet
@@ -816,7 +816,7 @@
class DistributionAddView(LaunchpadFormView, RequireVirtualizedBuildersMixin,
- EnableRestrictedProcessorsMixin):
+ EnableProcessorsMixin):
schema = IDistribution
label = "Register a new distribution"
@@ -834,7 +834,7 @@
"answers_usage",
]
custom_widget('require_virtualized', CheckBoxWidget)
- custom_widget('enabled_restricted_processors', LabeledMultiCheckBoxWidget)
+ custom_widget('processors', LabeledMultiCheckBoxWidget)
@property
def page_title(self):
@@ -843,9 +843,8 @@
@property
def initial_values(self):
- restricted_processors = getUtility(IProcessorSet).getRestricted()
return {
- 'enabled_restricted_processors': restricted_processors,
+ 'processors': getUtility(IProcessorSet).getAll(),
'require_virtualized': False,
}
@@ -858,9 +857,9 @@
"""See `LaunchpadFormView`."""
LaunchpadFormView.setUpFields(self)
self.form_fields += self.createRequireVirtualized()
- self.form_fields += self.createEnabledRestrictedProcessors(
- u"The restricted architectures on which the distribution's main "
- "archive can build.")
+ self.form_fields += self.createEnabledProcessors(
+ u"The architectures on which the distribution's main archive can "
+ u"build.")
@action("Save", name='save')
def save_action(self, action, data):
@@ -877,8 +876,7 @@
)
archive = distribution.main_archive
self.updateRequireVirtualized(data['require_virtualized'], archive)
- archive.enabled_restricted_processors = data[
- 'enabled_restricted_processors']
+ archive.processors = data['processors']
notify(ObjectCreatedEvent(distribution))
self.next_url = canonical_url(distribution)
@@ -886,7 +884,7 @@
class DistributionEditView(RegistryEditFormView,
RequireVirtualizedBuildersMixin,
- EnableRestrictedProcessorsMixin):
+ EnableProcessorsMixin):
schema = IDistribution
field_names = [
@@ -912,7 +910,7 @@
custom_widget('logo', ImageChangeWidget, ImageChangeWidget.EDIT_STYLE)
custom_widget('mugshot', ImageChangeWidget, ImageChangeWidget.EDIT_STYLE)
custom_widget('require_virtualized', CheckBoxWidget)
- custom_widget('enabled_restricted_processors', LabeledMultiCheckBoxWidget)
+ custom_widget('processors', LabeledMultiCheckBoxWidget)
@property
def label(self):
@@ -923,17 +921,16 @@
"""See `LaunchpadFormView`."""
RegistryEditFormView.setUpFields(self)
self.form_fields += self.createRequireVirtualized()
- self.form_fields += self.createEnabledRestrictedProcessors(
- u"The restricted architectures on which the distribution's main "
- "archive can build.")
+ self.form_fields += self.createEnabledProcessors(
+ u"The architectures on which the distribution's main archive can "
+ u"build.")
@property
def initial_values(self):
return {
'require_virtualized':
self.context.main_archive.require_virtualized,
- 'enabled_restricted_processors':
- self.context.main_archive.enabled_restricted_processors,
+ 'processors': self.context.main_archive.processors,
}
def validate(self, data):
@@ -952,14 +949,12 @@
self.updateRequireVirtualized(
new_require_virtualized, self.context.main_archive)
del(data['require_virtualized'])
- new_enabled_restricted_processors = data.get(
- 'enabled_restricted_processors')
- if new_enabled_restricted_processors is not None:
- if (set(self.context.main_archive.enabled_restricted_processors) !=
- set(new_enabled_restricted_processors)):
- self.context.main_archive.enabled_restricted_processors = (
- new_enabled_restricted_processors)
- del(data['enabled_restricted_processors'])
+ new_processors = data.get('processors')
+ if new_processors is not None:
+ if (set(self.context.main_archive.processors) !=
+ set(new_processors)):
+ self.context.main_archive.processors = new_processors
+ del(data['processors'])
@action("Change", name='change')
def change_action(self, action, data):
=== modified file 'lib/lp/registry/browser/tests/distribution-views.txt'
--- lib/lp/registry/browser/tests/distribution-views.txt 2013-09-12 05:19:43 +0000
+++ lib/lp/registry/browser/tests/distribution-views.txt 2015-05-18 07:05:39 +0000
@@ -80,7 +80,7 @@
... 'field.domainname': 'youbuntu.me',
... 'field.members': 'landscape-developers',
... 'field.require_virtualized': 'on',
- ... 'field.enabled_restricted_processors': [],
+ ... 'field.processors': [],
... 'field.actions.save': 'Save',
... }
>>> view = create_initialized_view(distributionset, '+add', form=form)
=== modified file 'lib/lp/registry/browser/tests/test_distribution_views.py'
--- lib/lp/registry/browser/tests/test_distribution_views.py 2015-04-20 09:48:57 +0000
+++ lib/lp/registry/browser/tests/test_distribution_views.py 2015-05-18 07:05:39 +0000
@@ -117,7 +117,7 @@
self.simple_user = self.factory.makePerson()
self.admin = login_celebrity('admin')
self.distributionset = getUtility(IDistributionSet)
- self.restricted_processors = getUtility(IProcessorSet).getRestricted()
+ self.all_processors = getUtility(IProcessorSet).getAll()
def getDefaultAddDict(self):
return {
@@ -129,8 +129,7 @@
'field.domainname': 'newbuntu',
'field.members': self.simple_user.name,
'field.require_virtualized': '',
- 'field.enabled_restricted_processors': [processor.name
- for processor in self.restricted_processors],
+ 'field.processors': [proc.name for proc in self.all_processors],
'field.actions.save': 'Save',
}
@@ -153,17 +152,15 @@
widget = view.widgets['require_virtualized']
self.assertEqual(False, widget._getCurrentValue())
- def test_add_distro_init_value_enabled_restricted_processors(self):
+ def test_add_distro_init_value_processors(self):
view = create_initialized_view(
self.distributionset, '+add', principal=self.admin,
method='GET')
- widget = view.widgets['enabled_restricted_processors']
- self.assertContentEqual(
- self.restricted_processors, widget._getCurrentValue())
- self.assertContentEqual(
- self.restricted_processors,
- [item.value for item in widget.vocabulary])
+ widget = view.widgets['processors']
+ self.assertContentEqual(self.all_processors, widget._getCurrentValue())
+ self.assertContentEqual(
+ self.all_processors, [item.value for item in widget.vocabulary])
def test_add_distro_require_virtualized(self):
creation_form = self.getDefaultAddDict()
@@ -177,16 +174,18 @@
False,
distribution.main_archive.require_virtualized)
- def test_add_distro_enabled_restricted_processors(self):
+ def test_add_distro_processors(self):
creation_form = self.getDefaultAddDict()
- creation_form['field.enabled_restricted_processors'] = []
+ creation_form['field.processors'] = []
create_initialized_view(
self.distributionset, '+add', principal=self.admin,
method='POST', form=creation_form)
distribution = self.distributionset.getByName('newbuntu')
+ # XXX wgrant 2015-05-15: Default processors are currently implicit.
self.assertContentEqual(
- [], distribution.main_archive.enabled_restricted_processors)
+ [proc for proc in self.all_processors if not proc.restricted],
+ distribution.main_archive.processors)
class TestDistroEditView(TestCaseWithFactory):
@@ -198,7 +197,7 @@
super(TestDistroEditView, self).setUp()
self.admin = login_celebrity('admin')
self.distribution = self.factory.makeDistribution()
- self.restricted_processors = getUtility(IProcessorSet).getRestricted()
+ self.all_processors = getUtility(IProcessorSet).getAll()
def test_edit_distro_init_value_require_virtualized(self):
view = create_initialized_view(
@@ -210,19 +209,16 @@
self.distribution.main_archive.require_virtualized,
widget._getCurrentValue())
- def test_edit_distro_init_value_enabled_restricted_processors(self):
- self.distribution.main_archive.enabled_restricted_processors = (
- self.restricted_processors)
+ def test_edit_distro_init_value_processors(self):
+ self.distribution.main_archive.processors = self.all_processors
view = create_initialized_view(
self.distribution, '+edit', principal=self.admin,
method='GET')
- widget = view.widgets['enabled_restricted_processors']
- self.assertContentEqual(
- self.restricted_processors, widget._getCurrentValue())
- self.assertContentEqual(
- self.restricted_processors,
- [item.value for item in widget.vocabulary])
+ widget = view.widgets['processors']
+ self.assertContentEqual(self.all_processors, widget._getCurrentValue())
+ self.assertContentEqual(
+ self.all_processors, [item.value for item in widget.vocabulary])
def getDefaultEditDict(self):
return {
@@ -231,8 +227,7 @@
'field.summary': 'newbuntu',
'field.description': 'newbuntu',
'field.require_virtualized.used': u'',
- 'field.enabled_restricted_processors': [processor.name
- for processor in self.restricted_processors],
+ 'field.processors': [proc.name for proc in self.all_processors],
'field.actions.change': 'Change',
}
@@ -248,18 +243,19 @@
True,
self.distribution.main_archive.require_virtualized)
- def test_change_enabled_restricted_processors(self):
+ def test_change_processors(self):
edit_form = self.getDefaultEditDict()
- edit_form['field.enabled_restricted_processors'] = []
+ edit_form['field.processors'] = []
- self.distribution.main_archive.enabled_restricted_processors = (
- self.restricted_processors)
+ self.distribution.main_archive.processors = self.all_processors
create_initialized_view(
self.distribution, '+edit', principal=self.admin,
method='POST', form=edit_form)
+ # XXX wgrant 2015-05-15: Default processors are currently implicit.
self.assertContentEqual(
- [], self.distribution.main_archive.enabled_restricted_processors)
+ [proc for proc in self.all_processors if not proc.restricted],
+ self.distribution.main_archive.processors)
def test_package_derivatives_email(self):
# Test that the edit form allows changing package_derivatives_email
=== modified file 'lib/lp/registry/stories/distribution/xx-distribution-launchpad-usage.txt'
--- lib/lp/registry/stories/distribution/xx-distribution-launchpad-usage.txt 2013-09-13 06:20:49 +0000
+++ lib/lp/registry/stories/distribution/xx-distribution-launchpad-usage.txt 2015-05-18 07:05:39 +0000
@@ -47,9 +47,8 @@
LAUNCHPAD
>>> print registrant.getControl(name='field.require_virtualized').value
False
- >>> print registrant.getControl(
- ... name='field.enabled_restricted_processors').value
- []
+ >>> print registrant.getControl(name='field.processors').value
+ ['386', 'amd64', 'hppa']
>>> registrant.getControl(name='field.translations_usage').value = [
... 'UNKNOWN']
=== modified file 'lib/lp/soyuz/browser/archive.py'
--- lib/lp/soyuz/browser/archive.py 2015-04-20 09:48:57 +0000
+++ lib/lp/soyuz/browser/archive.py 2015-05-18 07:05:39 +0000
@@ -22,7 +22,7 @@
'ArchivePackagesView',
'ArchiveView',
'ArchiveViewBase',
- 'EnableRestrictedProcessorsMixin',
+ 'EnableProcessorsMixin',
'make_archive_vocabulary',
'PackageCopyingMixin',
'traverse_named_ppa',
@@ -2023,16 +2023,16 @@
return 'Edit %s' % self.context.displayname
-class EnableRestrictedProcessorsMixin:
- """A mixin that provides enabled_restricted_processors field support"""
+class EnableProcessorsMixin:
+ """A mixin that provides processors field support"""
- def createEnabledRestrictedProcessors(self, description=None):
- """Creates the 'enabled_restricted_processors' field."""
+ def createEnabledProcessors(self, description=None):
+ """Creates the 'processors' field."""
terms = []
- for processor in getUtility(IProcessorSet).getRestricted():
+ for processor in getUtility(IProcessorSet).getAll():
terms.append(SimpleTerm(
processor, token=processor.name, title=processor.title))
- old_field = IArchive['enabled_restricted_processors']
+ old_field = IArchive['processors']
return form.Fields(
List(__name__=old_field.__name__,
title=old_field.title,
@@ -2043,7 +2043,7 @@
render_context=self.render_context)
-class ArchiveAdminView(BaseArchiveEditView, EnableRestrictedProcessorsMixin):
+class ArchiveAdminView(BaseArchiveEditView, EnableProcessorsMixin):
field_names = [
'enabled',
@@ -2058,7 +2058,7 @@
'external_dependencies',
]
custom_widget('external_dependencies', TextAreaWidget, height=3)
- custom_widget('enabled_restricted_processors', LabeledMultiCheckBoxWidget)
+ custom_widget('processors', LabeledMultiCheckBoxWidget)
page_title = 'Administer'
@property
@@ -2102,17 +2102,16 @@
@property
def initial_values(self):
return {
- 'enabled_restricted_processors':
- self.context.enabled_restricted_processors,
+ 'processors': self.context.processors,
}
def setUpFields(self):
"""Override `LaunchpadEditFormView`.
- See `createEnabledRestrictedProcessors` method.
+ See `createEnabledProcessors` method.
"""
super(ArchiveAdminView, self).setUpFields()
- self.form_fields += self.createEnabledRestrictedProcessors()
+ self.form_fields += self.createEnabledProcessors()
class ArchiveDeleteView(LaunchpadFormView):
Follow ups