Added source folder to data types, and removed unused attributes
authorThierry Florac <thierry.florac@onf.fr>
Mon, 07 Jan 2019 09:58:55 +0100
changeset 1213 22b0a3be985d
parent 1212 93ed7641c8f5
child 1214 584bf988caa8
Added source folder to data types, and removed unused attributes
src/pyams_content/shared/common/interfaces/types.py
src/pyams_content/shared/common/types.py
--- a/src/pyams_content/shared/common/interfaces/types.py	Sun Jan 06 18:39:25 2019 +0100
+++ b/src/pyams_content/shared/common/interfaces/types.py	Mon Jan 07 09:58:55 2019 +0100
@@ -12,21 +12,17 @@
 
 __docformat__ = 'restructuredtext'
 
+from zope.container.constraints import contains
+from zope.container.interfaces import IContainer
+from zope.interface import Attribute
+from zope.location.interfaces import ILocation
+from zope.schema import TextLine, List, Choice
 
-# import standard library
-
-# import interfaces
 from pyams_content.reference.pictograms.interfaces import PICTOGRAM_VOCABULARY
 from pyams_content.shared.common.interfaces import ISharedTool, IWfSharedContent, IBaseContentPortalContext
+from pyams_i18n.schema import I18nTextLineField
 from pyams_portal.interfaces import IPortalContext
-from zope.container.interfaces import IContainer
-from zope.location.interfaces import ILocation
-
-# import packages
-from pyams_i18n.schema import I18nTextLineField
-from zope.container.constraints import contains
-from zope.interface import Attribute
-from zope.schema import TextLine, List, Choice
+from pyams_sequence.schema import InternalReferenceField
 
 from pyams_content import _
 
@@ -47,31 +43,19 @@
     label = I18nTextLineField(title=_("Label"),
                               required=True)
 
+    source_folder = InternalReferenceField(title=_("Source folder"),
+                                           description=_("Source folder (or search engine) to which content is attached; "
+                                                         "if this reference is set, canonical URL will be based on this "
+                                                         "object's URL"),
+                                           required=False)
+
+    def get_source_folder(self):
+        """Return source folder as object"""
+
     navigation_label = I18nTextLineField(title=_("Navigation label"),
                                          description=_("Label used for navigation entries"),
                                          required=False)
 
-    tabfolder_label = I18nTextLineField(title=_("Tab-folder label"),
-                                        description=_("Label used to include into tab folder"),
-                                        required=False)
-
-    seealso_label = I18nTextLineField(title=_("'See also' label"),
-                                      description=_("This label can be used when contents of this type will be "
-                                                    "displayed in a 'See also' entries block"),
-                                      required=False)
-
-    single_label = I18nTextLineField(title=_("'Single value' label"),
-                                     description=_("Label given to this type when a single value is displayed"),
-                                     required=False)
-
-    seeall_label = I18nTextLineField(title=_("'Link to list' label"),
-                                     description=_("Label used to display a link to a list of items of this type"),
-                                     required=False)
-
-    next_label = I18nTextLineField(title=_("Next content label"),
-                                   description=_("Label used to announce next date for this type"),
-                                   required=False)
-
     pictogram = Choice(title=_("Pictogram"),
                        description=_("Pictogram associated with this data type"),
                        vocabulary=PICTOGRAM_VOCABULARY,
--- a/src/pyams_content/shared/common/types.py	Sun Jan 06 18:39:25 2019 +0100
+++ b/src/pyams_content/shared/common/types.py	Mon Jan 07 09:58:55 2019 +0100
@@ -12,55 +12,51 @@
 
 __docformat__ = 'restructuredtext'
 
+from persistent import Persistent
+from pyramid.events import subscriber
+from zope.container.contained import Contained
+from zope.container.ordered import OrderedContainer
+from zope.interface import implementer
+from zope.lifecycleevent.interfaces import IObjectAddedEvent
+from zope.location.interfaces import ISublocations
+from zope.schema import getFieldsInOrder
+from zope.schema.fieldproperty import FieldProperty
+from zope.schema.vocabulary import SimpleVocabulary, SimpleTerm
+from zope.traversing.interfaces import ITraversable
 
-# import standard library
-
-# import interfaces
 from pyams_content.component.extfile.interfaces import IExtFileContainerTarget
 from pyams_content.component.links.interfaces import ILinkContainerTarget
 from pyams_content.component.paragraph.interfaces import IParagraphContainerTarget
 from pyams_content.component.theme.interfaces import IThemesTarget, IThemesInfo
 from pyams_content.interfaces import MANAGE_TOOL_PERMISSION
+from pyams_content.shared.common import WfSharedContent, IWfSharedContentFactory
 from pyams_content.shared.common.interfaces import ISharedContentFactory
 from pyams_content.shared.common.interfaces.types import IDataType, ISubType, IBaseDataType, ITypedSharedTool, \
     ITypedDataManager, DATA_MANAGER_ANNOTATION_KEY, DATA_TYPES_VOCABULARY, DATA_TYPE_FIELDS_VOCABULARY, \
     IWfTypedSharedContent, DATA_SUBTYPES_VOCABULARY, ALL_DATA_TYPES_VOCABULARY
+from pyams_content.shared.common.manager import SharedTool
 from pyams_form.interfaces.form import IFormContextPermissionChecker
 from pyams_i18n.interfaces import II18n
-from zope.lifecycleevent.interfaces import IObjectAddedEvent
-from zope.location.interfaces import ISublocations
-from zope.traversing.interfaces import ITraversable
-
-# import packages
-from persistent import Persistent
-from pyams_content.shared.common import WfSharedContent, IWfSharedContentFactory
-from pyams_content.shared.common.manager import SharedTool
+from pyams_sequence.reference import get_reference_target
 from pyams_utils.adapter import adapter_config, ContextAdapter, get_annotation_adapter
 from pyams_utils.registry import get_local_registry
 from pyams_utils.request import check_request
 from pyams_utils.traversing import get_parent
 from pyams_utils.vocabulary import vocabulary_config
-from pyramid.events import subscriber
-from zope.container.contained import Contained
-from zope.container.ordered import OrderedContainer
-from zope.interface import implementer
-from zope.schema import getFieldsInOrder
-from zope.schema.fieldproperty import FieldProperty
-from zope.schema.vocabulary import SimpleVocabulary, SimpleTerm
 
 
 class BaseDataType(Persistent, Contained):
     """Base data type"""
 
     label = FieldProperty(IBaseDataType['label'])
+    source_folder = FieldProperty(IBaseDataType['source_folder'])
     navigation_label = FieldProperty(IBaseDataType['navigation_label'])
-    tabfolder_label = FieldProperty(IBaseDataType['tabfolder_label'])
-    seealso_label = FieldProperty(IBaseDataType['seealso_label'])
-    single_label = FieldProperty(IBaseDataType['single_label'])
-    seeall_label = FieldProperty(IBaseDataType['seeall_label'])
-    next_label = FieldProperty(IBaseDataType['next_label'])
     pictogram = FieldProperty(IBaseDataType['pictogram'])
 
+    def get_source_folder(self):
+        if self.source_folder is not None:
+            return get_reference_target(self.source_folder)
+
 
 @implementer(ISubType, IParagraphContainerTarget, IExtFileContainerTarget, ILinkContainerTarget)
 class SubType(BaseDataType):