Merge lp:~cjwatson/launchpad/custom-widget-no-class-advice-4 into lp:launchpad

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
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).

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
=== modified file 'lib/lp/registry/browser/person.py'
--- lib/lp/registry/browser/person.py 2018-05-18 14:07:28 +0000
+++ lib/lp/registry/browser/person.py 2018-08-31 11:41:19 +0000
@@ -74,6 +74,7 @@
74from zope.error.interfaces import IErrorReportingUtility74from zope.error.interfaces import IErrorReportingUtility
75from zope.formlib import form75from zope.formlib import form
76from zope.formlib.form import FormFields76from zope.formlib.form import FormFields
77from zope.formlib.widget import CustomWidgetFactory
77from zope.formlib.widgets import (78from zope.formlib.widgets import (
78 TextAreaWidget,79 TextAreaWidget,
79 TextWidget,80 TextWidget,
@@ -101,7 +102,6 @@
101from lp import _102from lp import _
102from lp.app.browser.launchpadform import (103from lp.app.browser.launchpadform import (
103 action,104 action,
104 custom_widget,
105 LaunchpadEditFormView,105 LaunchpadEditFormView,
106 LaunchpadFormView,106 LaunchpadFormView,
107 )107 )
@@ -1041,7 +1041,8 @@
10411041
1042 schema = DeactivateAccountSchema1042 schema = DeactivateAccountSchema
1043 label = "Deactivate your Launchpad account"1043 label = "Deactivate your Launchpad account"
1044 custom_widget('comment', TextAreaWidget, height=5, width=60)1044 custom_widget_comment = CustomWidgetFactory(
1045 TextAreaWidget, height=5, width=60)
10451046
1046 def validate(self, data):1047 def validate(self, data):
1047 """See `LaunchpadFormView`."""1048 """See `LaunchpadFormView`."""
@@ -1238,8 +1239,8 @@
1238 'personal_standing', 'personal_standing_reason',1239 'personal_standing', 'personal_standing_reason',
1239 'require_strong_email_authentication',1240 'require_strong_email_authentication',
1240 ]1241 ]
1241 custom_widget(1242 custom_widget_personal_standing_reason = CustomWidgetFactory(
1242 'personal_standing_reason', TextAreaWidget, height=5, width=60)1243 TextAreaWidget, height=5, width=60)
12431244
1244 @property1245 @property
1245 def is_viewing_person(self):1246 def is_viewing_person(self):
@@ -1278,7 +1279,8 @@
1278 schema = IAccountAdministerSchema1279 schema = IAccountAdministerSchema
1279 label = "Review person's account"1280 label = "Review person's account"
1280 field_names = ['status', 'comment']1281 field_names = ['status', 'comment']
1281 custom_widget('comment', TextAreaWidget, height=5, width=60)1282 custom_widget_comment = CustomWidgetFactory(
1283 TextAreaWidget, height=5, width=60)
12821284
1283 def __init__(self, context, request):1285 def __init__(self, context, request):
1284 """See `LaunchpadEditFormView`."""1286 """See `LaunchpadEditFormView`."""
@@ -1351,7 +1353,7 @@
1351class PersonVouchersView(LaunchpadFormView):1353class PersonVouchersView(LaunchpadFormView):
1352 """Form for displaying and redeeming commercial subscription vouchers."""1354 """Form for displaying and redeeming commercial subscription vouchers."""
13531355
1354 custom_widget('voucher', LaunchpadDropdownWidget)1356 custom_widget_voucher = LaunchpadDropdownWidget
13551357
1356 @property1358 @property
1357 def page_title(self):1359 def page_title(self):
@@ -2705,7 +2707,8 @@
2705 'hide_email_addresses', 'verbose_bugnotifications',2707 'hide_email_addresses', 'verbose_bugnotifications',
2706 'selfgenerated_bugnotifications',2708 'selfgenerated_bugnotifications',
2707 'expanded_notification_footers']2709 'expanded_notification_footers']
2708 custom_widget('mugshot', ImageChangeWidget, ImageChangeWidget.EDIT_STYLE)2710 custom_widget_mugshot = CustomWidgetFactory(
2711 ImageChangeWidget, ImageChangeWidget.EDIT_STYLE)
27092712
2710 label = 'Change your personal details'2713 label = 'Change your personal details'
2711 page_title = label2714 page_title = label
@@ -2775,10 +2778,10 @@
27752778
2776 schema = IEmailAddress2779 schema = IEmailAddress
27772780
2778 custom_widget('VALIDATED_SELECTED', LaunchpadRadioWidget,2781 custom_widget_VALIDATED_SELECTED = CustomWidgetFactory(
2779 orientation='vertical')2782 LaunchpadRadioWidget, orientation='vertical')
2780 custom_widget('UNVALIDATED_SELECTED', LaunchpadRadioWidget,2783 custom_widget_UNVALIDATED_SELECTED = CustomWidgetFactory(
2781 orientation='vertical')2784 LaunchpadRadioWidget, orientation='vertical')
27822785
2783 label = 'Change your email settings'2786 label = 'Change your email settings'
27842787
@@ -2840,8 +2843,7 @@
2840 Choice(__name__='VALIDATED_SELECTED',2843 Choice(__name__='VALIDATED_SELECTED',
2841 title=_('These addresses are confirmed as being yours'),2844 title=_('These addresses are confirmed as being yours'),
2842 source=SimpleVocabulary(terms),2845 source=SimpleVocabulary(terms),
2843 ),2846 ))
2844 custom_widget=self.custom_widgets['VALIDATED_SELECTED'])
28452847
2846 def _unvalidated_emails_field(self):2848 def _unvalidated_emails_field(self):
2847 """Create a field with a vocabulary of unvalidated and guessed emails.2849 """Create a field with a vocabulary of unvalidated and guessed emails.
@@ -2862,8 +2864,7 @@
28622864
2863 return FormFields(2865 return FormFields(
2864 Choice(__name__='UNVALIDATED_SELECTED', title=title,2866 Choice(__name__='UNVALIDATED_SELECTED', title=title,
2865 source=SimpleVocabulary(terms)),2867 source=SimpleVocabulary(terms)))
2866 custom_widget=self.custom_widgets['UNVALIDATED_SELECTED'])
28672868
2868 def _validate_selected_address(self, data, field='VALIDATED_SELECTED'):2869 def _validate_selected_address(self, data, field='VALIDATED_SELECTED'):
2869 """A generic validator for this view's actions.2870 """A generic validator for this view's actions.
@@ -3104,8 +3105,8 @@
31043105
3105 schema = IEmailAddress3106 schema = IEmailAddress
31063107
3107 custom_widget('mailing_list_auto_subscribe_policy',3108 custom_widget_mailing_list_auto_subscribe_policy = (
3108 LaunchpadRadioWidgetWithDescription)3109 LaunchpadRadioWidgetWithDescription)
31093110
3110 label = 'Change your mailing list subscriptions'3111 label = 'Change your mailing list subscriptions'
31113112
@@ -4016,7 +4017,7 @@
40164017
4017 schema = IEmailToPerson4018 schema = IEmailToPerson
4018 field_names = ['subject', 'message']4019 field_names = ['subject', 'message']
4019 custom_widget('subject', TextWidget, displayWidth=60)4020 custom_widget_subject = CustomWidgetFactory(TextWidget, displayWidth=60)
40204021
4021 def initialize(self):4022 def initialize(self):
4022 """See `ILaunchpadFormView`."""4023 """See `ILaunchpadFormView`."""
40234024
=== modified file 'lib/lp/registry/browser/poll.py'
--- lib/lp/registry/browser/poll.py 2016-01-26 15:47:37 +0000
+++ lib/lp/registry/browser/poll.py 2018-08-31 11:41:19 +0000
@@ -1,4 +1,4 @@
1# Copyright 2009 Canonical Ltd. This software is licensed under the1# Copyright 2009-2018 Canonical Ltd. This software is licensed under the
2# GNU Affero General Public License version 3 (see the file LICENSE).2# GNU Affero General Public License version 3 (see the file LICENSE).
33
4__metaclass__ = type4__metaclass__ = type
@@ -21,6 +21,7 @@
21from z3c.ptcompat import ViewPageTemplateFile21from z3c.ptcompat import ViewPageTemplateFile
22from zope.component import getUtility22from zope.component import getUtility
23from zope.event import notify23from zope.event import notify
24from zope.formlib.widget import CustomWidgetFactory
24from zope.formlib.widgets import TextWidget25from zope.formlib.widgets import TextWidget
25from zope.interface import (26from zope.interface import (
26 implementer,27 implementer,
@@ -30,7 +31,6 @@
3031
31from lp.app.browser.launchpadform import (32from lp.app.browser.launchpadform import (
32 action,33 action,
33 custom_widget,
34 LaunchpadEditFormView,34 LaunchpadEditFormView,
35 LaunchpadFormView,35 LaunchpadFormView,
36 )36 )
@@ -443,7 +443,7 @@
443 label = "Edit option details"443 label = "Edit option details"
444 page_title = 'Edit option'444 page_title = 'Edit option'
445 field_names = ["name", "title"]445 field_names = ["name", "title"]
446 custom_widget("title", TextWidget, displayWidth=30)446 custom_widget_title = CustomWidgetFactory(TextWidget, displayWidth=30)
447447
448 @property448 @property
449 def cancel_url(self):449 def cancel_url(self):
@@ -463,7 +463,7 @@
463 label = "Create new poll option"463 label = "Create new poll option"
464 page_title = "New option"464 page_title = "New option"
465 field_names = ["name", "title"]465 field_names = ["name", "title"]
466 custom_widget("title", TextWidget, displayWidth=30)466 custom_widget_title = CustomWidgetFactory(TextWidget, displayWidth=30)
467467
468 @property468 @property
469 def cancel_url(self):469 def cancel_url(self):
470470
=== modified file 'lib/lp/registry/browser/product.py'
--- lib/lp/registry/browser/product.py 2016-11-15 13:37:38 +0000
+++ lib/lp/registry/browser/product.py 2018-08-31 11:41:19 +0000
@@ -1,4 +1,4 @@
1# Copyright 2009-2016 Canonical Ltd. This software is licensed under the1# Copyright 2009-2018 Canonical Ltd. This software is licensed under the
2# GNU Affero General Public License version 3 (see the file LICENSE).2# GNU Affero General Public License version 3 (see the file LICENSE).
33
4"""Browser views for products."""4"""Browser views for products."""
@@ -82,7 +82,6 @@
82from lp.answers.browser.questiontarget import QuestionTargetTraversalMixin82from lp.answers.browser.questiontarget import QuestionTargetTraversalMixin
83from lp.app.browser.launchpadform import (83from lp.app.browser.launchpadform import (
84 action,84 action,
85 custom_widget,
86 LaunchpadEditFormView,85 LaunchpadEditFormView,
87 LaunchpadFormView,86 LaunchpadFormView,
88 render_radio_widget_part,87 render_radio_widget_part,
@@ -1406,10 +1405,10 @@
1406 "licenses",1405 "licenses",
1407 "license_info",1406 "license_info",
1408 ]1407 ]
1409 custom_widget('licenses', LicenseWidget)1408 custom_widget_licenses = LicenseWidget
1410 custom_widget('license_info', GhostWidget)1409 custom_widget_license_info = GhostWidget
1411 custom_widget(1410 custom_widget_information_type = CustomWidgetFactory(
1412 'information_type', LaunchpadRadioWidgetWithDescription,1411 LaunchpadRadioWidgetWithDescription,
1413 vocabulary=InformationTypeVocabulary(types=PILLAR_INFORMATION_TYPES))1412 vocabulary=InformationTypeVocabulary(types=PILLAR_INFORMATION_TYPES))
14141413
1415 @property1414 @property
@@ -1605,8 +1604,10 @@
16051604
1606 schema = IProductSeries1605 schema = IProductSeries
1607 field_names = ['name', 'summary', 'branch', 'releasefileglob']1606 field_names = ['name', 'summary', 'branch', 'releasefileglob']
1608 custom_widget('summary', TextAreaWidget, height=7, width=62)1607 custom_widget_summary = CustomWidgetFactory(
1609 custom_widget('releasefileglob', StrippedTextWidget, displayWidth=40)1608 TextAreaWidget, height=7, width=62)
1609 custom_widget_releasefileglob = CustomWidgetFactory(
1610 StrippedTextWidget, displayWidth=40)
16101611
1611 series = None1612 series = None
16121613
@@ -1765,10 +1766,10 @@
1765 # upon creation.1766 # upon creation.
1766 for_input = True1767 for_input = True
17671768
1768 custom_widget('rcs_type', LaunchpadRadioWidget)1769 custom_widget_rcs_type = LaunchpadRadioWidget
1769 custom_widget('branch_type', LaunchpadRadioWidget)1770 custom_widget_branch_type = LaunchpadRadioWidget
1770 custom_widget('default_vcs', LaunchpadRadioWidget)1771 custom_widget_default_vcs = LaunchpadRadioWidget
1771 custom_widget('git_repository_type', LaunchpadRadioWidget)1772 custom_widget_git_repository_type = LaunchpadRadioWidget
17721773
1773 errors_in_action = False1774 errors_in_action = False
1774 is_series = False1775 is_series = False
@@ -2219,23 +2220,22 @@
2219 ('subscription_modified_after', 'subscription_modified_before'),2220 ('subscription_modified_after', 'subscription_modified_before'),
2220 ]2221 ]
22212222
2222 custom_widget(2223 custom_widget_licenses = CustomWidgetFactory(
2223 'licenses', CheckBoxMatrixWidget, column_count=4,2224 CheckBoxMatrixWidget, column_count=4, orientation='vertical')
2224 orientation='vertical')2225 custom_widget_active = CustomWidgetFactory(
2225 custom_widget('active', LaunchpadRadioWidget,2226 LaunchpadRadioWidget, _messageNoValue="(do not filter)")
2226 _messageNoValue="(do not filter)")2227 custom_widget_project_reviewed = CustomWidgetFactory(
2227 custom_widget('project_reviewed', LaunchpadRadioWidget,2228 LaunchpadRadioWidget, _messageNoValue="(do not filter)")
2228 _messageNoValue="(do not filter)")2229 custom_widget_license_approved = CustomWidgetFactory(
2229 custom_widget('license_approved', LaunchpadRadioWidget,2230 LaunchpadRadioWidget, _messageNoValue="(do not filter)")
2230 _messageNoValue="(do not filter)")2231 custom_widget_has_subscription = CustomWidgetFactory(
2231 custom_widget('has_subscription', LaunchpadRadioWidget,2232 LaunchpadRadioWidget, _messageNoValue="(do not filter)")
2232 _messageNoValue="(do not filter)")2233 custom_widget_created_after = DateWidget
2233 custom_widget('created_after', DateWidget)2234 custom_widget_created_before = DateWidget
2234 custom_widget('created_before', DateWidget)2235 custom_widget_subscription_expires_after = DateWidget
2235 custom_widget('subscription_expires_after', DateWidget)2236 custom_widget_subscription_expires_before = DateWidget
2236 custom_widget('subscription_expires_before', DateWidget)2237 custom_widget_subscription_modified_after = DateWidget
2237 custom_widget('subscription_modified_after', DateWidget)2238 custom_widget_subscription_modified_before = DateWidget
2238 custom_widget('subscription_modified_before', DateWidget)
22392239
2240 @property2240 @property
2241 def left_side_widgets(self):2241 def left_side_widgets(self):
@@ -2296,8 +2296,9 @@
2296 template = ViewPageTemplateFile('../templates/product-new.pt')2296 template = ViewPageTemplateFile('../templates/product-new.pt')
2297 page_title = "Register a project in Launchpad"2297 page_title = "Register a project in Launchpad"
22982298
2299 custom_widget('display_name', TextWidget, displayWidth=50, label='Name')2299 custom_widget_display_name = CustomWidgetFactory(
2300 custom_widget('name', ProductNameWidget, label='URL')2300 TextWidget, displayWidth=50, label='Name')
2301 custom_widget_name = CustomWidgetFactory(ProductNameWidget, label='URL')
23012302
2302 step_description = 'Project basics'2303 step_description = 'Project basics'
2303 search_results_count = 02304 search_results_count = 0
@@ -2355,27 +2356,28 @@
23552356
2356 product = None2357 product = None
23572358
2358 custom_widget('display_name', TextWidget, displayWidth=50, label='Name')2359 custom_widget_display_name = CustomWidgetFactory(
2359 custom_widget('name', ProductNameWidget, label='URL')2360 TextWidget, displayWidth=50, label='Name')
2360 custom_widget('homepageurl', TextWidget, displayWidth=30)2361 custom_widget_name = CustomWidgetFactory(ProductNameWidget, label='URL')
2361 custom_widget('licenses', LicenseWidget)2362 custom_widget_homepageurl = CustomWidgetFactory(
2362 custom_widget('license_info', GhostWidget)2363 TextWidget, displayWidth=30)
2363 custom_widget(2364 custom_widget_licenses = LicenseWidget
2364 'information_type',2365 custom_widget_license_info = GhostWidget
2366 custom_widget_information_type = CustomWidgetFactory(
2365 LaunchpadRadioWidgetWithDescription,2367 LaunchpadRadioWidgetWithDescription,
2366 vocabulary=InformationTypeVocabulary(types=PILLAR_INFORMATION_TYPES))2368 vocabulary=InformationTypeVocabulary(types=PILLAR_INFORMATION_TYPES))
23672369
2368 custom_widget(2370 custom_widget_owner = CustomWidgetFactory(
2369 'owner', PersonPickerWidget, header="Select the maintainer",2371 PersonPickerWidget, header="Select the maintainer",
2370 show_create_team_link=True)2372 show_create_team_link=True)
2371 custom_widget(2373 custom_widget_bug_supervisor = CustomWidgetFactory(
2372 'bug_supervisor', PersonPickerWidget, header="Set a bug supervisor",2374 PersonPickerWidget, header="Set a bug supervisor",
2373 required=True, show_create_team_link=True)2375 required=True, show_create_team_link=True)
2374 custom_widget(2376 custom_widget_driver = CustomWidgetFactory(
2375 'driver', PersonPickerWidget, header="Set a driver",2377 PersonPickerWidget, header="Set a driver",
2376 required=True, show_create_team_link=True)2378 required=True, show_create_team_link=True)
2377 custom_widget(2379 custom_widget_disclaim_maintainer = CustomWidgetFactory(
2378 'disclaim_maintainer', CheckBoxWidget, cssClass="subordinate")2380 CheckBoxWidget, cssClass="subordinate")
23792381
2380 def initialize(self):2382 def initialize(self):
2381 # The JSON cache must be populated before the super call, since2383 # The JSON cache must be populated before the super call, since
@@ -2656,12 +2658,14 @@
2656 # failing.2658 # failing.
2657 initial_values = {'transfer_to_registry': False}2659 initial_values = {'transfer_to_registry': False}
26582660
2659 custom_widget('owner', PersonPickerWidget, header="Select the maintainer",2661 custom_widget_owner = CustomWidgetFactory(
2660 show_create_team_link=True)2662 PersonPickerWidget, header="Select the maintainer",
2661 custom_widget('transfer_to_registry', CheckBoxWidget,2663 show_create_team_link=True)
2662 widget_class='field subordinate')2664 custom_widget_transfer_to_registry = CustomWidgetFactory(
2663 custom_widget('driver', PersonPickerWidget, header="Select the driver",2665 CheckBoxWidget, widget_class='field subordinate')
2664 show_create_team_link=True)2666 custom_widget_driver = CustomWidgetFactory(
2667 PersonPickerWidget, header="Select the driver",
2668 show_create_team_link=True)
26652669
2666 @property2670 @property
2667 def page_title(self):2671 def page_title(self):
26682672
=== modified file 'lib/lp/registry/browser/productrelease.py'
--- lib/lp/registry/browser/productrelease.py 2015-02-01 22:42:13 +0000
+++ lib/lp/registry/browser/productrelease.py 2018-08-31 11:41:19 +0000
@@ -1,4 +1,4 @@
1# Copyright 2009-2011 Canonical Ltd. This software is licensed under the1# Copyright 2009-2018 Canonical Ltd. This software is licensed under the
2# GNU Affero General Public License version 3 (see the file LICENSE).2# GNU Affero General Public License version 3 (see the file LICENSE).
33
4__metaclass__ = type4__metaclass__ = type
@@ -21,6 +21,7 @@
21from z3c.ptcompat import ViewPageTemplateFile21from z3c.ptcompat import ViewPageTemplateFile
22from zope.event import notify22from zope.event import notify
23from zope.formlib.form import FormFields23from zope.formlib.form import FormFields
24from zope.formlib.widget import CustomWidgetFactory
24from zope.formlib.widgets import (25from zope.formlib.widgets import (
25 TextAreaWidget,26 TextAreaWidget,
26 TextWidget,27 TextWidget,
@@ -35,7 +36,6 @@
35from lp import _36from lp import _
36from lp.app.browser.launchpadform import (37from lp.app.browser.launchpadform import (
37 action,38 action,
38 custom_widget,
39 LaunchpadEditFormView,39 LaunchpadEditFormView,
40 LaunchpadFormView,40 LaunchpadFormView,
41 )41 )
@@ -107,9 +107,11 @@
107 """107 """
108 schema = IProductRelease108 schema = IProductRelease
109109
110 custom_widget('datereleased', DateTimeWidget)110 custom_widget_datereleased = DateTimeWidget
111 custom_widget('release_notes', TextAreaWidget, height=7, width=62)111 custom_widget_release_notes = CustomWidgetFactory(
112 custom_widget('changelog', TextAreaWidget, height=7, width=62)112 TextAreaWidget, height=7, width=62)
113 custom_widget_changelog = CustomWidgetFactory(
114 TextAreaWidget, height=7, width=62)
113115
114 def _prependKeepMilestoneActiveField(self):116 def _prependKeepMilestoneActiveField(self):
115 keep_milestone_active_checkbox = FormFields(117 keep_milestone_active_checkbox = FormFields(
@@ -227,9 +229,11 @@
227 "changelog",229 "changelog",
228 ]230 ]
229231
230 custom_widget('datereleased', DateTimeWidget)232 custom_widget_datereleased = DateTimeWidget
231 custom_widget('release_notes', TextAreaWidget, height=7, width=62)233 custom_widget_release_notes = CustomWidgetFactory(
232 custom_widget('changelog', TextAreaWidget, height=7, width=62)234 TextAreaWidget, height=7, width=62)
235 custom_widget_changelog = CustomWidgetFactory(
236 TextAreaWidget, height=7, width=62)
233237
234 @property238 @property
235 def label(self):239 def label(self):
@@ -265,7 +269,8 @@
265 """A view for adding a file to an `IProductRelease`."""269 """A view for adding a file to an `IProductRelease`."""
266 schema = IProductReleaseFileAddForm270 schema = IProductReleaseFileAddForm
267271
268 custom_widget('description', TextWidget, displayWidth=60)272 custom_widget_description = CustomWidgetFactory(
273 TextWidget, displayWidth=60)
269274
270 @property275 @property
271 def label(self):276 def label(self):
272277
=== modified file 'lib/lp/registry/browser/productseries.py'
--- lib/lp/registry/browser/productseries.py 2016-09-19 13:44:28 +0000
+++ lib/lp/registry/browser/productseries.py 2018-08-31 11:41:19 +0000
@@ -1,4 +1,4 @@
1# Copyright 2009-2016 Canonical Ltd. This software is licensed under the1# Copyright 2009-2018 Canonical Ltd. This software is licensed under the
2# GNU Affero General Public License version 3 (see the file LICENSE).2# GNU Affero General Public License version 3 (see the file LICENSE).
33
4"""View classes for `IProductSeries`."""4"""View classes for `IProductSeries`."""
@@ -32,6 +32,7 @@
32from z3c.ptcompat import ViewPageTemplateFile32from z3c.ptcompat import ViewPageTemplateFile
33from zope.component import getUtility33from zope.component import getUtility
34from zope.formlib import form34from zope.formlib import form
35from zope.formlib.widget import CustomWidgetFactory
35from zope.formlib.widgets import (36from zope.formlib.widgets import (
36 TextAreaWidget,37 TextAreaWidget,
37 TextWidget,38 TextWidget,
@@ -50,7 +51,6 @@
50from lp.app.browser.informationtype import InformationTypePortletMixin51from lp.app.browser.informationtype import InformationTypePortletMixin
51from lp.app.browser.launchpadform import (52from lp.app.browser.launchpadform import (
52 action,53 action,
53 custom_widget,
54 LaunchpadEditFormView,54 LaunchpadEditFormView,
55 LaunchpadFormView,55 LaunchpadFormView,
56 )56 )
@@ -502,7 +502,7 @@
502 return IPackaging502 return IPackaging
503503
504 field_names = ['sourcepackagename', 'distroseries']504 field_names = ['sourcepackagename', 'distroseries']
505 custom_widget('sourcepackagename', UbuntuSourcePackageNameWidget)505 custom_widget_sourcepackagename = UbuntuSourcePackageNameWidget
506 page_title = 'Ubuntu source packaging'506 page_title = 'Ubuntu source packaging'
507 label = page_title507 label = page_title
508508
@@ -636,8 +636,10 @@
636 schema = IProductSeries636 schema = IProductSeries
637 field_names = [637 field_names = [
638 'name', 'summary', 'status', 'branch', 'releasefileglob']638 'name', 'summary', 'status', 'branch', 'releasefileglob']
639 custom_widget('summary', TextAreaWidget, height=7, width=62)639 custom_widget_summary = CustomWidgetFactory(
640 custom_widget('releasefileglob', StrippedTextWidget, displayWidth=40)640 TextAreaWidget, height=7, width=62)
641 custom_widget_releasefileglob = CustomWidgetFactory(
642 StrippedTextWidget, displayWidth=40)
641643
642 @property644 @property
643 def label(self):645 def label(self):
@@ -797,7 +799,7 @@
797 """A view to review and change the series `IProduct` and name."""799 """A view to review and change the series `IProduct` and name."""
798 schema = IProductSeries800 schema = IProductSeries
799 field_names = ['product', 'name']801 field_names = ['product', 'name']
800 custom_widget('name', TextWidget, displayWidth=20)802 custom_widget_name = CustomWidgetFactory(TextWidget, displayWidth=20)
801803
802 @property804 @property
803 def label(self):805 def label(self):
804806
=== modified file 'lib/lp/registry/browser/project.py'
--- lib/lp/registry/browser/project.py 2015-10-01 17:32:41 +0000
+++ lib/lp/registry/browser/project.py 2018-08-31 11:41:19 +0000
@@ -1,4 +1,4 @@
1# Copyright 2009-2011 Canonical Ltd. This software is licensed under the1# Copyright 2009-2018 Canonical Ltd. This software is licensed under the
2# GNU Affero General Public License version 3 (see the file LICENSE).2# GNU Affero General Public License version 3 (see the file LICENSE).
33
4"""Project-related View Classes"""4"""Project-related View Classes"""
@@ -35,6 +35,7 @@
35from zope.component import getUtility35from zope.component import getUtility
36from zope.event import notify36from zope.event import notify
37from zope.formlib import form37from zope.formlib import form
38from zope.formlib.widget import CustomWidgetFactory
38from zope.formlib.widgets import TextWidget39from zope.formlib.widgets import TextWidget
39from zope.interface import (40from zope.interface import (
40 implementer,41 implementer,
@@ -48,7 +49,6 @@
48from lp.answers.browser.questiontarget import QuestionCollectionAnswersMenu49from lp.answers.browser.questiontarget import QuestionCollectionAnswersMenu
49from lp.app.browser.launchpadform import (50from lp.app.browser.launchpadform import (
50 action,51 action,
51 custom_widget,
52 LaunchpadEditFormView,52 LaunchpadEditFormView,
53 LaunchpadFormView,53 LaunchpadFormView,
54 )54 )
@@ -585,7 +585,8 @@
585 'owner',585 'owner',
586 'homepageurl',586 'homepageurl',
587 ]587 ]
588 custom_widget('homepageurl', TextWidget, displayWidth=30)588 custom_widget_homepageurl = CustomWidgetFactory(
589 TextWidget, displayWidth=30)
589 label = _('Register a project group with Launchpad')590 label = _('Register a project group with Launchpad')
590 page_title = label591 page_title = label
591 projectgroup = None592 projectgroup = None
592593
=== modified file 'lib/lp/registry/browser/sourcepackage.py'
--- lib/lp/registry/browser/sourcepackage.py 2016-02-05 15:16:29 +0000
+++ lib/lp/registry/browser/sourcepackage.py 2018-08-31 11:41:19 +0000
@@ -1,4 +1,4 @@
1# Copyright 2009-2012 Canonical Ltd. This software is licensed under the1# Copyright 2009-2018 Canonical Ltd. This software is licensed under the
2# GNU Affero General Public License version 3 (see the file LICENSE).2# GNU Affero General Public License version 3 (see the file LICENSE).
33
4"""Browser views for sourcepackages."""4"""Browser views for sourcepackages."""
@@ -37,6 +37,7 @@
37 )37 )
38from zope.formlib.form import Fields38from zope.formlib.form import Fields
39from zope.formlib.interfaces import IInputWidget39from zope.formlib.interfaces import IInputWidget
40from zope.formlib.widget import CustomWidgetFactory
40from zope.formlib.widgets import DropdownWidget41from zope.formlib.widgets import DropdownWidget
41from zope.interface import Interface42from zope.interface import Interface
42from zope.schema import (43from zope.schema import (
@@ -52,7 +53,6 @@
52from lp import _53from lp import _
53from lp.app.browser.launchpadform import (54from lp.app.browser.launchpadform import (
54 action,55 action,
55 custom_widget,
56 LaunchpadFormView,56 LaunchpadFormView,
57 ReturnToReferrerMixin,57 ReturnToReferrerMixin,
58 )58 )
@@ -316,8 +316,8 @@
316 # The DropdownWidget is used, since the VocabularyPickerWidget316 # The DropdownWidget is used, since the VocabularyPickerWidget
317 # does not support visible=False to turn it into a hidden input317 # does not support visible=False to turn it into a hidden input
318 # to continue passing the variable in the form.318 # to continue passing the variable in the form.
319 custom_widget('product', DropdownWidget, visible=False)319 custom_widget_product = CustomWidgetFactory(DropdownWidget, visible=False)
320 custom_widget('productseries', LaunchpadRadioWidget)320 custom_widget_productseries = LaunchpadRadioWidget
321321
322 def setUpFields(self):322 def setUpFields(self):
323 super(SourcePackageChangeUpstreamStepTwo, self).setUpFields()323 super(SourcePackageChangeUpstreamStepTwo, self).setUpFields()
@@ -556,8 +556,8 @@
556 """A view for linking to an upstream package."""556 """A view for linking to an upstream package."""
557557
558 schema = Interface558 schema = Interface
559 custom_widget(559 custom_widget_upstream = CustomWidgetFactory(
560 'upstream', LaunchpadRadioWidget, orientation='vertical')560 LaunchpadRadioWidget, orientation='vertical')
561 product_suggestions = None561 product_suggestions = None
562 initial_focus_widget = None562 initial_focus_widget = None
563 max_suggestions = 9563 max_suggestions = 9
564564
=== modified file 'lib/lp/registry/browser/team.py'
--- lib/lp/registry/browser/team.py 2016-11-15 17:49:49 +0000
+++ lib/lp/registry/browser/team.py 2018-08-31 11:41:19 +0000
@@ -1,4 +1,4 @@
1# Copyright 2009-2016 Canonical Ltd. This software is licensed under the1# Copyright 2009-2018 Canonical Ltd. This software is licensed under the
2# GNU Affero General Public License version 3 (see the file LICENSE).2# GNU Affero General Public License version 3 (see the file LICENSE).
33
4__metaclass__ = type4__metaclass__ = type
@@ -52,6 +52,7 @@
52 FormFields,52 FormFields,
53 )53 )
54from zope.formlib.textwidgets import IntWidget54from zope.formlib.textwidgets import IntWidget
55from zope.formlib.widget import CustomWidgetFactory
55from zope.formlib.widgets import TextAreaWidget56from zope.formlib.widgets import TextAreaWidget
56from zope.interface import (57from zope.interface import (
57 classImplements,58 classImplements,
@@ -76,7 +77,6 @@
76from lp.app.browser.badge import HasBadgeBase77from lp.app.browser.badge import HasBadgeBase
77from lp.app.browser.launchpadform import (78from lp.app.browser.launchpadform import (
78 action,79 action,
79 custom_widget,
80 LaunchpadFormView,80 LaunchpadFormView,
81 )81 )
82from lp.app.browser.tales import PersonFormatterAPI82from lp.app.browser.tales import PersonFormatterAPI
@@ -299,14 +299,14 @@
299299
300 page_title = label300 page_title = label
301301
302 custom_widget(302 custom_widget_renewal_policy = CustomWidgetFactory(
303 'renewal_policy', LaunchpadRadioWidget, orientation='vertical')303 LaunchpadRadioWidget, orientation='vertical')
304 custom_widget('defaultrenewalperiod', IntWidget,304 custom_widget_defaultrenewalperiod = CustomWidgetFactory(
305 widget_class='field subordinate')305 IntWidget, widget_class='field subordinate')
306 custom_widget(306 custom_widget_membership_policy = CustomWidgetFactory(
307 'membership_policy', LaunchpadRadioWidgetWithDescription,307 LaunchpadRadioWidgetWithDescription, orientation='vertical')
308 orientation='vertical')308 custom_widget_description = CustomWidgetFactory(
309 custom_widget('description', TextAreaWidget, height=10, width=30)309 TextAreaWidget, height=10, width=30)
310310
311 def setUpFields(self):311 def setUpFields(self):
312 """See `LaunchpadViewForm`."""312 """See `LaunchpadViewForm`."""
@@ -442,8 +442,8 @@
442442
443 schema = ITeamContactAddressForm443 schema = ITeamContactAddressForm
444444
445 custom_widget(445 custom_widget_contact_method = CustomWidgetFactory(
446 'contact_method', LaunchpadRadioWidget, orientation='vertical')446 LaunchpadRadioWidget, orientation='vertical')
447447
448 @property448 @property
449 def label(self):449 def label(self):
@@ -603,7 +603,8 @@
603 schema = IMailingList603 schema = IMailingList
604 field_names = ['welcome_message']604 field_names = ['welcome_message']
605 label = "Mailing list configuration"605 label = "Mailing list configuration"
606 custom_widget('welcome_message', TextAreaWidget, width=72, height=10)606 custom_widget_welcome_message = CustomWidgetFactory(
607 TextAreaWidget, width=72, height=10)
607 page_title = label608 page_title = label
608609
609 def __init__(self, context, request):610 def __init__(self, context, request):
@@ -1001,14 +1002,13 @@
1001 page_title = 'Register a new team in Launchpad'1002 page_title = 'Register a new team in Launchpad'
1002 label = page_title1003 label = page_title
10031004
1004 custom_widget('teamowner', HiddenUserWidget)1005 custom_widget_teamowner = HiddenUserWidget
1005 custom_widget(1006 custom_widget_renewal_policy = CustomWidgetFactory(
1006 'renewal_policy', LaunchpadRadioWidget, orientation='vertical')1007 LaunchpadRadioWidget, orientation='vertical')
1007 custom_widget(1008 custom_widget_membership_policy = CustomWidgetFactory(
1008 'membership_policy', LaunchpadRadioWidgetWithDescription,1009 LaunchpadRadioWidgetWithDescription, orientation='vertical')
1009 orientation='vertical')1010 custom_widget_defaultrenewalperiod = CustomWidgetFactory(
1010 custom_widget('defaultrenewalperiod', IntWidget,1011 IntWidget, widget_class='field subordinate')
1011 widget_class='field subordinate')
10121012
1013 def setUpFields(self):1013 def setUpFields(self):
1014 """See `LaunchpadViewForm`.1014 """See `LaunchpadViewForm`.
@@ -1073,9 +1073,8 @@
10731073
1074 # Use a dropdown - Javascript will be used to change this to a choice1074 # Use a dropdown - Javascript will be used to change this to a choice
1075 # popup widget.1075 # popup widget.
1076 custom_widget(1076 custom_widget_membership_policy = CustomWidgetFactory(
1077 'membership_policy', LaunchpadDropdownWidget,1077 LaunchpadDropdownWidget, orientation='vertical')
1078 orientation='vertical')
10791078
10801079
1081class ProposedTeamMembersEditView(LaunchpadFormView):1080class ProposedTeamMembersEditView(LaunchpadFormView):
@@ -1164,8 +1163,8 @@
1164 # below should be changed to the more appropriate False bool when we're1163 # below should be changed to the more appropriate False bool when we're
1165 # making use of the JSON cache to setup pickers, rather than assembling1164 # making use of the JSON cache to setup pickers, rather than assembling
1166 # javascript in a view macro.1165 # javascript in a view macro.
1167 custom_widget(1166 custom_widget_newmember = CustomWidgetFactory(
1168 'newmember', PersonPickerWidget,1167 PersonPickerWidget,
1169 show_assign_me_button='false', show_remove_button='false')1168 show_assign_me_button='false', show_remove_button='false')
11701169
1171 @property1170 @property
@@ -1362,7 +1361,8 @@
1362 __name__ = '+invitation'1361 __name__ = '+invitation'
1363 schema = ITeamMembershipInvitationAcknowledgementForm1362 schema = ITeamMembershipInvitationAcknowledgementForm
1364 field_names = ['acknowledger_comment']1363 field_names = ['acknowledger_comment']
1365 custom_widget('acknowledger_comment', TextAreaWidget, height=5, width=60)1364 custom_widget_acknowledger_comment = CustomWidgetFactory(
1365 TextAreaWidget, height=5, width=60)
1366 template = ViewPageTemplateFile(1366 template = ViewPageTemplateFile(
1367 '../templates/teammembership-invitation.pt')1367 '../templates/teammembership-invitation.pt')
13681368
@@ -1893,7 +1893,7 @@
1893 """Propose/add to this team any team that you're an administrator of."""1893 """Propose/add to this team any team that you're an administrator of."""
18941894
1895 page_title = 'Propose/add one of your teams to another one'1895 page_title = 'Propose/add one of your teams to another one'
1896 custom_widget('teams', LabeledMultiCheckBoxWidget)1896 custom_widget_teams = LabeledMultiCheckBoxWidget
18971897
1898 def initialize(self):1898 def initialize(self):
1899 context = self.context1899 context = self.context
19001900
=== modified file 'lib/lp/registry/doc/product-widgets.txt'
--- lib/lp/registry/doc/product-widgets.txt 2017-10-21 18:14:14 +0000
+++ lib/lp/registry/doc/product-widgets.txt 2018-08-31 11:41:19 +0000
@@ -403,8 +403,7 @@
403403
404 >>> from lp.services.config import config404 >>> from lp.services.config import config
405 >>> from z3c.ptcompat import ViewPageTemplateFile405 >>> from z3c.ptcompat import ViewPageTemplateFile
406 >>> from lp.app.browser.launchpadform import (406 >>> from lp.app.browser.launchpadform import LaunchpadFormView
407 ... custom_widget, LaunchpadFormView)
408407
409 >>> class GhostWidgetView(LaunchpadFormView):408 >>> class GhostWidgetView(LaunchpadFormView):
410 ... page_title = 'Test'409 ... page_title = 'Test'
@@ -412,7 +411,7 @@
412 ... config.root + '/lib/lp/app/templates/generic-edit.pt')411 ... config.root + '/lib/lp/app/templates/generic-edit.pt')
413 ... schema = IProduct412 ... schema = IProduct
414 ... field_names = ['license_info']413 ... field_names = ['license_info']
415 ... custom_widget('license_info', GhostWidget)414 ... custom_widget_license_info = GhostWidget
416415
417 >>> request = LaunchpadTestRequest()416 >>> request = LaunchpadTestRequest()
418 >>> request.setPrincipal(factory.makePerson())417 >>> request.setPrincipal(factory.makePerson())