--- a/src/pyams_content/shared/common/interfaces/types.py Wed Sep 25 15:11:13 2019 +0200
+++ b/src/pyams_content/shared/common/interfaces/types.py Wed Sep 25 17:21:20 2019 +0200
@@ -10,20 +10,22 @@
# FOR A PARTICULAR PURPOSE.
#
-__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
+from zope.schema import Bool, Choice, List, TextLine
from pyams_content.reference.pictograms.interfaces import PICTOGRAM_VOCABULARY
-from pyams_content.shared.common.interfaces import ISharedTool, IWfSharedContent, IBaseContentPortalContext
+from pyams_content.shared.common.interfaces import IBaseContentPortalContext, ISharedTool, \
+ IWfSharedContent
from pyams_i18n.schema import I18nTextLineField
from pyams_portal.interfaces import IPortalContext
from pyams_sequence.schema import InternalReferenceField
+
+__docformat__ = 'restructuredtext'
+
from pyams_content import _
@@ -44,9 +46,10 @@
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"),
+ 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):
@@ -71,6 +74,14 @@
contains(ISubType)
+ display_as_tag = Bool(title=_("Display as tag?"),
+ description=_("Some portlets renderers can display a small tag above "
+ "each content to show their content type; if this option "
+ "is checked, data type label will be displayed instead "
+ "of content type"),
+ required=True,
+ default=False)
+
field_names = List(title=_("Field names"),
description=_("List of fields associated with this data type"),
value_type=Choice(vocabulary=DATA_TYPE_FIELDS_VOCABULARY))
--- a/src/pyams_content/shared/common/types.py Wed Sep 25 15:11:13 2019 +0200
+++ b/src/pyams_content/shared/common/types.py Wed Sep 25 17:21:20 2019 +0200
@@ -10,8 +10,6 @@
# FOR A PARTICULAR PURPOSE.
#
-__docformat__ = 'restructuredtext'
-
from persistent import Persistent
from pyramid.events import subscriber
from zope.container.contained import Contained
@@ -21,24 +19,25 @@
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.schema.vocabulary import SimpleTerm, SimpleVocabulary
from zope.traversing.interfaces import ITraversable
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.component.theme.interfaces import IThemesInfo, IThemesTarget
from pyams_content.interfaces import MANAGE_TOOL_PERMISSION
-from pyams_content.shared.common import WfSharedContent, IWfSharedContentFactory
+from pyams_content.shared.common import IWfSharedContentFactory, WfSharedContent
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.interfaces.types import ALL_DATA_TYPES_VOCABULARY, \
+ DATA_MANAGER_ANNOTATION_KEY, DATA_SUBTYPES_VOCABULARY, DATA_TYPES_VOCABULARY, \
+ DATA_TYPE_FIELDS_VOCABULARY, IBaseDataType, IDataType, ISubType, ITypedDataManager, \
+ ITypedSharedTool, IWfTypedSharedContent
from pyams_content.shared.common.manager import SharedTool
from pyams_form.interfaces.form import IFormContextPermissionChecker
from pyams_i18n.interfaces import II18n
from pyams_sequence.reference import get_reference_target
-from pyams_utils.adapter import adapter_config, ContextAdapter, get_annotation_adapter
+from pyams_utils.adapter import ContextAdapter, adapter_config, get_annotation_adapter
from pyams_utils.factory import factory_config
from pyams_utils.registry import get_local_registry
from pyams_utils.request import check_request
@@ -46,6 +45,9 @@
from pyams_utils.vocabulary import vocabulary_config
+__docformat__ = 'restructuredtext'
+
+
class BaseDataType(Persistent, Contained):
"""Base data type"""
@@ -68,6 +70,7 @@
class DataType(BaseDataType, OrderedContainer):
"""Data type persistent class"""
+ display_as_tag = FieldProperty(IDataType['display_as_tag'])
field_names = FieldProperty(IDataType['field_names'])
@@ -164,7 +167,8 @@
for tool in registry.getAllUtilitiesRegisteredFor(ITypedSharedTool):
manager = ITypedDataManager(tool)
terms.extend([SimpleTerm(datatype.__name__,
- title=II18n(datatype).query_attribute('label', request=request))
+ title=II18n(datatype).query_attribute('label',
+ request=request))
for datatype in manager.values()])
terms.sort(key=lambda x: x.title)
super(AllTypedSharedToolDataTypesVocabulary, self).__init__(terms)