Added portal adapter to shared contents
authorThierry Florac <thierry.florac@onf.fr>
Mon, 11 Jun 2018 14:59:38 +0200
changeset 613 cf14f3928a90
parent 612 04f5df7ee1d2
child 614 0b5ec468c64b
Added portal adapter to shared contents
src/pyams_content/shared/blog/__init__.py
src/pyams_content/shared/news/__init__.py
src/pyams_content/shared/site/__init__.py
--- a/src/pyams_content/shared/blog/__init__.py	Mon Jun 11 14:58:31 2018 +0200
+++ b/src/pyams_content/shared/blog/__init__.py	Mon Jun 11 14:59:38 2018 +0200
@@ -23,16 +23,18 @@
 from pyams_content.features.review.interfaces import IReviewTarget
 from pyams_content.shared.blog.interfaces import IWfBlogPost, BLOG_CONTENT_TYPE, BLOG_CONTENT_NAME, IBlogPost, \
     IWfBlogPostFactory
+from pyams_portal.interfaces import IPortalContext, IPortalPage, PORTAL_PAGE_KEY
 from pyams_workflow.interfaces import IWorkflow, IWorkflowVersions, IWorkflowState
 
 # import packages
 from pyams_content.shared.common import WfSharedContent, register_content_type, SharedContent, IWfSharedContentFactory
-from pyams_utils.adapter import adapter_config
+from pyams_content.shared.common.portal import SharedContentPortalPage
+from pyams_utils.adapter import adapter_config, get_annotation_adapter
 from zope.interface import implementer, provider
 
 
-@implementer(IWfBlogPost, IParagraphContainerTarget, IThemesTarget,
-             IIllustrationTarget, IPreviewTarget, IReviewTarget)
+@implementer(IWfBlogPost, IParagraphContainerTarget, IThemesTarget, IIllustrationTarget,
+             IPortalContext, IPreviewTarget, IReviewTarget)
 class WfBlogPost(WfSharedContent):
     """Base blog post"""
 
@@ -58,3 +60,9 @@
 @adapter_config(context=IWfBlogPostFactory, provides=IWfSharedContentFactory)
 def blog_post_content_factory(context):
     return WfBlogPost
+
+
+@adapter_config(context=IWfBlogPost, provides=IPortalPage)
+def blog_post_portal_page_adapter(context):
+    """Blog post portal page adapter"""
+    return get_annotation_adapter(context, PORTAL_PAGE_KEY, SharedContentPortalPage)
--- a/src/pyams_content/shared/news/__init__.py	Mon Jun 11 14:58:31 2018 +0200
+++ b/src/pyams_content/shared/news/__init__.py	Mon Jun 11 14:59:38 2018 +0200
@@ -23,15 +23,17 @@
 from pyams_content.features.review.interfaces import IReviewTarget
 from pyams_content.shared.news.interfaces import INewsEvent, IWfNewsEvent, NEWS_CONTENT_TYPE, NEWS_CONTENT_NAME, \
     IWfNewsEventFactory
+from pyams_portal.interfaces import IPortalContext, IPortalPage, PORTAL_PAGE_KEY
 
 # import packages
 from pyams_content.shared.common import SharedContent, WfSharedContent, register_content_type, IWfSharedContentFactory
-from pyams_utils.adapter import adapter_config
+from pyams_content.shared.common.portal import SharedContentPortalPage
+from pyams_utils.adapter import adapter_config, get_annotation_adapter
 from zope.interface import implementer, provider
 
 
 @implementer(IWfNewsEvent, IIllustrationTarget, IParagraphContainerTarget, IThemesTarget,
-             IPreviewTarget, IReviewTarget)
+             IPortalContext, IPreviewTarget, IReviewTarget)
 class WfNewsEvent(WfSharedContent):
     """Base news event"""
 
@@ -50,3 +52,9 @@
 @adapter_config(context=IWfNewsEventFactory, provides=IWfSharedContentFactory)
 def news_event_content_factory(context):
     return WfNewsEvent
+
+
+@adapter_config(context=IWfNewsEvent, provides=IPortalPage)
+def news_event_portal_page_adapter(context):
+    """News event portal page adapter"""
+    return get_annotation_adapter(context, PORTAL_PAGE_KEY, SharedContentPortalPage)
--- a/src/pyams_content/shared/site/__init__.py	Mon Jun 11 14:58:31 2018 +0200
+++ b/src/pyams_content/shared/site/__init__.py	Mon Jun 11 14:59:38 2018 +0200
@@ -23,16 +23,18 @@
 from pyams_content.features.review.interfaces import IReviewTarget
 from pyams_content.shared.site.interfaces import ITopic, IWfTopic, TOPIC_CONTENT_NAME, \
     TOPIC_CONTENT_TYPE, IWfTopicFactory
+from pyams_portal.interfaces import IPortalContext, IPortalPage, PORTAL_PAGE_KEY
 from pyams_workflow.interfaces import IWorkflow, IWorkflowVersions, IWorkflowState
 
 # import packages
 from pyams_content.shared.common import SharedContent, WfSharedContent, register_content_type, IWfSharedContentFactory
-from pyams_utils.adapter import adapter_config
+from pyams_content.shared.common.portal import SharedContentPortalPage
+from pyams_utils.adapter import adapter_config, get_annotation_adapter
 from zope.interface import implementer, provider
 
 
-@implementer(IWfTopic, IParagraphContainerTarget, IThemesTarget,
-             IIllustrationTarget, IPreviewTarget, IReviewTarget)
+@implementer(IWfTopic, IParagraphContainerTarget, IThemesTarget, IIllustrationTarget,
+             IPortalContext, IPreviewTarget, IReviewTarget)
 class WfTopic(WfSharedContent):
     """Base topic"""
 
@@ -60,3 +62,9 @@
 @adapter_config(context=IWfTopicFactory, provides=IWfSharedContentFactory)
 def topic_content_factory(context):
     return WfTopic
+
+
+@adapter_config(context=IWfTopic, provides=IPortalPage)
+def topic_portal_page_adapter(context):
+    """Topic portal page adapter"""
+    return get_annotation_adapter(context, PORTAL_PAGE_KEY, SharedContentPortalPage)