Merge lp:~wgrant/launchpad/archive-processors-forms into lp:launchpad
- archive-processors-forms
- Merge into devel
Proposed by
William Grant
Status: | Merged |
---|---|
Merged at revision: | 17511 |
Proposed branch: | lp:~wgrant/launchpad/archive-processors-forms |
Merge into: | lp:launchpad |
Prerequisite: | lp:~wgrant/launchpad/archive-processors |
Diff against target: |
396 lines (+61/-79) 7 files modified
lib/lp/buildmaster/interfaces/processor.py (+0/-3) lib/lp/buildmaster/model/processor.py (+0/-4) lib/lp/registry/browser/distribution.py (+20/-25) lib/lp/registry/browser/tests/distribution-views.txt (+1/-1) lib/lp/registry/browser/tests/test_distribution_views.py (+26/-30) lib/lp/registry/stories/distribution/xx-distribution-launchpad-usage.txt (+2/-3) lib/lp/soyuz/browser/archive.py (+12/-13) |
To merge this branch: | bzr merge lp:~wgrant/launchpad/archive-processors-forms |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Colin Watson (community) | Approve | ||
Review via email: mp+259353@code.launchpad.net |
Commit message
Port Archive:+admin, Distribution:+edit and DistributionSet
Description of the change
Port Archive:+admin, Distribution:+edit and DistributionSet
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'lib/lp/buildmaster/interfaces/processor.py' |
2 | --- lib/lp/buildmaster/interfaces/processor.py 2015-05-14 08:28:54 +0000 |
3 | +++ lib/lp/buildmaster/interfaces/processor.py 2015-05-19 00:55:55 +0000 |
4 | @@ -109,9 +109,6 @@ |
5 | def getAll(): |
6 | """Return all the `IProcessor` known to Launchpad.""" |
7 | |
8 | - def getRestricted(): |
9 | - """Return all restricted `IProcessor`s.""" |
10 | - |
11 | def new(name, title, description, restricted=False, |
12 | build_by_default=False, supports_virtualized=False, |
13 | supports_nonvirtualized=True): |
14 | |
15 | === modified file 'lib/lp/buildmaster/model/processor.py' |
16 | --- lib/lp/buildmaster/model/processor.py 2015-05-14 08:28:54 +0000 |
17 | +++ lib/lp/buildmaster/model/processor.py 2015-05-19 00:55:55 +0000 |
18 | @@ -62,10 +62,6 @@ |
19 | """See `IProcessorSet`.""" |
20 | return IStore(Processor).find(Processor) |
21 | |
22 | - def getRestricted(self): |
23 | - """See `IProcessorSet`.""" |
24 | - return IStore(Processor).find(Processor, Processor.restricted == True) |
25 | - |
26 | def new(self, name, title, description, restricted=False, |
27 | build_by_default=False, supports_virtualized=False, |
28 | supports_nonvirtualized=True): |
29 | |
30 | === modified file 'lib/lp/registry/browser/distribution.py' |
31 | --- lib/lp/registry/browser/distribution.py 2015-04-20 09:48:57 +0000 |
32 | +++ lib/lp/registry/browser/distribution.py 2015-05-19 00:55:55 +0000 |
33 | @@ -129,7 +129,7 @@ |
34 | from lp.services.webapp.batching import BatchNavigator |
35 | from lp.services.webapp.breadcrumb import Breadcrumb |
36 | from lp.services.webapp.interfaces import ILaunchBag |
37 | -from lp.soyuz.browser.archive import EnableRestrictedProcessorsMixin |
38 | +from lp.soyuz.browser.archive import EnableProcessorsMixin |
39 | from lp.soyuz.browser.packagesearch import PackageSearchViewBase |
40 | from lp.soyuz.enums import ArchivePurpose |
41 | from lp.soyuz.interfaces.archive import IArchiveSet |
42 | @@ -816,7 +816,7 @@ |
43 | |
44 | |
45 | class DistributionAddView(LaunchpadFormView, RequireVirtualizedBuildersMixin, |
46 | - EnableRestrictedProcessorsMixin): |
47 | + EnableProcessorsMixin): |
48 | |
49 | schema = IDistribution |
50 | label = "Register a new distribution" |
51 | @@ -834,7 +834,7 @@ |
52 | "answers_usage", |
53 | ] |
54 | custom_widget('require_virtualized', CheckBoxWidget) |
55 | - custom_widget('enabled_restricted_processors', LabeledMultiCheckBoxWidget) |
56 | + custom_widget('processors', LabeledMultiCheckBoxWidget) |
57 | |
58 | @property |
59 | def page_title(self): |
60 | @@ -843,9 +843,8 @@ |
61 | |
62 | @property |
63 | def initial_values(self): |
64 | - restricted_processors = getUtility(IProcessorSet).getRestricted() |
65 | return { |
66 | - 'enabled_restricted_processors': restricted_processors, |
67 | + 'processors': getUtility(IProcessorSet).getAll(), |
68 | 'require_virtualized': False, |
69 | } |
70 | |
71 | @@ -858,9 +857,9 @@ |
72 | """See `LaunchpadFormView`.""" |
73 | LaunchpadFormView.setUpFields(self) |
74 | self.form_fields += self.createRequireVirtualized() |
75 | - self.form_fields += self.createEnabledRestrictedProcessors( |
76 | - u"The restricted architectures on which the distribution's main " |
77 | - "archive can build.") |
78 | + self.form_fields += self.createEnabledProcessors( |
79 | + u"The architectures on which the distribution's main archive can " |
80 | + u"build.") |
81 | |
82 | @action("Save", name='save') |
83 | def save_action(self, action, data): |
84 | @@ -877,8 +876,7 @@ |
85 | ) |
86 | archive = distribution.main_archive |
87 | self.updateRequireVirtualized(data['require_virtualized'], archive) |
88 | - archive.enabled_restricted_processors = data[ |
89 | - 'enabled_restricted_processors'] |
90 | + archive.processors = data['processors'] |
91 | |
92 | notify(ObjectCreatedEvent(distribution)) |
93 | self.next_url = canonical_url(distribution) |
94 | @@ -886,7 +884,7 @@ |
95 | |
96 | class DistributionEditView(RegistryEditFormView, |
97 | RequireVirtualizedBuildersMixin, |
98 | - EnableRestrictedProcessorsMixin): |
99 | + EnableProcessorsMixin): |
100 | |
101 | schema = IDistribution |
102 | field_names = [ |
103 | @@ -912,7 +910,7 @@ |
104 | custom_widget('logo', ImageChangeWidget, ImageChangeWidget.EDIT_STYLE) |
105 | custom_widget('mugshot', ImageChangeWidget, ImageChangeWidget.EDIT_STYLE) |
106 | custom_widget('require_virtualized', CheckBoxWidget) |
107 | - custom_widget('enabled_restricted_processors', LabeledMultiCheckBoxWidget) |
108 | + custom_widget('processors', LabeledMultiCheckBoxWidget) |
109 | |
110 | @property |
111 | def label(self): |
112 | @@ -923,17 +921,16 @@ |
113 | """See `LaunchpadFormView`.""" |
114 | RegistryEditFormView.setUpFields(self) |
115 | self.form_fields += self.createRequireVirtualized() |
116 | - self.form_fields += self.createEnabledRestrictedProcessors( |
117 | - u"The restricted architectures on which the distribution's main " |
118 | - "archive can build.") |
119 | + self.form_fields += self.createEnabledProcessors( |
120 | + u"The architectures on which the distribution's main archive can " |
121 | + u"build.") |
122 | |
123 | @property |
124 | def initial_values(self): |
125 | return { |
126 | 'require_virtualized': |
127 | self.context.main_archive.require_virtualized, |
128 | - 'enabled_restricted_processors': |
129 | - self.context.main_archive.enabled_restricted_processors, |
130 | + 'processors': self.context.main_archive.processors, |
131 | } |
132 | |
133 | def validate(self, data): |
134 | @@ -952,14 +949,12 @@ |
135 | self.updateRequireVirtualized( |
136 | new_require_virtualized, self.context.main_archive) |
137 | del(data['require_virtualized']) |
138 | - new_enabled_restricted_processors = data.get( |
139 | - 'enabled_restricted_processors') |
140 | - if new_enabled_restricted_processors is not None: |
141 | - if (set(self.context.main_archive.enabled_restricted_processors) != |
142 | - set(new_enabled_restricted_processors)): |
143 | - self.context.main_archive.enabled_restricted_processors = ( |
144 | - new_enabled_restricted_processors) |
145 | - del(data['enabled_restricted_processors']) |
146 | + new_processors = data.get('processors') |
147 | + if new_processors is not None: |
148 | + if (set(self.context.main_archive.processors) != |
149 | + set(new_processors)): |
150 | + self.context.main_archive.processors = new_processors |
151 | + del(data['processors']) |
152 | |
153 | @action("Change", name='change') |
154 | def change_action(self, action, data): |
155 | |
156 | === modified file 'lib/lp/registry/browser/tests/distribution-views.txt' |
157 | --- lib/lp/registry/browser/tests/distribution-views.txt 2013-09-12 05:19:43 +0000 |
158 | +++ lib/lp/registry/browser/tests/distribution-views.txt 2015-05-19 00:55:55 +0000 |
159 | @@ -80,7 +80,7 @@ |
160 | ... 'field.domainname': 'youbuntu.me', |
161 | ... 'field.members': 'landscape-developers', |
162 | ... 'field.require_virtualized': 'on', |
163 | - ... 'field.enabled_restricted_processors': [], |
164 | + ... 'field.processors': [], |
165 | ... 'field.actions.save': 'Save', |
166 | ... } |
167 | >>> view = create_initialized_view(distributionset, '+add', form=form) |
168 | |
169 | === modified file 'lib/lp/registry/browser/tests/test_distribution_views.py' |
170 | --- lib/lp/registry/browser/tests/test_distribution_views.py 2015-04-20 09:48:57 +0000 |
171 | +++ lib/lp/registry/browser/tests/test_distribution_views.py 2015-05-19 00:55:55 +0000 |
172 | @@ -117,7 +117,7 @@ |
173 | self.simple_user = self.factory.makePerson() |
174 | self.admin = login_celebrity('admin') |
175 | self.distributionset = getUtility(IDistributionSet) |
176 | - self.restricted_processors = getUtility(IProcessorSet).getRestricted() |
177 | + self.all_processors = getUtility(IProcessorSet).getAll() |
178 | |
179 | def getDefaultAddDict(self): |
180 | return { |
181 | @@ -129,8 +129,7 @@ |
182 | 'field.domainname': 'newbuntu', |
183 | 'field.members': self.simple_user.name, |
184 | 'field.require_virtualized': '', |
185 | - 'field.enabled_restricted_processors': [processor.name |
186 | - for processor in self.restricted_processors], |
187 | + 'field.processors': [proc.name for proc in self.all_processors], |
188 | 'field.actions.save': 'Save', |
189 | } |
190 | |
191 | @@ -153,17 +152,15 @@ |
192 | widget = view.widgets['require_virtualized'] |
193 | self.assertEqual(False, widget._getCurrentValue()) |
194 | |
195 | - def test_add_distro_init_value_enabled_restricted_processors(self): |
196 | + def test_add_distro_init_value_processors(self): |
197 | view = create_initialized_view( |
198 | self.distributionset, '+add', principal=self.admin, |
199 | method='GET') |
200 | |
201 | - widget = view.widgets['enabled_restricted_processors'] |
202 | - self.assertContentEqual( |
203 | - self.restricted_processors, widget._getCurrentValue()) |
204 | - self.assertContentEqual( |
205 | - self.restricted_processors, |
206 | - [item.value for item in widget.vocabulary]) |
207 | + widget = view.widgets['processors'] |
208 | + self.assertContentEqual(self.all_processors, widget._getCurrentValue()) |
209 | + self.assertContentEqual( |
210 | + self.all_processors, [item.value for item in widget.vocabulary]) |
211 | |
212 | def test_add_distro_require_virtualized(self): |
213 | creation_form = self.getDefaultAddDict() |
214 | @@ -177,16 +174,18 @@ |
215 | False, |
216 | distribution.main_archive.require_virtualized) |
217 | |
218 | - def test_add_distro_enabled_restricted_processors(self): |
219 | + def test_add_distro_processors(self): |
220 | creation_form = self.getDefaultAddDict() |
221 | - creation_form['field.enabled_restricted_processors'] = [] |
222 | + creation_form['field.processors'] = [] |
223 | create_initialized_view( |
224 | self.distributionset, '+add', principal=self.admin, |
225 | method='POST', form=creation_form) |
226 | |
227 | distribution = self.distributionset.getByName('newbuntu') |
228 | + # XXX wgrant 2015-05-15: Default processors are currently implicit. |
229 | self.assertContentEqual( |
230 | - [], distribution.main_archive.enabled_restricted_processors) |
231 | + [proc for proc in self.all_processors if not proc.restricted], |
232 | + distribution.main_archive.processors) |
233 | |
234 | |
235 | class TestDistroEditView(TestCaseWithFactory): |
236 | @@ -198,7 +197,7 @@ |
237 | super(TestDistroEditView, self).setUp() |
238 | self.admin = login_celebrity('admin') |
239 | self.distribution = self.factory.makeDistribution() |
240 | - self.restricted_processors = getUtility(IProcessorSet).getRestricted() |
241 | + self.all_processors = getUtility(IProcessorSet).getAll() |
242 | |
243 | def test_edit_distro_init_value_require_virtualized(self): |
244 | view = create_initialized_view( |
245 | @@ -210,19 +209,16 @@ |
246 | self.distribution.main_archive.require_virtualized, |
247 | widget._getCurrentValue()) |
248 | |
249 | - def test_edit_distro_init_value_enabled_restricted_processors(self): |
250 | - self.distribution.main_archive.enabled_restricted_processors = ( |
251 | - self.restricted_processors) |
252 | + def test_edit_distro_init_value_processors(self): |
253 | + self.distribution.main_archive.processors = self.all_processors |
254 | view = create_initialized_view( |
255 | self.distribution, '+edit', principal=self.admin, |
256 | method='GET') |
257 | |
258 | - widget = view.widgets['enabled_restricted_processors'] |
259 | - self.assertContentEqual( |
260 | - self.restricted_processors, widget._getCurrentValue()) |
261 | - self.assertContentEqual( |
262 | - self.restricted_processors, |
263 | - [item.value for item in widget.vocabulary]) |
264 | + widget = view.widgets['processors'] |
265 | + self.assertContentEqual(self.all_processors, widget._getCurrentValue()) |
266 | + self.assertContentEqual( |
267 | + self.all_processors, [item.value for item in widget.vocabulary]) |
268 | |
269 | def getDefaultEditDict(self): |
270 | return { |
271 | @@ -231,8 +227,7 @@ |
272 | 'field.summary': 'newbuntu', |
273 | 'field.description': 'newbuntu', |
274 | 'field.require_virtualized.used': u'', |
275 | - 'field.enabled_restricted_processors': [processor.name |
276 | - for processor in self.restricted_processors], |
277 | + 'field.processors': [proc.name for proc in self.all_processors], |
278 | 'field.actions.change': 'Change', |
279 | } |
280 | |
281 | @@ -248,18 +243,19 @@ |
282 | True, |
283 | self.distribution.main_archive.require_virtualized) |
284 | |
285 | - def test_change_enabled_restricted_processors(self): |
286 | + def test_change_processors(self): |
287 | edit_form = self.getDefaultEditDict() |
288 | - edit_form['field.enabled_restricted_processors'] = [] |
289 | + edit_form['field.processors'] = [] |
290 | |
291 | - self.distribution.main_archive.enabled_restricted_processors = ( |
292 | - self.restricted_processors) |
293 | + self.distribution.main_archive.processors = self.all_processors |
294 | create_initialized_view( |
295 | self.distribution, '+edit', principal=self.admin, |
296 | method='POST', form=edit_form) |
297 | |
298 | + # XXX wgrant 2015-05-15: Default processors are currently implicit. |
299 | self.assertContentEqual( |
300 | - [], self.distribution.main_archive.enabled_restricted_processors) |
301 | + [proc for proc in self.all_processors if not proc.restricted], |
302 | + self.distribution.main_archive.processors) |
303 | |
304 | def test_package_derivatives_email(self): |
305 | # Test that the edit form allows changing package_derivatives_email |
306 | |
307 | === modified file 'lib/lp/registry/stories/distribution/xx-distribution-launchpad-usage.txt' |
308 | --- lib/lp/registry/stories/distribution/xx-distribution-launchpad-usage.txt 2013-09-13 06:20:49 +0000 |
309 | +++ lib/lp/registry/stories/distribution/xx-distribution-launchpad-usage.txt 2015-05-19 00:55:55 +0000 |
310 | @@ -47,9 +47,8 @@ |
311 | LAUNCHPAD |
312 | >>> print registrant.getControl(name='field.require_virtualized').value |
313 | False |
314 | - >>> print registrant.getControl( |
315 | - ... name='field.enabled_restricted_processors').value |
316 | - [] |
317 | + >>> print registrant.getControl(name='field.processors').value |
318 | + ['386', 'amd64', 'hppa'] |
319 | |
320 | >>> registrant.getControl(name='field.translations_usage').value = [ |
321 | ... 'UNKNOWN'] |
322 | |
323 | === modified file 'lib/lp/soyuz/browser/archive.py' |
324 | --- lib/lp/soyuz/browser/archive.py 2015-04-20 09:48:57 +0000 |
325 | +++ lib/lp/soyuz/browser/archive.py 2015-05-19 00:55:55 +0000 |
326 | @@ -22,7 +22,7 @@ |
327 | 'ArchivePackagesView', |
328 | 'ArchiveView', |
329 | 'ArchiveViewBase', |
330 | - 'EnableRestrictedProcessorsMixin', |
331 | + 'EnableProcessorsMixin', |
332 | 'make_archive_vocabulary', |
333 | 'PackageCopyingMixin', |
334 | 'traverse_named_ppa', |
335 | @@ -2023,16 +2023,16 @@ |
336 | return 'Edit %s' % self.context.displayname |
337 | |
338 | |
339 | -class EnableRestrictedProcessorsMixin: |
340 | - """A mixin that provides enabled_restricted_processors field support""" |
341 | +class EnableProcessorsMixin: |
342 | + """A mixin that provides processors field support""" |
343 | |
344 | - def createEnabledRestrictedProcessors(self, description=None): |
345 | - """Creates the 'enabled_restricted_processors' field.""" |
346 | + def createEnabledProcessors(self, description=None): |
347 | + """Creates the 'processors' field.""" |
348 | terms = [] |
349 | - for processor in getUtility(IProcessorSet).getRestricted(): |
350 | + for processor in getUtility(IProcessorSet).getAll(): |
351 | terms.append(SimpleTerm( |
352 | processor, token=processor.name, title=processor.title)) |
353 | - old_field = IArchive['enabled_restricted_processors'] |
354 | + old_field = IArchive['processors'] |
355 | return form.Fields( |
356 | List(__name__=old_field.__name__, |
357 | title=old_field.title, |
358 | @@ -2043,7 +2043,7 @@ |
359 | render_context=self.render_context) |
360 | |
361 | |
362 | -class ArchiveAdminView(BaseArchiveEditView, EnableRestrictedProcessorsMixin): |
363 | +class ArchiveAdminView(BaseArchiveEditView, EnableProcessorsMixin): |
364 | |
365 | field_names = [ |
366 | 'enabled', |
367 | @@ -2058,7 +2058,7 @@ |
368 | 'external_dependencies', |
369 | ] |
370 | custom_widget('external_dependencies', TextAreaWidget, height=3) |
371 | - custom_widget('enabled_restricted_processors', LabeledMultiCheckBoxWidget) |
372 | + custom_widget('processors', LabeledMultiCheckBoxWidget) |
373 | page_title = 'Administer' |
374 | |
375 | @property |
376 | @@ -2102,17 +2102,16 @@ |
377 | @property |
378 | def initial_values(self): |
379 | return { |
380 | - 'enabled_restricted_processors': |
381 | - self.context.enabled_restricted_processors, |
382 | + 'processors': self.context.processors, |
383 | } |
384 | |
385 | def setUpFields(self): |
386 | """Override `LaunchpadEditFormView`. |
387 | |
388 | - See `createEnabledRestrictedProcessors` method. |
389 | + See `createEnabledProcessors` method. |
390 | """ |
391 | super(ArchiveAdminView, self).setUpFields() |
392 | - self.form_fields += self.createEnabledRestrictedProcessors() |
393 | + self.form_fields += self.createEnabledProcessors() |
394 | |
395 | |
396 | class ArchiveDeleteView(LaunchpadFormView): |
ProcessorSet. getRestricted is now unused and could be removed.