Added navigation mode to sites and hubs managers
authorThierry Florac <tflorac@ulthar.net>
Mon, 01 Feb 2021 13:31:22 +0100
changeset 1452 f5eca01f0a1d
parent 1451 9539c5209338
child 1453 5b3285e47b62
Added navigation mode to sites and hubs managers
src/pyams_content/shared/hub/manager.py
src/pyams_content/shared/hub/zmi/manager.py
src/pyams_content/shared/site/interfaces.py
src/pyams_content/shared/site/manager.py
src/pyams_content/shared/site/zmi/manager.py
--- a/src/pyams_content/shared/hub/manager.py	Wed Jan 27 16:14:21 2021 +0100
+++ b/src/pyams_content/shared/hub/manager.py	Mon Feb 01 13:31:22 2021 +0100
@@ -54,6 +54,7 @@
     navigation_header = FieldProperty(IHubManager['navigation_header'])
     description = FieldProperty(IHubManager['description'])
     notepad = FieldProperty(IHubManager['notepad'])
+    navigation_mode = FieldProperty(IHubManager['navigation_mode'])
 
     allowed_paragraphs = FieldProperty(IParagraphFactorySettings['allowed_paragraphs'])
     auto_created_paragraphs = FieldProperty(IParagraphFactorySettings['auto_created_paragraphs'])
--- a/src/pyams_content/shared/hub/zmi/manager.py	Wed Jan 27 16:14:21 2021 +0100
+++ b/src/pyams_content/shared/hub/zmi/manager.py	Mon Feb 01 13:31:22 2021 +0100
@@ -108,4 +108,5 @@
 
     fields = field.Fields(IHubManager).select('title', 'short_name', 'header',
                                               'navigation_header', 'description', 'notepad') + \
-        field.Fields(IBaseSharedTool).select('shared_content_workflow')
+        field.Fields(IBaseSharedTool).select('shared_content_workflow') + \
+        field.Fields(IHubManager).select('navigation_mode')
--- a/src/pyams_content/shared/site/interfaces.py	Wed Jan 27 16:14:21 2021 +0100
+++ b/src/pyams_content/shared/site/interfaces.py	Mon Feb 01 13:31:22 2021 +0100
@@ -35,16 +35,18 @@
 from pyams_content import _
 
 
-FOLDER_REDIRECT_DISPLAY_MODE = 'redirect'
-FOLDER_TEMPLATE_DISPLAY_MODE = 'template'
+SITE_CONTAINER_REDIRECT_MODE = 'redirect'
+SITE_CONTAINER_TEMPLATE_MODE = 'template'
 
-FOLDER_DISPLAY_MODES = OrderedDict((
-    (FOLDER_REDIRECT_DISPLAY_MODE, _("Redirect to first visible sub-folder or content")),
-    (FOLDER_TEMPLATE_DISPLAY_MODE, _("Use presentation template"))
+SITE_CONTAINER_NAVIGATION_MODES = OrderedDict((
+    (SITE_CONTAINER_REDIRECT_MODE, _("Redirect to first visible sub-folder or content")),
+    (SITE_CONTAINER_TEMPLATE_MODE, _("Use presentation template"))
 ))
 
-FOLDER_DISPLAY_MODE_VOCABULARY = SimpleVocabulary([SimpleTerm(v, title=t)
-                                                   for v, t in FOLDER_DISPLAY_MODES.items()])
+SITE_CONTAINER_NAVIGATION_MODES_VOCABULARY = SimpleVocabulary([
+    SimpleTerm(v, title=t)
+    for v, t in SITE_CONTAINER_NAVIGATION_MODES.items()
+])
 
 
 class ISiteElement(IContained, IDeletableElement):
@@ -114,8 +116,8 @@
     navigation_mode = Choice(title=_("Navigation mode"),
                              description=_("Folder behaviour when navigating to folder URL"),
                              required=True,
-                             vocabulary=FOLDER_DISPLAY_MODE_VOCABULARY,
-                             default=FOLDER_REDIRECT_DISPLAY_MODE)
+                             vocabulary=SITE_CONTAINER_NAVIGATION_MODES_VOCABULARY,
+                             default=SITE_CONTAINER_REDIRECT_MODE)
 
 
 class ISiteFolderFactory(Interface):
@@ -153,6 +155,12 @@
                    description=_("Internal information to be known about this content"),
                    required=False)
 
+    navigation_mode = Choice(title=_("Navigation mode"),
+                             description=_("Site behaviour when navigating to site URL"),
+                             required=True,
+                             vocabulary=SITE_CONTAINER_NAVIGATION_MODES_VOCABULARY,
+                             default=SITE_CONTAINER_TEMPLATE_MODE)
+
 
 class ISiteManagerFactory(Interface):
     """Site manager factory interface"""
--- a/src/pyams_content/shared/site/manager.py	Wed Jan 27 16:14:21 2021 +0100
+++ b/src/pyams_content/shared/site/manager.py	Mon Feb 01 13:31:22 2021 +0100
@@ -62,6 +62,7 @@
     header = FieldProperty(ISiteManager['header'])
     description = FieldProperty(ISiteManager['description'])
     notepad = FieldProperty(ISiteManager['notepad'])
+    navigation_mode = FieldProperty(ISiteManager['navigation_mode'])
 
     allowed_paragraphs = FieldProperty(IParagraphFactorySettings['allowed_paragraphs'])
     auto_created_paragraphs = FieldProperty(IParagraphFactorySettings['auto_created_paragraphs'])
--- a/src/pyams_content/shared/site/zmi/manager.py	Wed Jan 27 16:14:21 2021 +0100
+++ b/src/pyams_content/shared/site/zmi/manager.py	Mon Feb 01 13:31:22 2021 +0100
@@ -164,7 +164,8 @@
 
     fields = field.Fields(ISiteManager).select('title', 'short_name', 'header', 'description',
                                                'notepad') + \
-        field.Fields(IBaseSharedTool).select('shared_content_workflow')
+        field.Fields(IBaseSharedTool).select('shared_content_workflow') + \
+        field.Fields(ISiteManager).select('navigation_mode')
 
 
 @subscriber(IDataExtractedEvent, form_selector=SiteManagerAddForm)