Merge lp:~cjwatson/launchpad/custom-widget-no-class-advice-4 into lp:launchpad
- custom-widget-no-class-advice-4
- Merge into devel
Proposed by
Colin Watson
Status: | Merged |
---|---|
Merged at revision: | 18776 |
Proposed branch: | lp:~cjwatson/launchpad/custom-widget-no-class-advice-4 |
Merge into: | lp:launchpad |
Diff against target: |
712 lines (+143/-131) 9 files modified
lib/lp/registry/browser/person.py (+19/-18) lib/lp/registry/browser/poll.py (+4/-4) lib/lp/registry/browser/product.py (+58/-54) lib/lp/registry/browser/productrelease.py (+14/-9) lib/lp/registry/browser/productseries.py (+8/-6) lib/lp/registry/browser/project.py (+4/-3) lib/lp/registry/browser/sourcepackage.py (+6/-6) lib/lp/registry/browser/team.py (+28/-28) lib/lp/registry/doc/product-widgets.txt (+2/-3) |
To merge this branch: | bzr merge lp:~cjwatson/launchpad/custom-widget-no-class-advice-4 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
William Grant | code | Approve | |
Review via email: mp+354107@code.launchpad.net |
Commit message
Remove Zope class advice from custom widget registration (part 4).
Description of the change
To post a comment you must log in.
Revision history for this message
William Grant (wgrant) : | # |
review:
Approve
(code)
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'lib/lp/registry/browser/person.py' |
2 | --- lib/lp/registry/browser/person.py 2018-05-18 14:07:28 +0000 |
3 | +++ lib/lp/registry/browser/person.py 2018-08-31 11:41:19 +0000 |
4 | @@ -74,6 +74,7 @@ |
5 | from zope.error.interfaces import IErrorReportingUtility |
6 | from zope.formlib import form |
7 | from zope.formlib.form import FormFields |
8 | +from zope.formlib.widget import CustomWidgetFactory |
9 | from zope.formlib.widgets import ( |
10 | TextAreaWidget, |
11 | TextWidget, |
12 | @@ -101,7 +102,6 @@ |
13 | from lp import _ |
14 | from lp.app.browser.launchpadform import ( |
15 | action, |
16 | - custom_widget, |
17 | LaunchpadEditFormView, |
18 | LaunchpadFormView, |
19 | ) |
20 | @@ -1041,7 +1041,8 @@ |
21 | |
22 | schema = DeactivateAccountSchema |
23 | label = "Deactivate your Launchpad account" |
24 | - custom_widget('comment', TextAreaWidget, height=5, width=60) |
25 | + custom_widget_comment = CustomWidgetFactory( |
26 | + TextAreaWidget, height=5, width=60) |
27 | |
28 | def validate(self, data): |
29 | """See `LaunchpadFormView`.""" |
30 | @@ -1238,8 +1239,8 @@ |
31 | 'personal_standing', 'personal_standing_reason', |
32 | 'require_strong_email_authentication', |
33 | ] |
34 | - custom_widget( |
35 | - 'personal_standing_reason', TextAreaWidget, height=5, width=60) |
36 | + custom_widget_personal_standing_reason = CustomWidgetFactory( |
37 | + TextAreaWidget, height=5, width=60) |
38 | |
39 | @property |
40 | def is_viewing_person(self): |
41 | @@ -1278,7 +1279,8 @@ |
42 | schema = IAccountAdministerSchema |
43 | label = "Review person's account" |
44 | field_names = ['status', 'comment'] |
45 | - custom_widget('comment', TextAreaWidget, height=5, width=60) |
46 | + custom_widget_comment = CustomWidgetFactory( |
47 | + TextAreaWidget, height=5, width=60) |
48 | |
49 | def __init__(self, context, request): |
50 | """See `LaunchpadEditFormView`.""" |
51 | @@ -1351,7 +1353,7 @@ |
52 | class PersonVouchersView(LaunchpadFormView): |
53 | """Form for displaying and redeeming commercial subscription vouchers.""" |
54 | |
55 | - custom_widget('voucher', LaunchpadDropdownWidget) |
56 | + custom_widget_voucher = LaunchpadDropdownWidget |
57 | |
58 | @property |
59 | def page_title(self): |
60 | @@ -2705,7 +2707,8 @@ |
61 | 'hide_email_addresses', 'verbose_bugnotifications', |
62 | 'selfgenerated_bugnotifications', |
63 | 'expanded_notification_footers'] |
64 | - custom_widget('mugshot', ImageChangeWidget, ImageChangeWidget.EDIT_STYLE) |
65 | + custom_widget_mugshot = CustomWidgetFactory( |
66 | + ImageChangeWidget, ImageChangeWidget.EDIT_STYLE) |
67 | |
68 | label = 'Change your personal details' |
69 | page_title = label |
70 | @@ -2775,10 +2778,10 @@ |
71 | |
72 | schema = IEmailAddress |
73 | |
74 | - custom_widget('VALIDATED_SELECTED', LaunchpadRadioWidget, |
75 | - orientation='vertical') |
76 | - custom_widget('UNVALIDATED_SELECTED', LaunchpadRadioWidget, |
77 | - orientation='vertical') |
78 | + custom_widget_VALIDATED_SELECTED = CustomWidgetFactory( |
79 | + LaunchpadRadioWidget, orientation='vertical') |
80 | + custom_widget_UNVALIDATED_SELECTED = CustomWidgetFactory( |
81 | + LaunchpadRadioWidget, orientation='vertical') |
82 | |
83 | label = 'Change your email settings' |
84 | |
85 | @@ -2840,8 +2843,7 @@ |
86 | Choice(__name__='VALIDATED_SELECTED', |
87 | title=_('These addresses are confirmed as being yours'), |
88 | source=SimpleVocabulary(terms), |
89 | - ), |
90 | - custom_widget=self.custom_widgets['VALIDATED_SELECTED']) |
91 | + )) |
92 | |
93 | def _unvalidated_emails_field(self): |
94 | """Create a field with a vocabulary of unvalidated and guessed emails. |
95 | @@ -2862,8 +2864,7 @@ |
96 | |
97 | return FormFields( |
98 | Choice(__name__='UNVALIDATED_SELECTED', title=title, |
99 | - source=SimpleVocabulary(terms)), |
100 | - custom_widget=self.custom_widgets['UNVALIDATED_SELECTED']) |
101 | + source=SimpleVocabulary(terms))) |
102 | |
103 | def _validate_selected_address(self, data, field='VALIDATED_SELECTED'): |
104 | """A generic validator for this view's actions. |
105 | @@ -3104,8 +3105,8 @@ |
106 | |
107 | schema = IEmailAddress |
108 | |
109 | - custom_widget('mailing_list_auto_subscribe_policy', |
110 | - LaunchpadRadioWidgetWithDescription) |
111 | + custom_widget_mailing_list_auto_subscribe_policy = ( |
112 | + LaunchpadRadioWidgetWithDescription) |
113 | |
114 | label = 'Change your mailing list subscriptions' |
115 | |
116 | @@ -4016,7 +4017,7 @@ |
117 | |
118 | schema = IEmailToPerson |
119 | field_names = ['subject', 'message'] |
120 | - custom_widget('subject', TextWidget, displayWidth=60) |
121 | + custom_widget_subject = CustomWidgetFactory(TextWidget, displayWidth=60) |
122 | |
123 | def initialize(self): |
124 | """See `ILaunchpadFormView`.""" |
125 | |
126 | === modified file 'lib/lp/registry/browser/poll.py' |
127 | --- lib/lp/registry/browser/poll.py 2016-01-26 15:47:37 +0000 |
128 | +++ lib/lp/registry/browser/poll.py 2018-08-31 11:41:19 +0000 |
129 | @@ -1,4 +1,4 @@ |
130 | -# Copyright 2009 Canonical Ltd. This software is licensed under the |
131 | +# Copyright 2009-2018 Canonical Ltd. This software is licensed under the |
132 | # GNU Affero General Public License version 3 (see the file LICENSE). |
133 | |
134 | __metaclass__ = type |
135 | @@ -21,6 +21,7 @@ |
136 | from z3c.ptcompat import ViewPageTemplateFile |
137 | from zope.component import getUtility |
138 | from zope.event import notify |
139 | +from zope.formlib.widget import CustomWidgetFactory |
140 | from zope.formlib.widgets import TextWidget |
141 | from zope.interface import ( |
142 | implementer, |
143 | @@ -30,7 +31,6 @@ |
144 | |
145 | from lp.app.browser.launchpadform import ( |
146 | action, |
147 | - custom_widget, |
148 | LaunchpadEditFormView, |
149 | LaunchpadFormView, |
150 | ) |
151 | @@ -443,7 +443,7 @@ |
152 | label = "Edit option details" |
153 | page_title = 'Edit option' |
154 | field_names = ["name", "title"] |
155 | - custom_widget("title", TextWidget, displayWidth=30) |
156 | + custom_widget_title = CustomWidgetFactory(TextWidget, displayWidth=30) |
157 | |
158 | @property |
159 | def cancel_url(self): |
160 | @@ -463,7 +463,7 @@ |
161 | label = "Create new poll option" |
162 | page_title = "New option" |
163 | field_names = ["name", "title"] |
164 | - custom_widget("title", TextWidget, displayWidth=30) |
165 | + custom_widget_title = CustomWidgetFactory(TextWidget, displayWidth=30) |
166 | |
167 | @property |
168 | def cancel_url(self): |
169 | |
170 | === modified file 'lib/lp/registry/browser/product.py' |
171 | --- lib/lp/registry/browser/product.py 2016-11-15 13:37:38 +0000 |
172 | +++ lib/lp/registry/browser/product.py 2018-08-31 11:41:19 +0000 |
173 | @@ -1,4 +1,4 @@ |
174 | -# Copyright 2009-2016 Canonical Ltd. This software is licensed under the |
175 | +# Copyright 2009-2018 Canonical Ltd. This software is licensed under the |
176 | # GNU Affero General Public License version 3 (see the file LICENSE). |
177 | |
178 | """Browser views for products.""" |
179 | @@ -82,7 +82,6 @@ |
180 | from lp.answers.browser.questiontarget import QuestionTargetTraversalMixin |
181 | from lp.app.browser.launchpadform import ( |
182 | action, |
183 | - custom_widget, |
184 | LaunchpadEditFormView, |
185 | LaunchpadFormView, |
186 | render_radio_widget_part, |
187 | @@ -1406,10 +1405,10 @@ |
188 | "licenses", |
189 | "license_info", |
190 | ] |
191 | - custom_widget('licenses', LicenseWidget) |
192 | - custom_widget('license_info', GhostWidget) |
193 | - custom_widget( |
194 | - 'information_type', LaunchpadRadioWidgetWithDescription, |
195 | + custom_widget_licenses = LicenseWidget |
196 | + custom_widget_license_info = GhostWidget |
197 | + custom_widget_information_type = CustomWidgetFactory( |
198 | + LaunchpadRadioWidgetWithDescription, |
199 | vocabulary=InformationTypeVocabulary(types=PILLAR_INFORMATION_TYPES)) |
200 | |
201 | @property |
202 | @@ -1605,8 +1604,10 @@ |
203 | |
204 | schema = IProductSeries |
205 | field_names = ['name', 'summary', 'branch', 'releasefileglob'] |
206 | - custom_widget('summary', TextAreaWidget, height=7, width=62) |
207 | - custom_widget('releasefileglob', StrippedTextWidget, displayWidth=40) |
208 | + custom_widget_summary = CustomWidgetFactory( |
209 | + TextAreaWidget, height=7, width=62) |
210 | + custom_widget_releasefileglob = CustomWidgetFactory( |
211 | + StrippedTextWidget, displayWidth=40) |
212 | |
213 | series = None |
214 | |
215 | @@ -1765,10 +1766,10 @@ |
216 | # upon creation. |
217 | for_input = True |
218 | |
219 | - custom_widget('rcs_type', LaunchpadRadioWidget) |
220 | - custom_widget('branch_type', LaunchpadRadioWidget) |
221 | - custom_widget('default_vcs', LaunchpadRadioWidget) |
222 | - custom_widget('git_repository_type', LaunchpadRadioWidget) |
223 | + custom_widget_rcs_type = LaunchpadRadioWidget |
224 | + custom_widget_branch_type = LaunchpadRadioWidget |
225 | + custom_widget_default_vcs = LaunchpadRadioWidget |
226 | + custom_widget_git_repository_type = LaunchpadRadioWidget |
227 | |
228 | errors_in_action = False |
229 | is_series = False |
230 | @@ -2219,23 +2220,22 @@ |
231 | ('subscription_modified_after', 'subscription_modified_before'), |
232 | ] |
233 | |
234 | - custom_widget( |
235 | - 'licenses', CheckBoxMatrixWidget, column_count=4, |
236 | - orientation='vertical') |
237 | - custom_widget('active', LaunchpadRadioWidget, |
238 | - _messageNoValue="(do not filter)") |
239 | - custom_widget('project_reviewed', LaunchpadRadioWidget, |
240 | - _messageNoValue="(do not filter)") |
241 | - custom_widget('license_approved', LaunchpadRadioWidget, |
242 | - _messageNoValue="(do not filter)") |
243 | - custom_widget('has_subscription', LaunchpadRadioWidget, |
244 | - _messageNoValue="(do not filter)") |
245 | - custom_widget('created_after', DateWidget) |
246 | - custom_widget('created_before', DateWidget) |
247 | - custom_widget('subscription_expires_after', DateWidget) |
248 | - custom_widget('subscription_expires_before', DateWidget) |
249 | - custom_widget('subscription_modified_after', DateWidget) |
250 | - custom_widget('subscription_modified_before', DateWidget) |
251 | + custom_widget_licenses = CustomWidgetFactory( |
252 | + CheckBoxMatrixWidget, column_count=4, orientation='vertical') |
253 | + custom_widget_active = CustomWidgetFactory( |
254 | + LaunchpadRadioWidget, _messageNoValue="(do not filter)") |
255 | + custom_widget_project_reviewed = CustomWidgetFactory( |
256 | + LaunchpadRadioWidget, _messageNoValue="(do not filter)") |
257 | + custom_widget_license_approved = CustomWidgetFactory( |
258 | + LaunchpadRadioWidget, _messageNoValue="(do not filter)") |
259 | + custom_widget_has_subscription = CustomWidgetFactory( |
260 | + LaunchpadRadioWidget, _messageNoValue="(do not filter)") |
261 | + custom_widget_created_after = DateWidget |
262 | + custom_widget_created_before = DateWidget |
263 | + custom_widget_subscription_expires_after = DateWidget |
264 | + custom_widget_subscription_expires_before = DateWidget |
265 | + custom_widget_subscription_modified_after = DateWidget |
266 | + custom_widget_subscription_modified_before = DateWidget |
267 | |
268 | @property |
269 | def left_side_widgets(self): |
270 | @@ -2296,8 +2296,9 @@ |
271 | template = ViewPageTemplateFile('../templates/product-new.pt') |
272 | page_title = "Register a project in Launchpad" |
273 | |
274 | - custom_widget('display_name', TextWidget, displayWidth=50, label='Name') |
275 | - custom_widget('name', ProductNameWidget, label='URL') |
276 | + custom_widget_display_name = CustomWidgetFactory( |
277 | + TextWidget, displayWidth=50, label='Name') |
278 | + custom_widget_name = CustomWidgetFactory(ProductNameWidget, label='URL') |
279 | |
280 | step_description = 'Project basics' |
281 | search_results_count = 0 |
282 | @@ -2355,27 +2356,28 @@ |
283 | |
284 | product = None |
285 | |
286 | - custom_widget('display_name', TextWidget, displayWidth=50, label='Name') |
287 | - custom_widget('name', ProductNameWidget, label='URL') |
288 | - custom_widget('homepageurl', TextWidget, displayWidth=30) |
289 | - custom_widget('licenses', LicenseWidget) |
290 | - custom_widget('license_info', GhostWidget) |
291 | - custom_widget( |
292 | - 'information_type', |
293 | + custom_widget_display_name = CustomWidgetFactory( |
294 | + TextWidget, displayWidth=50, label='Name') |
295 | + custom_widget_name = CustomWidgetFactory(ProductNameWidget, label='URL') |
296 | + custom_widget_homepageurl = CustomWidgetFactory( |
297 | + TextWidget, displayWidth=30) |
298 | + custom_widget_licenses = LicenseWidget |
299 | + custom_widget_license_info = GhostWidget |
300 | + custom_widget_information_type = CustomWidgetFactory( |
301 | LaunchpadRadioWidgetWithDescription, |
302 | vocabulary=InformationTypeVocabulary(types=PILLAR_INFORMATION_TYPES)) |
303 | |
304 | - custom_widget( |
305 | - 'owner', PersonPickerWidget, header="Select the maintainer", |
306 | + custom_widget_owner = CustomWidgetFactory( |
307 | + PersonPickerWidget, header="Select the maintainer", |
308 | show_create_team_link=True) |
309 | - custom_widget( |
310 | - 'bug_supervisor', PersonPickerWidget, header="Set a bug supervisor", |
311 | - required=True, show_create_team_link=True) |
312 | - custom_widget( |
313 | - 'driver', PersonPickerWidget, header="Set a driver", |
314 | - required=True, show_create_team_link=True) |
315 | - custom_widget( |
316 | - 'disclaim_maintainer', CheckBoxWidget, cssClass="subordinate") |
317 | + custom_widget_bug_supervisor = CustomWidgetFactory( |
318 | + PersonPickerWidget, header="Set a bug supervisor", |
319 | + required=True, show_create_team_link=True) |
320 | + custom_widget_driver = CustomWidgetFactory( |
321 | + PersonPickerWidget, header="Set a driver", |
322 | + required=True, show_create_team_link=True) |
323 | + custom_widget_disclaim_maintainer = CustomWidgetFactory( |
324 | + CheckBoxWidget, cssClass="subordinate") |
325 | |
326 | def initialize(self): |
327 | # The JSON cache must be populated before the super call, since |
328 | @@ -2656,12 +2658,14 @@ |
329 | # failing. |
330 | initial_values = {'transfer_to_registry': False} |
331 | |
332 | - custom_widget('owner', PersonPickerWidget, header="Select the maintainer", |
333 | - show_create_team_link=True) |
334 | - custom_widget('transfer_to_registry', CheckBoxWidget, |
335 | - widget_class='field subordinate') |
336 | - custom_widget('driver', PersonPickerWidget, header="Select the driver", |
337 | - show_create_team_link=True) |
338 | + custom_widget_owner = CustomWidgetFactory( |
339 | + PersonPickerWidget, header="Select the maintainer", |
340 | + show_create_team_link=True) |
341 | + custom_widget_transfer_to_registry = CustomWidgetFactory( |
342 | + CheckBoxWidget, widget_class='field subordinate') |
343 | + custom_widget_driver = CustomWidgetFactory( |
344 | + PersonPickerWidget, header="Select the driver", |
345 | + show_create_team_link=True) |
346 | |
347 | @property |
348 | def page_title(self): |
349 | |
350 | === modified file 'lib/lp/registry/browser/productrelease.py' |
351 | --- lib/lp/registry/browser/productrelease.py 2015-02-01 22:42:13 +0000 |
352 | +++ lib/lp/registry/browser/productrelease.py 2018-08-31 11:41:19 +0000 |
353 | @@ -1,4 +1,4 @@ |
354 | -# Copyright 2009-2011 Canonical Ltd. This software is licensed under the |
355 | +# Copyright 2009-2018 Canonical Ltd. This software is licensed under the |
356 | # GNU Affero General Public License version 3 (see the file LICENSE). |
357 | |
358 | __metaclass__ = type |
359 | @@ -21,6 +21,7 @@ |
360 | from z3c.ptcompat import ViewPageTemplateFile |
361 | from zope.event import notify |
362 | from zope.formlib.form import FormFields |
363 | +from zope.formlib.widget import CustomWidgetFactory |
364 | from zope.formlib.widgets import ( |
365 | TextAreaWidget, |
366 | TextWidget, |
367 | @@ -35,7 +36,6 @@ |
368 | from lp import _ |
369 | from lp.app.browser.launchpadform import ( |
370 | action, |
371 | - custom_widget, |
372 | LaunchpadEditFormView, |
373 | LaunchpadFormView, |
374 | ) |
375 | @@ -107,9 +107,11 @@ |
376 | """ |
377 | schema = IProductRelease |
378 | |
379 | - custom_widget('datereleased', DateTimeWidget) |
380 | - custom_widget('release_notes', TextAreaWidget, height=7, width=62) |
381 | - custom_widget('changelog', TextAreaWidget, height=7, width=62) |
382 | + custom_widget_datereleased = DateTimeWidget |
383 | + custom_widget_release_notes = CustomWidgetFactory( |
384 | + TextAreaWidget, height=7, width=62) |
385 | + custom_widget_changelog = CustomWidgetFactory( |
386 | + TextAreaWidget, height=7, width=62) |
387 | |
388 | def _prependKeepMilestoneActiveField(self): |
389 | keep_milestone_active_checkbox = FormFields( |
390 | @@ -227,9 +229,11 @@ |
391 | "changelog", |
392 | ] |
393 | |
394 | - custom_widget('datereleased', DateTimeWidget) |
395 | - custom_widget('release_notes', TextAreaWidget, height=7, width=62) |
396 | - custom_widget('changelog', TextAreaWidget, height=7, width=62) |
397 | + custom_widget_datereleased = DateTimeWidget |
398 | + custom_widget_release_notes = CustomWidgetFactory( |
399 | + TextAreaWidget, height=7, width=62) |
400 | + custom_widget_changelog = CustomWidgetFactory( |
401 | + TextAreaWidget, height=7, width=62) |
402 | |
403 | @property |
404 | def label(self): |
405 | @@ -265,7 +269,8 @@ |
406 | """A view for adding a file to an `IProductRelease`.""" |
407 | schema = IProductReleaseFileAddForm |
408 | |
409 | - custom_widget('description', TextWidget, displayWidth=60) |
410 | + custom_widget_description = CustomWidgetFactory( |
411 | + TextWidget, displayWidth=60) |
412 | |
413 | @property |
414 | def label(self): |
415 | |
416 | === modified file 'lib/lp/registry/browser/productseries.py' |
417 | --- lib/lp/registry/browser/productseries.py 2016-09-19 13:44:28 +0000 |
418 | +++ lib/lp/registry/browser/productseries.py 2018-08-31 11:41:19 +0000 |
419 | @@ -1,4 +1,4 @@ |
420 | -# Copyright 2009-2016 Canonical Ltd. This software is licensed under the |
421 | +# Copyright 2009-2018 Canonical Ltd. This software is licensed under the |
422 | # GNU Affero General Public License version 3 (see the file LICENSE). |
423 | |
424 | """View classes for `IProductSeries`.""" |
425 | @@ -32,6 +32,7 @@ |
426 | from z3c.ptcompat import ViewPageTemplateFile |
427 | from zope.component import getUtility |
428 | from zope.formlib import form |
429 | +from zope.formlib.widget import CustomWidgetFactory |
430 | from zope.formlib.widgets import ( |
431 | TextAreaWidget, |
432 | TextWidget, |
433 | @@ -50,7 +51,6 @@ |
434 | from lp.app.browser.informationtype import InformationTypePortletMixin |
435 | from lp.app.browser.launchpadform import ( |
436 | action, |
437 | - custom_widget, |
438 | LaunchpadEditFormView, |
439 | LaunchpadFormView, |
440 | ) |
441 | @@ -502,7 +502,7 @@ |
442 | return IPackaging |
443 | |
444 | field_names = ['sourcepackagename', 'distroseries'] |
445 | - custom_widget('sourcepackagename', UbuntuSourcePackageNameWidget) |
446 | + custom_widget_sourcepackagename = UbuntuSourcePackageNameWidget |
447 | page_title = 'Ubuntu source packaging' |
448 | label = page_title |
449 | |
450 | @@ -636,8 +636,10 @@ |
451 | schema = IProductSeries |
452 | field_names = [ |
453 | 'name', 'summary', 'status', 'branch', 'releasefileglob'] |
454 | - custom_widget('summary', TextAreaWidget, height=7, width=62) |
455 | - custom_widget('releasefileglob', StrippedTextWidget, displayWidth=40) |
456 | + custom_widget_summary = CustomWidgetFactory( |
457 | + TextAreaWidget, height=7, width=62) |
458 | + custom_widget_releasefileglob = CustomWidgetFactory( |
459 | + StrippedTextWidget, displayWidth=40) |
460 | |
461 | @property |
462 | def label(self): |
463 | @@ -797,7 +799,7 @@ |
464 | """A view to review and change the series `IProduct` and name.""" |
465 | schema = IProductSeries |
466 | field_names = ['product', 'name'] |
467 | - custom_widget('name', TextWidget, displayWidth=20) |
468 | + custom_widget_name = CustomWidgetFactory(TextWidget, displayWidth=20) |
469 | |
470 | @property |
471 | def label(self): |
472 | |
473 | === modified file 'lib/lp/registry/browser/project.py' |
474 | --- lib/lp/registry/browser/project.py 2015-10-01 17:32:41 +0000 |
475 | +++ lib/lp/registry/browser/project.py 2018-08-31 11:41:19 +0000 |
476 | @@ -1,4 +1,4 @@ |
477 | -# Copyright 2009-2011 Canonical Ltd. This software is licensed under the |
478 | +# Copyright 2009-2018 Canonical Ltd. This software is licensed under the |
479 | # GNU Affero General Public License version 3 (see the file LICENSE). |
480 | |
481 | """Project-related View Classes""" |
482 | @@ -35,6 +35,7 @@ |
483 | from zope.component import getUtility |
484 | from zope.event import notify |
485 | from zope.formlib import form |
486 | +from zope.formlib.widget import CustomWidgetFactory |
487 | from zope.formlib.widgets import TextWidget |
488 | from zope.interface import ( |
489 | implementer, |
490 | @@ -48,7 +49,6 @@ |
491 | from lp.answers.browser.questiontarget import QuestionCollectionAnswersMenu |
492 | from lp.app.browser.launchpadform import ( |
493 | action, |
494 | - custom_widget, |
495 | LaunchpadEditFormView, |
496 | LaunchpadFormView, |
497 | ) |
498 | @@ -585,7 +585,8 @@ |
499 | 'owner', |
500 | 'homepageurl', |
501 | ] |
502 | - custom_widget('homepageurl', TextWidget, displayWidth=30) |
503 | + custom_widget_homepageurl = CustomWidgetFactory( |
504 | + TextWidget, displayWidth=30) |
505 | label = _('Register a project group with Launchpad') |
506 | page_title = label |
507 | projectgroup = None |
508 | |
509 | === modified file 'lib/lp/registry/browser/sourcepackage.py' |
510 | --- lib/lp/registry/browser/sourcepackage.py 2016-02-05 15:16:29 +0000 |
511 | +++ lib/lp/registry/browser/sourcepackage.py 2018-08-31 11:41:19 +0000 |
512 | @@ -1,4 +1,4 @@ |
513 | -# Copyright 2009-2012 Canonical Ltd. This software is licensed under the |
514 | +# Copyright 2009-2018 Canonical Ltd. This software is licensed under the |
515 | # GNU Affero General Public License version 3 (see the file LICENSE). |
516 | |
517 | """Browser views for sourcepackages.""" |
518 | @@ -37,6 +37,7 @@ |
519 | ) |
520 | from zope.formlib.form import Fields |
521 | from zope.formlib.interfaces import IInputWidget |
522 | +from zope.formlib.widget import CustomWidgetFactory |
523 | from zope.formlib.widgets import DropdownWidget |
524 | from zope.interface import Interface |
525 | from zope.schema import ( |
526 | @@ -52,7 +53,6 @@ |
527 | from lp import _ |
528 | from lp.app.browser.launchpadform import ( |
529 | action, |
530 | - custom_widget, |
531 | LaunchpadFormView, |
532 | ReturnToReferrerMixin, |
533 | ) |
534 | @@ -316,8 +316,8 @@ |
535 | # The DropdownWidget is used, since the VocabularyPickerWidget |
536 | # does not support visible=False to turn it into a hidden input |
537 | # to continue passing the variable in the form. |
538 | - custom_widget('product', DropdownWidget, visible=False) |
539 | - custom_widget('productseries', LaunchpadRadioWidget) |
540 | + custom_widget_product = CustomWidgetFactory(DropdownWidget, visible=False) |
541 | + custom_widget_productseries = LaunchpadRadioWidget |
542 | |
543 | def setUpFields(self): |
544 | super(SourcePackageChangeUpstreamStepTwo, self).setUpFields() |
545 | @@ -556,8 +556,8 @@ |
546 | """A view for linking to an upstream package.""" |
547 | |
548 | schema = Interface |
549 | - custom_widget( |
550 | - 'upstream', LaunchpadRadioWidget, orientation='vertical') |
551 | + custom_widget_upstream = CustomWidgetFactory( |
552 | + LaunchpadRadioWidget, orientation='vertical') |
553 | product_suggestions = None |
554 | initial_focus_widget = None |
555 | max_suggestions = 9 |
556 | |
557 | === modified file 'lib/lp/registry/browser/team.py' |
558 | --- lib/lp/registry/browser/team.py 2016-11-15 17:49:49 +0000 |
559 | +++ lib/lp/registry/browser/team.py 2018-08-31 11:41:19 +0000 |
560 | @@ -1,4 +1,4 @@ |
561 | -# Copyright 2009-2016 Canonical Ltd. This software is licensed under the |
562 | +# Copyright 2009-2018 Canonical Ltd. This software is licensed under the |
563 | # GNU Affero General Public License version 3 (see the file LICENSE). |
564 | |
565 | __metaclass__ = type |
566 | @@ -52,6 +52,7 @@ |
567 | FormFields, |
568 | ) |
569 | from zope.formlib.textwidgets import IntWidget |
570 | +from zope.formlib.widget import CustomWidgetFactory |
571 | from zope.formlib.widgets import TextAreaWidget |
572 | from zope.interface import ( |
573 | classImplements, |
574 | @@ -76,7 +77,6 @@ |
575 | from lp.app.browser.badge import HasBadgeBase |
576 | from lp.app.browser.launchpadform import ( |
577 | action, |
578 | - custom_widget, |
579 | LaunchpadFormView, |
580 | ) |
581 | from lp.app.browser.tales import PersonFormatterAPI |
582 | @@ -299,14 +299,14 @@ |
583 | |
584 | page_title = label |
585 | |
586 | - custom_widget( |
587 | - 'renewal_policy', LaunchpadRadioWidget, orientation='vertical') |
588 | - custom_widget('defaultrenewalperiod', IntWidget, |
589 | - widget_class='field subordinate') |
590 | - custom_widget( |
591 | - 'membership_policy', LaunchpadRadioWidgetWithDescription, |
592 | - orientation='vertical') |
593 | - custom_widget('description', TextAreaWidget, height=10, width=30) |
594 | + custom_widget_renewal_policy = CustomWidgetFactory( |
595 | + LaunchpadRadioWidget, orientation='vertical') |
596 | + custom_widget_defaultrenewalperiod = CustomWidgetFactory( |
597 | + IntWidget, widget_class='field subordinate') |
598 | + custom_widget_membership_policy = CustomWidgetFactory( |
599 | + LaunchpadRadioWidgetWithDescription, orientation='vertical') |
600 | + custom_widget_description = CustomWidgetFactory( |
601 | + TextAreaWidget, height=10, width=30) |
602 | |
603 | def setUpFields(self): |
604 | """See `LaunchpadViewForm`.""" |
605 | @@ -442,8 +442,8 @@ |
606 | |
607 | schema = ITeamContactAddressForm |
608 | |
609 | - custom_widget( |
610 | - 'contact_method', LaunchpadRadioWidget, orientation='vertical') |
611 | + custom_widget_contact_method = CustomWidgetFactory( |
612 | + LaunchpadRadioWidget, orientation='vertical') |
613 | |
614 | @property |
615 | def label(self): |
616 | @@ -603,7 +603,8 @@ |
617 | schema = IMailingList |
618 | field_names = ['welcome_message'] |
619 | label = "Mailing list configuration" |
620 | - custom_widget('welcome_message', TextAreaWidget, width=72, height=10) |
621 | + custom_widget_welcome_message = CustomWidgetFactory( |
622 | + TextAreaWidget, width=72, height=10) |
623 | page_title = label |
624 | |
625 | def __init__(self, context, request): |
626 | @@ -1001,14 +1002,13 @@ |
627 | page_title = 'Register a new team in Launchpad' |
628 | label = page_title |
629 | |
630 | - custom_widget('teamowner', HiddenUserWidget) |
631 | - custom_widget( |
632 | - 'renewal_policy', LaunchpadRadioWidget, orientation='vertical') |
633 | - custom_widget( |
634 | - 'membership_policy', LaunchpadRadioWidgetWithDescription, |
635 | - orientation='vertical') |
636 | - custom_widget('defaultrenewalperiod', IntWidget, |
637 | - widget_class='field subordinate') |
638 | + custom_widget_teamowner = HiddenUserWidget |
639 | + custom_widget_renewal_policy = CustomWidgetFactory( |
640 | + LaunchpadRadioWidget, orientation='vertical') |
641 | + custom_widget_membership_policy = CustomWidgetFactory( |
642 | + LaunchpadRadioWidgetWithDescription, orientation='vertical') |
643 | + custom_widget_defaultrenewalperiod = CustomWidgetFactory( |
644 | + IntWidget, widget_class='field subordinate') |
645 | |
646 | def setUpFields(self): |
647 | """See `LaunchpadViewForm`. |
648 | @@ -1073,9 +1073,8 @@ |
649 | |
650 | # Use a dropdown - Javascript will be used to change this to a choice |
651 | # popup widget. |
652 | - custom_widget( |
653 | - 'membership_policy', LaunchpadDropdownWidget, |
654 | - orientation='vertical') |
655 | + custom_widget_membership_policy = CustomWidgetFactory( |
656 | + LaunchpadDropdownWidget, orientation='vertical') |
657 | |
658 | |
659 | class ProposedTeamMembersEditView(LaunchpadFormView): |
660 | @@ -1164,8 +1163,8 @@ |
661 | # below should be changed to the more appropriate False bool when we're |
662 | # making use of the JSON cache to setup pickers, rather than assembling |
663 | # javascript in a view macro. |
664 | - custom_widget( |
665 | - 'newmember', PersonPickerWidget, |
666 | + custom_widget_newmember = CustomWidgetFactory( |
667 | + PersonPickerWidget, |
668 | show_assign_me_button='false', show_remove_button='false') |
669 | |
670 | @property |
671 | @@ -1362,7 +1361,8 @@ |
672 | __name__ = '+invitation' |
673 | schema = ITeamMembershipInvitationAcknowledgementForm |
674 | field_names = ['acknowledger_comment'] |
675 | - custom_widget('acknowledger_comment', TextAreaWidget, height=5, width=60) |
676 | + custom_widget_acknowledger_comment = CustomWidgetFactory( |
677 | + TextAreaWidget, height=5, width=60) |
678 | template = ViewPageTemplateFile( |
679 | '../templates/teammembership-invitation.pt') |
680 | |
681 | @@ -1893,7 +1893,7 @@ |
682 | """Propose/add to this team any team that you're an administrator of.""" |
683 | |
684 | page_title = 'Propose/add one of your teams to another one' |
685 | - custom_widget('teams', LabeledMultiCheckBoxWidget) |
686 | + custom_widget_teams = LabeledMultiCheckBoxWidget |
687 | |
688 | def initialize(self): |
689 | context = self.context |
690 | |
691 | === modified file 'lib/lp/registry/doc/product-widgets.txt' |
692 | --- lib/lp/registry/doc/product-widgets.txt 2017-10-21 18:14:14 +0000 |
693 | +++ lib/lp/registry/doc/product-widgets.txt 2018-08-31 11:41:19 +0000 |
694 | @@ -403,8 +403,7 @@ |
695 | |
696 | >>> from lp.services.config import config |
697 | >>> from z3c.ptcompat import ViewPageTemplateFile |
698 | - >>> from lp.app.browser.launchpadform import ( |
699 | - ... custom_widget, LaunchpadFormView) |
700 | + >>> from lp.app.browser.launchpadform import LaunchpadFormView |
701 | |
702 | >>> class GhostWidgetView(LaunchpadFormView): |
703 | ... page_title = 'Test' |
704 | @@ -412,7 +411,7 @@ |
705 | ... config.root + '/lib/lp/app/templates/generic-edit.pt') |
706 | ... schema = IProduct |
707 | ... field_names = ['license_info'] |
708 | - ... custom_widget('license_info', GhostWidget) |
709 | + ... custom_widget_license_info = GhostWidget |
710 | |
711 | >>> request = LaunchpadTestRequest() |
712 | >>> request.setPrincipal(factory.makePerson()) |