Moved folder-related views to "folder" module
authorThierry Florac <thierry.florac@onf.fr>
Mon, 12 Nov 2018 11:35:52 +0100
changeset 209 26e95dcab6aa
parent 208 c46b86b87cfd
child 210 228dfc67f066
Moved folder-related views to "folder" module
src/pyams_default_theme/shared/site/__init__.py
src/pyams_default_theme/shared/site/folder.py
--- a/src/pyams_default_theme/shared/site/__init__.py	Sun Nov 11 20:05:10 2018 +0100
+++ b/src/pyams_default_theme/shared/site/__init__.py	Mon Nov 12 11:35:52 2018 +0100
@@ -12,19 +12,14 @@
 
 __docformat__ = 'restructuredtext'
 
-from pyramid.httpexceptions import HTTPSeeOther
 from zope.interface import Interface
 
-from pyams_content.shared.site.interfaces import FOLDER_REDIRECT_DISPLAY_MODE, ISiteFolder, ISiteManager
+from pyams_content.shared.site.interfaces import ISiteFolder, ISiteManager
 from pyams_i18n.interfaces import II18n
-from pyams_pagelet.pagelet import pagelet_config
-from pyams_portal.views import PortalContextIndexPage, PortalContextPreviewPage
 from pyams_skin.interfaces.metas import IHTMLContentMetas
 from pyams_skin.layer import IPyAMSUserLayer
 from pyams_skin.metas import ContentMeta, HTMLTagMeta
 from pyams_utils.adapter import ContextRequestViewAdapter, adapter_config
-from pyams_utils.interfaces import VIEW_SYSTEM_PERMISSION
-from pyams_utils.url import relative_url
 
 
 @adapter_config(name='title', context=(ISiteManager, IPyAMSUserLayer, Interface), provides=IHTMLContentMetas)
@@ -43,27 +38,3 @@
             description = i18n.query_attribute('header', request=self.request)
         if description:
             yield ContentMeta('description', description)
-
-
-@pagelet_config(name='', context=ISiteFolder, layer=IPyAMSUserLayer)
-class SiteFolderIndexPage(PortalContextIndexPage):
-    """Site folder index page"""
-
-    def __call__(self, **kwargs):
-        if self.context.navigation_mode == FOLDER_REDIRECT_DISPLAY_MODE:
-            target = next(self.context.get_visible_items(self.request), None)
-            if target is not None:
-                return HTTPSeeOther(relative_url(target, request=self.request))
-        return super(SiteFolderIndexPage, self).__call__(**kwargs)
-
-
-@pagelet_config(name='preview.html', context=ISiteFolder, layer=IPyAMSUserLayer, permission=VIEW_SYSTEM_PERMISSION)
-class SiteFolderPreviewPage(PortalContextPreviewPage):
-    """Site folder preview page"""
-
-    def __call__(self, **kwargs):
-        if self.context.navigation_mode == FOLDER_REDIRECT_DISPLAY_MODE:
-            target = next(self.context.get_visible_items(self.request), None)
-            if target is not None:
-                return HTTPSeeOther(relative_url(target, request=self.request, view_name='preview.html'))
-        return super(SiteFolderPreviewPage, self).__call__(**kwargs)
--- a/src/pyams_default_theme/shared/site/folder.py	Sun Nov 11 20:05:10 2018 +0100
+++ b/src/pyams_default_theme/shared/site/folder.py	Mon Nov 12 11:35:52 2018 +0100
@@ -12,12 +12,18 @@
 
 __docformat__ = 'restructuredtext'
 
-from pyams_content.shared.site.interfaces import ISiteFolder
+from pyramid.httpexceptions import HTTPSeeOther
+
+from pyams_content.shared.site import ISiteElementNavigation
+from pyams_content.shared.site.interfaces import FOLDER_REDIRECT_DISPLAY_MODE, ISiteFolder
 from pyams_default_theme.interfaces import IContentSummaryInfo
-from pyams_content.shared.site import ISiteElementNavigation
 from pyams_i18n.interfaces import II18n
+from pyams_pagelet.pagelet import pagelet_config
+from pyams_portal.views import PortalContextIndexPage, PortalContextPreviewPage
 from pyams_skin.layer import IPyAMSUserLayer
 from pyams_utils.adapter import ContextRequestAdapter, adapter_config
+from pyams_utils.interfaces import VIEW_SYSTEM_PERMISSION
+from pyams_utils.url import relative_url
 from pyams_workflow.interfaces import IWorkflowPublicationInfo
 
 from pyams_content import _
@@ -52,3 +58,27 @@
             return None
 
     button_title = _("Consult folder")
+
+
+@pagelet_config(name='', context=ISiteFolder, layer=IPyAMSUserLayer)
+class SiteFolderIndexPage(PortalContextIndexPage):
+    """Site folder index page"""
+
+    def __call__(self, **kwargs):
+        if self.context.navigation_mode == FOLDER_REDIRECT_DISPLAY_MODE:
+            target = next(self.context.get_visible_items(self.request), None)
+            if target is not None:
+                return HTTPSeeOther(relative_url(target, request=self.request))
+        return super(SiteFolderIndexPage, self).__call__(**kwargs)
+
+
+@pagelet_config(name='preview.html', context=ISiteFolder, layer=IPyAMSUserLayer, permission=VIEW_SYSTEM_PERMISSION)
+class SiteFolderPreviewPage(PortalContextPreviewPage):
+    """Site folder preview page"""
+
+    def __call__(self, **kwargs):
+        if self.context.navigation_mode == FOLDER_REDIRECT_DISPLAY_MODE:
+            target = next(self.context.get_visible_items(self.request), None)
+            if target is not None:
+                return HTTPSeeOther(relative_url(target, request=self.request, view_name='preview.html'))
+        return super(SiteFolderPreviewPage, self).__call__(**kwargs)