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

Proposed by Colin Watson
Status: Merged
Merged at revision: 18778
Proposed branch: lp:~cjwatson/launchpad/custom-widget-no-class-advice-5
Merge into: lp:launchpad
Diff against target: 684 lines (+95/-120)
14 files modified
lib/lp/app/browser/launchpadform.py (+0/-26)
lib/lp/services/features/browser/edit.py (+3/-3)
lib/lp/services/verification/browser/logintoken.py (+8/-7)
lib/lp/services/webhooks/browser.py (+3/-4)
lib/lp/snappy/browser/snap.py (+17/-16)
lib/lp/soyuz/browser/archive.py (+21/-19)
lib/lp/soyuz/browser/archivesubscription.py (+8/-8)
lib/lp/soyuz/browser/livefs.py (+3/-4)
lib/lp/translations/browser/hastranslationimports.py (+12/-9)
lib/lp/translations/browser/language.py (+6/-5)
lib/lp/translations/browser/person.py (+5/-5)
lib/lp/translations/browser/potemplate.py (+5/-6)
lib/lp/translations/browser/productseries.py (+2/-4)
lib/lp/translations/browser/translationimportqueue.py (+2/-4)
To merge this branch: bzr merge lp:~cjwatson/launchpad/custom-widget-no-class-advice-5
Reviewer Review Type Date Requested Status
William Grant code Approve
Review via email: mp+354843@code.launchpad.net

Commit message

