Use SEO-related title input field
authorThierry Florac <thierry.florac@onf.fr>
Fri, 08 Dec 2017 10:46:16 +0100
changeset 312 cc13bd3548c3
parent 311 28a39fd182ea
child 313 2e71fb238b1c
Use SEO-related title input field
src/pyams_content/shared/common/zmi/__init__.py
--- a/src/pyams_content/shared/common/zmi/__init__.py	Fri Dec 08 10:45:37 2017 +0100
+++ b/src/pyams_content/shared/common/zmi/__init__.py	Fri Dec 08 10:46:16 2017 +0100
@@ -1,4 +1,4 @@
-#
+# -*- coding: utf-8 -*-
 # Copyright (c) 2008-2015 Thierry Florac <tflorac AT ulthar.net>
 # All Rights Reserved.
 #
@@ -31,13 +31,15 @@
 from pyams_skin.interfaces.viewlet import IContextActions, IMenuHeader, IBreadcrumbItem
 from pyams_skin.layer import IPyAMSLayer
 from pyams_utils.interfaces import FORBIDDEN_PERMISSION
-from pyams_workflow.interfaces import IWorkflowVersions, IWorkflowInfo, IWorkflowState, IWorkflowCommentInfo, IWorkflow
+from pyams_workflow.interfaces import IWorkflowVersions, IWorkflowInfo, IWorkflowState, IWorkflowCommentInfo, IWorkflow, \
+    IWorkflowPublicationInfo
 from pyams_zmi.interfaces.menu import ISiteManagementMenu
 from zope.dublincore.interfaces import IZopeDublinCore
 
 # import packages
 from pyams_form.form import AJAXAddForm
 from pyams_form.schema import CloseButton
+from pyams_i18n.widget import I18nSEOTextLineFieldWidget
 from pyams_pagelet.pagelet import pagelet_config
 from pyams_skin.page import DefaultPageHeaderAdapter
 from pyams_skin.table import DefaultElementEditorAdapter
@@ -72,6 +74,7 @@
 
     icon_css_class = 'fa fa-fw fa-plus'
     fields = field.Fields(IWfSharedContent).select('title', 'notepad')
+    fields['title'].widgetFactory = I18nSEOTextLineFieldWidget
 
     ajax_handler = 'add-shared-content.json'
     edit_permission = CREATE_CONTENT_PERMISSION
@@ -317,14 +320,18 @@
         translate = self.request.localizer.translate
         workflow = get_utility(IWorkflow, name=new_content.workflow_name)
         IWorkflowVersions(new_content).add_version(new_version, workflow.initial_state)
+        # reset publication info
+        pub_info = IWorkflowPublicationInfo(new_version, None)
+        if pub_info is not None:
+            pub_info.reset(complete=True)
         # update new version history
         source_state = IWorkflowState(self.context)
         state = IWorkflowState(new_version)
         state.history.clear()
         history = WorkflowHistoryItem(date=datetime.utcnow(),
                                       principal=self.request.principal.id,
-                                      comment=translate(_("Clone created from version {source} of {oid} (in « {"
-                                                          "state} » state)")).format(
+                                      comment=translate(_("Clone created from version {source} of {oid} "
+                                                          "(in « {state} » state)")).format(
                                           source=source_state.version_id,
                                           oid=ISequentialIdInfo(self.context).get_short_oid(),
                                           state=translate(IWorkflow(self.context).get_state_label(source_state.state)))