# HG changeset patch # User Thierry Florac # Date 1523608118 -7200 # Node ID e0708738c26ec5f3a92f206ad9b38cddb0edace6 # Parent f02b1394f204a2355ea24622c9b52efbf08e9a67 Removed short name from properties form diff -r f02b1394f204 -r e0708738c26e src/pyams_content/shared/common/zmi/properties.py --- a/src/pyams_content/shared/common/zmi/properties.py Fri Apr 13 09:37:23 2018 +0200 +++ b/src/pyams_content/shared/common/zmi/properties.py Fri Apr 13 10:28:38 2018 +0200 @@ -9,6 +9,8 @@ # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # FOR A PARTICULAR PURPOSE. # +from pyramid.events import subscriber +from z3c.form.interfaces import IDataExtractedEvent, HIDDEN_MODE __docformat__ = 'restructuredtext' @@ -77,19 +79,27 @@ legend = _("Content properties") - fields = field.Fields(IWfSharedContent).select('title', 'short_name', 'description', 'keywords', 'notepad') + fields = field.Fields(IWfSharedContent).select('title', 'short_name', 'description', 'notepad') fields['title'].widgetFactory = I18nSEOTextLineFieldWidget ajax_handler = 'properties.json' def updateWidgets(self, prefix=None): super(SharedContentPropertiesEditForm, self).updateWidgets(prefix) + if 'short_name' in self.widgets: + self.widgets['short_name'].set_mode(HIDDEN_MODE) if 'description' in self.widgets: self.widgets['description'].widget_css_class = 'textarea' if 'notepad' in self.widgets: self.widgets['notepad'].widget_css_class = 'textarea' +@subscriber(IDataExtractedEvent, form_selector=SharedContentPropertiesEditForm) +def handle_content_properties_data_extraction(event): + """Automatically set short_name as title""" + event.data['short_name'] = event.data['title'] + + @view_config(name='properties.json', context=IWfSharedContent, request_type=IPyAMSLayer, permission=MANAGE_CONTENT_PERMISSION, renderer='json', xhr=True) class SharedContentPropertiesAJAXEditForm(AJAXEditForm, SharedContentPropertiesEditForm):