Finish removing Zope class advice from custom widget registration.

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/app/browser/launchpadform.py'
--- lib/lp/app/browser/launchpadform.py 2018-08-09 14:31:23 +0000
+++ lib/lp/app/browser/launchpadform.py 2018-09-13 08:25:30 +0000
@@ -8,7 +8,6 @@
88
9__all__ = [9__all__ = [
10 'action',10 'action',
11 'custom_widget',
12 'has_structured_doc',11 'has_structured_doc',
13 'LaunchpadEditFormView',12 'LaunchpadEditFormView',
14 'LaunchpadFormView',13 'LaunchpadFormView',
@@ -41,7 +40,6 @@
41 implementer,40 implementer,
42 providedBy,41 providedBy,
43 )42 )
44from zope.interface.advice import addClassAdvisor
45from zope.traversing.interfaces import (43from zope.traversing.interfaces import (
46 ITraversable,44 ITraversable,
47 TraversalError,45 TraversalError,
@@ -80,8 +78,6 @@
80 schema = None78 schema = None
81 # Subset of fields to use79 # Subset of fields to use
82 field_names = None80 field_names = None
83 # Dictionary mapping field names to custom widgets
84 custom_widgets = {}
8581
86 # The next URL to redirect to on successful form submission82 # The next URL to redirect to on successful form submission
87 next_url = None83 next_url = None
@@ -205,8 +201,6 @@
205 if field.custom_widget is None:201 if field.custom_widget is None:
206 widget = getattr(202 widget = getattr(
207 self, 'custom_widget_%s' % field.__name__, None)203 self, 'custom_widget_%s' % field.__name__, None)
208 if widget is None:
209 widget = self.custom_widgets.get(field.__name__)
210 if widget is not None:204 if widget is not None:
211 if IWidgetFactory.providedBy(widget):205 if IWidgetFactory.providedBy(widget):
212 field.custom_widget = widget206 field.custom_widget = widget
@@ -488,26 +482,6 @@
488 return was_changed482 return was_changed
489483
490484
491class custom_widget:
492 """A class advisor for overriding the default widget for a field."""
493
494 def __init__(self, field_name, widget, *args, **kwargs):
495 self.field_name = field_name
496 if widget is None:
497 self.widget = None
498 else:
499 self.widget = CustomWidgetFactory(widget, *args, **kwargs)
500 addClassAdvisor(self.advise)
501
502 def advise(self, cls):
503 if cls.custom_widgets is None:
504 cls.custom_widgets = {}
505 else:
506 cls.custom_widgets = dict(cls.custom_widgets)
507 cls.custom_widgets[self.field_name] = self.widget
508 return cls
509
510
511def safe_action(action):485def safe_action(action):
512 """A decorator used to mark a particular action as 'safe'.486 """A decorator used to mark a particular action as 'safe'.
513487
514488
=== modified file 'lib/lp/services/features/browser/edit.py'
--- lib/lp/services/features/browser/edit.py 2013-04-10 08:09:05 +0000
+++ lib/lp/services/features/browser/edit.py 2018-09-13 08:25:30 +0000
@@ -1,4 +1,4 @@
1# Copyright 2010 Canonical Ltd. This software is licensed under the1# Copyright 2010-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 and edit feature rules."""4"""View and edit feature rules."""
@@ -13,13 +13,13 @@
13from difflib import unified_diff13from difflib import unified_diff
14import logging14import logging
1515
16from zope.formlib.widget import CustomWidgetFactory
16from zope.formlib.widgets import TextAreaWidget17from zope.formlib.widgets import TextAreaWidget
17from zope.interface import Interface18from zope.interface import Interface
18from zope.schema import Text19from zope.schema import Text
1920
20from lp.app.browser.launchpadform import (21from lp.app.browser.launchpadform import (
21 action,22 action,
22 custom_widget,
23 LaunchpadFormView,23 LaunchpadFormView,
24 )24 )
25from lp.app.browser.stringformatter import FormattersAPI25from lp.app.browser.stringformatter import FormattersAPI
@@ -59,7 +59,7 @@
59 page_title = label = 'Feature control'59 page_title = label = 'Feature control'
60 diff = None60 diff = None
61 logger_name = 'lp.services.features'61 logger_name = 'lp.services.features'
62 custom_widget('comment', TextAreaWidget, height=2)62 custom_widget_comment = CustomWidgetFactory(TextAreaWidget, height=2)
6363
64 @property64 @property
65 def field_names(self):65 def field_names(self):
6666
=== modified file 'lib/lp/services/verification/browser/logintoken.py'
--- lib/lp/services/verification/browser/logintoken.py 2018-03-02 16:17:35 +0000
+++ lib/lp/services/verification/browser/logintoken.py 2018-09-13 08:25:30 +0000
@@ -1,4 +1,4 @@
1# Copyright 2009-2013 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
@@ -18,6 +18,7 @@
18import urllib18import urllib
1919
20from zope.component import getUtility20from zope.component import getUtility
21from zope.formlib.widget import CustomWidgetFactory
21from zope.formlib.widgets import TextAreaWidget22from zope.formlib.widgets import TextAreaWidget
22from zope.interface import (23from zope.interface import (
23 alsoProvides,24 alsoProvides,
@@ -29,7 +30,6 @@
29from lp import _30from lp import _
30from lp.app.browser.launchpadform import (31from lp.app.browser.launchpadform import (
31 action,32 action,
32 custom_widget,
33 LaunchpadEditFormView,33 LaunchpadEditFormView,
34 LaunchpadFormView,34 LaunchpadFormView,
35 )35 )
@@ -176,11 +176,12 @@
176 'teamowner', 'display_name', 'description', 'membership_policy',176 'teamowner', 'display_name', 'description', 'membership_policy',
177 'defaultmembershipperiod', 'renewal_policy', 'defaultrenewalperiod']177 'defaultmembershipperiod', 'renewal_policy', 'defaultrenewalperiod']
178 label = 'Claim Launchpad team'178 label = 'Claim Launchpad team'
179 custom_widget('description', TextAreaWidget, height=10, width=30)179 custom_widget_description = CustomWidgetFactory(
180 custom_widget(180 TextAreaWidget, height=10, width=30)
181 'renewal_policy', LaunchpadRadioWidget, orientation='vertical')181 custom_widget_renewal_policy = CustomWidgetFactory(
182 custom_widget(182 LaunchpadRadioWidget, orientation='vertical')
183 'membership_policy', LaunchpadRadioWidget, orientation='vertical')183 custom_widget_membership_policy = CustomWidgetFactory(
184 LaunchpadRadioWidget, orientation='vertical')
184185
185 expected_token_types = (LoginTokenType.TEAMCLAIM,)186 expected_token_types = (LoginTokenType.TEAMCLAIM,)
186187
187188
=== modified file 'lib/lp/services/webhooks/browser.py'
--- lib/lp/services/webhooks/browser.py 2015-10-26 11:47:38 +0000
+++ lib/lp/services/webhooks/browser.py 2018-09-13 08:25:30 +0000
@@ -1,4 +1,4 @@
1# Copyright 2015 Canonical Ltd. This software is licensed under the1# Copyright 2015-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"""Webhook browser and API classes."""4"""Webhook browser and API classes."""
@@ -17,7 +17,6 @@
1717
18from lp.app.browser.launchpadform import (18from lp.app.browser.launchpadform import (
19 action,19 action,
20 custom_widget,
21 LaunchpadEditFormView,20 LaunchpadEditFormView,
22 LaunchpadFormView,21 LaunchpadFormView,
23 )22 )
@@ -119,7 +118,7 @@
119 page_title = label = "Add webhook"118 page_title = label = "Add webhook"
120119
121 schema = WebhookEditSchema120 schema = WebhookEditSchema
122 custom_widget('event_types', LabeledMultiCheckBoxWidget)121 custom_widget_event_types = LabeledMultiCheckBoxWidget
123122
124 @property123 @property
125 def inside_breadcrumb(self):124 def inside_breadcrumb(self):
@@ -152,7 +151,7 @@
152 schema = WebhookEditSchema151 schema = WebhookEditSchema
153 # XXX wgrant 2015-08-04: Need custom widget for secret.152 # XXX wgrant 2015-08-04: Need custom widget for secret.
154 field_names = ['delivery_url', 'event_types', 'active']153 field_names = ['delivery_url', 'event_types', 'active']
155 custom_widget('event_types', LabeledMultiCheckBoxWidget)154 custom_widget_event_types = LabeledMultiCheckBoxWidget
156155
157 def initialize(self):156 def initialize(self):
158 super(WebhookView, self).initialize()157 super(WebhookView, self).initialize()
159158
=== modified file 'lib/lp/snappy/browser/snap.py'
--- lib/lp/snappy/browser/snap.py 2018-08-30 16:15:20 +0000
+++ lib/lp/snappy/browser/snap.py 2018-09-13 08:25:30 +0000
@@ -25,6 +25,7 @@
25 )25 )
26from zope.component import getUtility26from zope.component import getUtility
27from zope.error.interfaces import IErrorReportingUtility27from zope.error.interfaces import IErrorReportingUtility
28from zope.formlib.widget import CustomWidgetFactory
28from zope.interface import Interface29from zope.interface import Interface
29from zope.schema import (30from zope.schema import (
30 Choice,31 Choice,
@@ -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 render_radio_widget_part,41 render_radio_widget_part,
@@ -263,9 +263,9 @@
263 description=u'The package stream within the source distribution '263 description=u'The package stream within the source distribution '
264 'series to use when building the snap package.')264 'series to use when building the snap package.')
265265
266 custom_widget('archive', SnapArchiveWidget)266 custom_widget_archive = SnapArchiveWidget
267 custom_widget('distro_arch_series', LabeledMultiCheckBoxWidget)267 custom_widget_distro_arch_series = LabeledMultiCheckBoxWidget
268 custom_widget('pocket', LaunchpadDropdownWidget)268 custom_widget_pocket = LaunchpadDropdownWidget
269269
270 help_links = {270 help_links = {
271 "pocket": u"/+help-snappy/snap-build-pocket.html",271 "pocket": u"/+help-snappy/snap-build-pocket.html",
@@ -400,11 +400,11 @@
400 'store_name',400 'store_name',
401 'store_channels',401 'store_channels',
402 ]402 ]
403 custom_widget('store_distro_series', LaunchpadRadioWidget)403 custom_widget_store_distro_series = LaunchpadRadioWidget
404 custom_widget('auto_build_archive', SnapArchiveWidget)404 custom_widget_auto_build_archive = SnapArchiveWidget
405 custom_widget('auto_build_pocket', LaunchpadDropdownWidget)405 custom_widget_auto_build_pocket = LaunchpadDropdownWidget
406 custom_widget('auto_build_channels', SnapBuildChannelsWidget)406 custom_widget_auto_build_channels = SnapBuildChannelsWidget
407 custom_widget('store_channels', StoreChannelsWidget)407 custom_widget_store_channels = StoreChannelsWidget
408408
409 help_links = {409 help_links = {
410 "auto_build_pocket": u"/+help-snappy/snap-build-pocket.html",410 "auto_build_pocket": u"/+help-snappy/snap-build-pocket.html",
@@ -696,13 +696,14 @@
696 'store_name',696 'store_name',
697 'store_channels',697 'store_channels',
698 ]698 ]
699 custom_widget('store_distro_series', LaunchpadRadioWidget)699 custom_widget_store_distro_series = LaunchpadRadioWidget
700 custom_widget('vcs', LaunchpadRadioWidget)700 custom_widget_vcs = LaunchpadRadioWidget
701 custom_widget('git_ref', GitRefWidget, allow_external=True)701 custom_widget_git_ref = CustomWidgetFactory(
702 custom_widget('auto_build_archive', SnapArchiveWidget)702 GitRefWidget, allow_external=True)
703 custom_widget('auto_build_pocket', LaunchpadDropdownWidget)703 custom_widget_auto_build_archive = SnapArchiveWidget
704 custom_widget('auto_build_channels', SnapBuildChannelsWidget)704 custom_widget_auto_build_pocket = LaunchpadDropdownWidget
705 custom_widget('store_channels', StoreChannelsWidget)705 custom_widget_auto_build_channels = SnapBuildChannelsWidget
706 custom_widget_store_channels = StoreChannelsWidget
706707
707 help_links = {708 help_links = {
708 "auto_build_pocket": u"/+help-snappy/snap-build-pocket.html",709 "auto_build_pocket": u"/+help-snappy/snap-build-pocket.html",
709710
=== modified file 'lib/lp/soyuz/browser/archive.py'
--- lib/lp/soyuz/browser/archive.py 2018-05-11 17:52:11 +0000
+++ lib/lp/soyuz/browser/archive.py 2018-09-13 08:25:30 +0000
@@ -65,7 +65,6 @@
65from lp.app.browser.badge import HasBadgeBase65from lp.app.browser.badge import HasBadgeBase
66from lp.app.browser.launchpadform import (66from lp.app.browser.launchpadform import (
67 action,67 action,
68 custom_widget,
69 LaunchpadEditFormView,68 LaunchpadEditFormView,
70 LaunchpadFormView,69 LaunchpadFormView,
71 )70 )
@@ -830,8 +829,8 @@
830 """A Form view for filtering and batching source packages."""829 """A Form view for filtering and batching source packages."""
831830
832 schema = IPPAPackageFilter831 schema = IPPAPackageFilter
833 custom_widget('series_filter', SeriesFilterWidget)832 custom_widget_series_filter = SeriesFilterWidget
834 custom_widget('status_filter', StatusFilterWidget)833 custom_widget_status_filter = StatusFilterWidget
835834
836 # By default this view will not display the sources with selectable835 # By default this view will not display the sources with selectable
837 # checkboxes, but subclasses can override as needed.836 # checkboxes, but subclasses can override as needed.
@@ -1129,7 +1128,7 @@
1129class ArchiveSourceSelectionFormView(ArchiveSourcePackageListViewBase):1128class ArchiveSourceSelectionFormView(ArchiveSourcePackageListViewBase):
1130 """Base class to implement a source selection widget for PPAs."""1129 """Base class to implement a source selection widget for PPAs."""
11311130
1132 custom_widget('selected_sources', LabeledMultiCheckBoxWidget)1131 custom_widget_selected_sources = LabeledMultiCheckBoxWidget
11331132
1134 selectable_sources = True1133 selectable_sources = True
11351134
@@ -1212,7 +1211,8 @@
1212 """1211 """
12131212
1214 schema = IArchivePackageDeletionForm1213 schema = IArchivePackageDeletionForm
1215 custom_widget('deletion_comment', StrippedTextWidget, displayWidth=50)1214 custom_widget_deletion_comment = CustomWidgetFactory(
1215 StrippedTextWidget, displayWidth=50)
1216 label = 'Delete packages'1216 label = 'Delete packages'
12171217
1218 @property1218 @property
@@ -1450,9 +1450,9 @@
1450 a copying action that can be performed upon a set of selected packages.1450 a copying action that can be performed upon a set of selected packages.
1451 """1451 """
1452 schema = IPPAPackageFilter1452 schema = IPPAPackageFilter
1453 custom_widget('destination_archive', DestinationArchiveDropdownWidget)1453 custom_widget_destination_archive = DestinationArchiveDropdownWidget
1454 custom_widget('destination_series', DestinationSeriesDropdownWidget)1454 custom_widget_destination_series = DestinationSeriesDropdownWidget
1455 custom_widget('include_binaries', LaunchpadRadioWidget)1455 custom_widget_include_binaries = LaunchpadRadioWidget
1456 label = 'Copy packages'1456 label = 'Copy packages'
14571457
1458 @property1458 @property
@@ -1615,12 +1615,13 @@
16151615
1616 schema = IArchiveEditDependenciesForm1616 schema = IArchiveEditDependenciesForm
16171617
1618 custom_widget('selected_dependencies', PlainMultiCheckBoxWidget,1618 custom_widget_selected_dependencies = CustomWidgetFactory(
1619 cssClass='line-through-when-checked ppa-dependencies')1619 PlainMultiCheckBoxWidget,
1620 custom_widget('primary_dependencies', LaunchpadRadioWidget,1620 cssClass='line-through-when-checked ppa-dependencies')
1621 cssClass='highlight-selected')1621 custom_widget_primary_dependencies = CustomWidgetFactory(
1622 custom_widget('primary_components', LaunchpadRadioWidget,1622 LaunchpadRadioWidget, cssClass='highlight-selected')
1623 cssClass='highlight-selected')1623 custom_widget_primary_components = CustomWidgetFactory(
1624 LaunchpadRadioWidget, cssClass='highlight-selected')
16241625
1625 label = "Edit PPA dependencies"1626 label = "Edit PPA dependencies"
1626 page_title = label1627 page_title = label
@@ -1922,8 +1923,8 @@
19221923
1923 schema = IArchive1924 schema = IArchive
1924 field_names = ('name', 'displayname', 'description')1925 field_names = ('name', 'displayname', 'description')
1925 custom_widget('description', TextAreaWidget, height=3)1926 custom_widget_description = CustomWidgetFactory(TextAreaWidget, height=3)
1926 custom_widget('name', PPANameWidget, label="URL")1927 custom_widget_name = CustomWidgetFactory(PPANameWidget, label="URL")
1927 label = 'Activate a Personal Package Archive'1928 label = 'Activate a Personal Package Archive'
1928 page_title = 'Activate PPA'1929 page_title = 'Activate PPA'
19291930
@@ -2106,8 +2107,8 @@
2106 'build_debug_symbols',2107 'build_debug_symbols',
2107 'publish_debug_symbols',2108 'publish_debug_symbols',
2108 ]2109 ]
2109 custom_widget(2110 custom_widget_description = CustomWidgetFactory(
2110 'description', TextAreaWidget, height=10, width=30)2111 TextAreaWidget, height=10, width=30)
2111 page_title = 'Change details'2112 page_title = 'Change details'
21122113
2113 @property2114 @property
@@ -2160,7 +2161,8 @@
2160 'relative_build_score',2161 'relative_build_score',
2161 'external_dependencies',2162 'external_dependencies',
2162 ]2163 ]
2163 custom_widget('external_dependencies', TextAreaWidget, height=3)2164 custom_widget_external_dependencies = CustomWidgetFactory(
2165 TextAreaWidget, height=3)
2164 page_title = 'Administer'2166 page_title = 'Administer'
21652167
2166 @property2168 @property
21672169
=== modified file 'lib/lp/soyuz/browser/archivesubscription.py'
--- lib/lp/soyuz/browser/archivesubscription.py 2015-09-24 11:30:01 +0000
+++ lib/lp/soyuz/browser/archivesubscription.py 2018-09-13 08:25:30 +0000
@@ -1,4 +1,4 @@
1# Copyright 2009-2015 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 related to archive subscriptions."""4"""Browser views related to archive subscriptions."""
@@ -33,7 +33,6 @@
33from lp import _33from lp import _
34from lp.app.browser.launchpadform import (34from lp.app.browser.launchpadform import (
35 action,35 action,
36 custom_widget,
37 LaunchpadEditFormView,36 LaunchpadEditFormView,
38 LaunchpadFormView,37 LaunchpadFormView,
39 )38 )
@@ -130,10 +129,10 @@
130129
131 schema = IArchiveSubscriberUI130 schema = IArchiveSubscriberUI
132 field_names = ['subscriber', 'date_expires', 'description']131 field_names = ['subscriber', 'date_expires', 'description']
133 custom_widget('description', TextWidget, displayWidth=40)132 custom_widget_description = CustomWidgetFactory(TextWidget, displayWidth=40)
134 custom_widget('date_expires', CustomWidgetFactory(DateWidget))133 custom_widget_date_expires = DateWidget
135 custom_widget('subscriber', PersonPickerWidget,134 custom_widget_subscriber = CustomWidgetFactory(
136 header="Select the subscriber")135 PersonPickerWidget, header="Select the subscriber")
137136
138 @property137 @property
139 def label(self):138 def label(self):
@@ -245,8 +244,9 @@
245244
246 schema = IArchiveSubscriberUI245 schema = IArchiveSubscriberUI
247 field_names = ['date_expires', 'description']246 field_names = ['date_expires', 'description']
248 custom_widget('description', TextWidget, displayWidth=40)247 custom_widget_description = CustomWidgetFactory(
249 custom_widget('date_expires', CustomWidgetFactory(DateWidget))248 TextWidget, displayWidth=40)
249 custom_widget_date_expires = DateWidget
250250
251 @property251 @property
252 def label(self):252 def label(self):
253253
=== modified file 'lib/lp/soyuz/browser/livefs.py'
--- lib/lp/soyuz/browser/livefs.py 2017-07-18 16:22:03 +0000
+++ lib/lp/soyuz/browser/livefs.py 2018-09-13 08:25:30 +0000
@@ -1,4 +1,4 @@
1# Copyright 2014-2017 Canonical Ltd. This software is licensed under the1# Copyright 2014-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"""LiveFS views."""4"""LiveFS views."""
@@ -29,7 +29,6 @@
2929
30from lp.app.browser.launchpadform import (30from lp.app.browser.launchpadform import (
31 action,31 action,
32 custom_widget,
33 LaunchpadEditFormView,32 LaunchpadEditFormView,
34 LaunchpadFormView,33 LaunchpadFormView,
35 )34 )
@@ -210,7 +209,7 @@
210209
211 schema = ILiveFSEditSchema210 schema = ILiveFSEditSchema
212 field_names = ['owner', 'name', 'distro_series', 'metadata']211 field_names = ['owner', 'name', 'distro_series', 'metadata']
213 custom_widget('distro_series', LaunchpadRadioWidget)212 custom_widget_distro_series = LaunchpadRadioWidget
214213
215 def initialize(self):214 def initialize(self):
216 """See `LaunchpadView`."""215 """See `LaunchpadView`."""
@@ -303,7 +302,7 @@
303 label = title302 label = title
304303
305 field_names = ['owner', 'name', 'distro_series', 'metadata']304 field_names = ['owner', 'name', 'distro_series', 'metadata']
306 custom_widget('distro_series', LaunchpadRadioWidget)305 custom_widget_distro_series = LaunchpadRadioWidget
307306
308 @property307 @property
309 def initial_values(self):308 def initial_values(self):
310309
=== modified file 'lib/lp/translations/browser/hastranslationimports.py'
--- lib/lp/translations/browser/hastranslationimports.py 2015-07-08 16:05:11 +0000
+++ lib/lp/translations/browser/hastranslationimports.py 2018-09-13 08:25:30 +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"""Browser view for IHasTranslationImports."""4"""Browser view for IHasTranslationImports."""
@@ -16,6 +16,7 @@
16from z3c.ptcompat import ViewPageTemplateFile16from z3c.ptcompat import ViewPageTemplateFile
17from zope.component import getUtility17from zope.component import getUtility
18from zope.formlib import form18from zope.formlib import form
19from zope.formlib.widget import CustomWidgetFactory
19from zope.formlib.widgets import DropdownWidget20from zope.formlib.widgets import DropdownWidget
20from zope.interface import implementer21from zope.interface import implementer
21from zope.schema import Choice22from zope.schema import Choice
@@ -28,7 +29,6 @@
28from lp import _29from lp import _
29from lp.app.browser.launchpadform import (30from lp.app.browser.launchpadform import (
30 action,31 action,
31 custom_widget,
32 LaunchpadFormView,32 LaunchpadFormView,
33 safe_action,33 safe_action,
34 )34 )
@@ -55,11 +55,14 @@
55 schema = IHasTranslationImports55 schema = IHasTranslationImports
56 field_names = []56 field_names = []
5757
58 custom_widget('filter_target', DropdownWidget, cssClass='inlined-widget')58 custom_widget_filter_target = CustomWidgetFactory(
59 custom_widget('filter_status', DropdownWidget, cssClass='inlined-widget')59 DropdownWidget, cssClass='inlined-widget')
60 custom_widget(60 custom_widget_filter_status = CustomWidgetFactory(
61 'filter_extension', DropdownWidget, cssClass='inlined-widget')61 DropdownWidget, cssClass='inlined-widget')
62 custom_widget('status', DropdownWidget, cssClass='inlined-widget')62 custom_widget_filter_extension = CustomWidgetFactory(
63 DropdownWidget, cssClass='inlined-widget')
64 custom_widget_status = CustomWidgetFactory(
65 DropdownWidget, cssClass='inlined-widget')
6366
64 translation_import_queue_macros = ViewPageTemplateFile(67 translation_import_queue_macros = ViewPageTemplateFile(
65 '../templates/translation-import-queue-macros.pt')68 '../templates/translation-import-queue-macros.pt')
@@ -88,7 +91,7 @@
88 __name__=name,91 __name__=name,
89 source=source,92 source=source,
90 title=_(title)),93 title=_(title)),
91 custom_widget=self.custom_widgets[name],94 custom_widget=getattr(self, 'custom_widget_%s' % name),
92 render_context=self.render_context)95 render_context=self.render_context)
9396
94 def createFilterStatusField(self):97 def createFilterStatusField(self):
@@ -132,7 +135,7 @@
132 __name__=name,135 __name__=name,
133 source=EntryImportStatusVocabularyFactory(entry, self.user),136 source=EntryImportStatusVocabularyFactory(entry, self.user),
134 title=_('Select import status')),137 title=_('Select import status')),
135 custom_widget=self.custom_widgets['status'],138 custom_widget=self.custom_widgets_status,
136 render_context=self.render_context)139 render_context=self.render_context)
137140
138 def setUpFields(self):141 def setUpFields(self):
139142
=== modified file 'lib/lp/translations/browser/language.py'
--- lib/lp/translations/browser/language.py 2013-04-10 08:09:05 +0000
+++ lib/lp/translations/browser/language.py 2018-09-13 08:25:30 +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"""Browser code for Language table."""4"""Browser code for Language table."""
@@ -16,6 +16,7 @@
1616
17from zope.component import getUtility17from zope.component import getUtility
18from zope.event import notify18from zope.event import notify
19from zope.formlib.widget import CustomWidgetFactory
19from zope.formlib.widgets import TextWidget20from zope.formlib.widgets import TextWidget
20from zope.interface import Interface21from zope.interface import Interface
21from zope.lifecycleevent import ObjectCreatedEvent22from zope.lifecycleevent import ObjectCreatedEvent
@@ -23,7 +24,6 @@
2324
24from lp.app.browser.launchpadform import (25from lp.app.browser.launchpadform import (
25 action,26 action,
26 custom_widget,
27 LaunchpadEditFormView,27 LaunchpadEditFormView,
28 LaunchpadFormView,28 LaunchpadFormView,
29 )29 )
@@ -120,7 +120,8 @@
120120
121 schema = ILanguageSetSearch121 schema = ILanguageSetSearch
122122
123 custom_widget('search_lang', TextWidget, displayWidth=30)123 custom_widget_search_lang = CustomWidgetFactory(
124 TextWidget, displayWidth=30)
124125
125 def initialize(self):126 def initialize(self):
126 """See `LaunchpadFormView`."""127 """See `LaunchpadFormView`."""
@@ -290,8 +291,8 @@
290291
291 schema = ILanguage292 schema = ILanguage
292293
293 custom_widget('countries', LabeledMultiCheckBoxWidget,294 custom_widget_countries = CustomWidgetFactory(
294 orientation='vertical')295 LabeledMultiCheckBoxWidget, orientation='vertical')
295296
296 field_names = ['code', 'englishname', 'nativename', 'pluralforms',297 field_names = ['code', 'englishname', 'nativename', 'pluralforms',
297 'pluralexpression', 'visible', 'direction', 'countries']298 'pluralexpression', 'visible', 'direction', 'countries']
298299
=== modified file 'lib/lp/translations/browser/person.py'
--- lib/lp/translations/browser/person.py 2015-07-08 16:05:11 +0000
+++ lib/lp/translations/browser/person.py 2018-09-13 08:25:30 +0000
@@ -1,4 +1,4 @@
1# Copyright 2009-2013 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"""Person-related translations view classes."""4"""Person-related translations view classes."""
@@ -21,6 +21,7 @@
21import pytz21import pytz
22from z3c.ptcompat import ViewPageTemplateFile22from z3c.ptcompat import ViewPageTemplateFile
23from zope.component import getUtility23from zope.component import getUtility
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 @@
30from lp import _31from lp import _
31from lp.app.browser.launchpadform import (32from lp.app.browser.launchpadform import (
32 action,33 action,
33 custom_widget,
34 LaunchpadFormView,34 LaunchpadFormView,
35 )35 )
36from lp.app.enums import ServiceUsage36from lp.app.enums import ServiceUsage
@@ -443,9 +443,9 @@
443 """View for Person's translation relicensing page."""443 """View for Person's translation relicensing page."""
444 schema = ITranslationRelicensingAgreementEdit444 schema = ITranslationRelicensingAgreementEdit
445 field_names = ['allow_relicensing', 'back_to']445 field_names = ['allow_relicensing', 'back_to']
446 custom_widget(446 custom_widget_allow_relicensing = CustomWidgetFactory(
447 'allow_relicensing', LaunchpadRadioWidget, orientation='vertical')447 LaunchpadRadioWidget, orientation='vertical')
448 custom_widget('back_to', TextWidget, visible=False)448 custom_widget_back_to = CustomWidgetFactory(TextWidget, visible=False)
449449
450 page_title = "Licensing"450 page_title = "Licensing"
451451
452452
=== modified file 'lib/lp/translations/browser/potemplate.py'
--- lib/lp/translations/browser/potemplate.py 2016-09-12 15:07:45 +0000
+++ lib/lp/translations/browser/potemplate.py 2018-09-13 08:25:30 +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).
3"""Browser code for PO templates."""3"""Browser code for PO templates."""
44
@@ -42,7 +42,6 @@
42from lp import _42from lp import _
43from lp.app.browser.launchpadform import (43from lp.app.browser.launchpadform import (
44 action,44 action,
45 custom_widget,
46 LaunchpadEditFormView,45 LaunchpadEditFormView,
47 ReturnToReferrerMixin,46 ReturnToReferrerMixin,
48 )47 )
@@ -524,7 +523,7 @@
524 else:523 else:
525 return IPOTemplate524 return IPOTemplate
526525
527 custom_widget('sourcepackagename', POTemplateEditSourcePackageNameWidget)526 custom_widget_sourcepackagename = POTemplateEditSourcePackageNameWidget
528 label = 'Edit translation template details'527 label = 'Edit translation template details'
529 page_title = 'Edit details'528 page_title = 'Edit details'
530 PRIORITY_MIN_VALUE = 0529 PRIORITY_MIN_VALUE = 0
@@ -700,9 +699,9 @@
700 'from_sourcepackagename', 'sourcepackageversion',699 'from_sourcepackagename', 'sourcepackageversion',
701 'languagepack', 'path', 'source_file_format', 'priority',700 'languagepack', 'path', 'source_file_format', 'priority',
702 'date_last_updated']701 'date_last_updated']
703 custom_widget('sourcepackagename', POTemplateAdminSourcePackageNameWidget)702 custom_widget_sourcepackagename = POTemplateAdminSourcePackageNameWidget
704 custom_widget(703 custom_widget_from_sourcepackagename = (
705 'from_sourcepackagename', POTemplateAdminSourcePackageNameWidget)704 POTemplateAdminSourcePackageNameWidget)
706 label = 'Administer translation template'705 label = 'Administer translation template'
707 page_title = "Administer"706 page_title = "Administer"
708707
709708
=== modified file 'lib/lp/translations/browser/productseries.py'
--- lib/lp/translations/browser/productseries.py 2012-12-12 04:59:52 +0000
+++ lib/lp/translations/browser/productseries.py 2018-09-13 08:25:30 +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"""View classes for `IProductSeries`."""4"""View classes for `IProductSeries`."""
@@ -25,7 +25,6 @@
25from lp import _25from lp import _
26from lp.app.browser.launchpadform import (26from lp.app.browser.launchpadform import (
27 action,27 action,
28 custom_widget,
29 LaunchpadEditFormView,28 LaunchpadEditFormView,
30 LaunchpadFormView,29 LaunchpadFormView,
31 ReturnToReferrerMixin,30 ReturnToReferrerMixin,
@@ -486,8 +485,7 @@
486 page_title = "Settings"485 page_title = "Settings"
487486
488 field_names = ['translations_autoimport_mode']487 field_names = ['translations_autoimport_mode']
489 settings_widget = custom_widget('translations_autoimport_mode',488 custom_widget_translations_autoimport_mode = SettingsRadioWidget
490 SettingsRadioWidget)
491489
492 @action(u"Save settings", name="save_settings")490 @action(u"Save settings", name="save_settings")
493 def change_settings_action(self, action, data):491 def change_settings_action(self, action, data):
494492
=== modified file 'lib/lp/translations/browser/translationimportqueue.py'
--- lib/lp/translations/browser/translationimportqueue.py 2016-09-12 17:41:21 +0000
+++ lib/lp/translations/browser/translationimportqueue.py 2018-09-13 08:25:30 +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 `ITranslationImportQueue`."""4"""Browser views for `ITranslationImportQueue`."""
@@ -27,7 +27,6 @@
2727
28from lp.app.browser.launchpadform import (28from lp.app.browser.launchpadform import (
29 action,29 action,
30 custom_widget,
31 LaunchpadFormView,30 LaunchpadFormView,
32 )31 )
33from lp.app.browser.tales import DateTimeFormatterAPI32from lp.app.browser.tales import DateTimeFormatterAPI
@@ -113,8 +112,7 @@
113 else:112 else:
114 return IEditTranslationImportQueueEntry113 return IEditTranslationImportQueueEntry
115114
116 custom_widget(115 custom_widget_sourcepackagename = (
117 'sourcepackagename',
118 TranslationImportQueueEntrySourcePackageNameWidget)116 TranslationImportQueueEntrySourcePackageNameWidget)
119117
120 max_series_to_display = 3118 max_series_to_display = 3