# HG changeset patch # User Thierry Florac # Date 1567605463 -7200 # Node ID 999fa08d99c2d38c6e4d9e3e032085f67d1a3902 # Parent 09247c61f985b92e7b5df7b4ac32b91e1c55ccea Small refactoring in shared contents properties edit forms diff -r 09247c61f985 -r 999fa08d99c2 src/pyams_content/shared/common/zmi/properties.py --- a/src/pyams_content/shared/common/zmi/properties.py Wed Sep 04 15:56:28 2019 +0200 +++ b/src/pyams_content/shared/common/zmi/properties.py Wed Sep 04 15:57:43 2019 +0200 @@ -77,16 +77,19 @@ legend = _("Content properties") + interface = IWfSharedContent + fieldnames = ('title', 'short_name', 'content_url', 'header', 'description', 'notepad') + @property def fields(self): - fields = field.Fields(IWfSharedContent).select('title', 'short_name', 'content_url', - 'header', 'description', 'notepad') - fields['title'].widgetFactory = I18nSEOTextLineFieldWidget - if not self.context.handle_content_url: + fields = field.Fields(self.interface).select(*self.fieldnames) + if 'title' in fields: + fields['title'].widgetFactory = I18nSEOTextLineFieldWidget + if ('content_url' in fields) and not self.context.handle_content_url: fields = fields.omit('content_url') - if not self.context.handle_header: + if ('header' in fields) and not self.context.handle_header: fields = fields.omit('header') - if not self.context.handle_description: + if ('description' in fields) and not self.context.handle_description: fields = fields.omit('description') return fields diff -r 09247c61f985 -r 999fa08d99c2 src/pyams_content/shared/common/zmi/types/__init__.py --- a/src/pyams_content/shared/common/zmi/types/__init__.py Wed Sep 04 15:56:28 2019 +0200 +++ b/src/pyams_content/shared/common/zmi/types/__init__.py Wed Sep 04 15:57:43 2019 +0200 @@ -404,19 +404,8 @@ """Typed shared content properties edit form""" interface = IWfTypedSharedContent - - @property - def fields(self): - fields = field.Fields(self.interface).select('title', 'short_name', 'content_url', - 'data_type', 'header', 'description', 'notepad') - fields['title'].widgetFactory = I18nSEOTextLineFieldWidget - if not self.context.handle_content_url: - fields = fields.omit('content_url') - if not self.context.handle_header: - fields = fields.omit('header') - if not self.context.handle_description: - fields = fields.omit('description') - return fields + fieldnames = ('title', 'short_name', 'content_url', + 'data_type', 'header', 'description', 'notepad') # diff -r 09247c61f985 -r 999fa08d99c2 src/pyams_content/shared/logo/zmi/properties.py --- a/src/pyams_content/shared/logo/zmi/properties.py Wed Sep 04 15:56:28 2019 +0200 +++ b/src/pyams_content/shared/logo/zmi/properties.py Wed Sep 04 15:57:43 2019 +0200 @@ -46,7 +46,8 @@ class LogoMainPropertiesEditForm(SharedContentPropertiesEditForm): """Logo properties edit form""" - fields = field.Fields(IWfLogo).select('title', 'short_name', 'notepad') + interface = IWfLogo + fieldnames = ('title', 'short_name', 'notepad') @adapter_config(name='logo-settings',