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