Use new TALES extensions
authorThierry Florac <thierry.florac@onf.fr>
Thu, 12 Jul 2018 17:35:20 +0200
changeset 840 3dcf565c711e
parent 839 37c3280e6def
child 841 d50743e69693
Use new TALES extensions
src/pyams_content/features/menu/portlet/navigation/zmi/double.py
src/pyams_content/features/menu/portlet/navigation/zmi/simple.py
src/pyams_content/features/menu/portlet/navigation/zmi/templates/double-preview.pt
src/pyams_content/features/menu/portlet/navigation/zmi/templates/simple-preview.pt
--- a/src/pyams_content/features/menu/portlet/navigation/zmi/double.py	Thu Jul 12 15:55:45 2018 +0200
+++ b/src/pyams_content/features/menu/portlet/navigation/zmi/double.py	Thu Jul 12 17:35:20 2018 +0200
@@ -16,7 +16,6 @@
 # import standard library
 
 # import interfaces
-from pyams_content.component.illustration.interfaces import IIllustration, ILinkIllustration
 from pyams_content.component.links.interfaces import IInternalLink
 from pyams_content.features.menu.portlet.navigation.interfaces.double import IDoubleNavigationPortletSettings, \
     IDoubleNavigationMenusContainer
@@ -89,16 +88,3 @@
             return True
         target = link.get_target()
         return (target is not None) and IWorkflowPublicationInfo(target).is_published()
-
-    @classmethod
-    def get_link_illustration(cls, link):
-        illustration = IIllustration(link, None)
-        if (illustration is None) or not illustration.has_data():
-            if IInternalLink.providedBy(link):
-                target = link.get_target()
-                if target is None:
-                    return
-                illustration = ILinkIllustration(target, None)
-                if (illustration is None) or not illustration.has_data():
-                    illustration = IIllustration(target, None)
-        return illustration
--- a/src/pyams_content/features/menu/portlet/navigation/zmi/simple.py	Thu Jul 12 15:55:45 2018 +0200
+++ b/src/pyams_content/features/menu/portlet/navigation/zmi/simple.py	Thu Jul 12 17:35:20 2018 +0200
@@ -16,7 +16,6 @@
 # import standard library
 
 # import interfaces
-from pyams_content.component.illustration.interfaces import IIllustration, ILinkIllustration
 from pyams_content.component.links.interfaces import IInternalLink
 from pyams_content.features.menu.portlet.navigation.interfaces.simple import ISimpleNavigationPortletSettings, \
     ISimpleNavigationMenu
@@ -89,16 +88,3 @@
             return True
         target = link.get_target()
         return (target is not None) and IWorkflowPublicationInfo(target).is_published()
-
-    @classmethod
-    def get_link_illustration(cls, link):
-        illustration = IIllustration(link, None)
-        if (illustration is None) or not illustration.has_data():
-            if IInternalLink.providedBy(link):
-                target = link.get_target()
-                if target is None:
-                    return
-                illustration = ILinkIllustration(target, None)
-                if (illustration is None) or not illustration.has_data():
-                    illustration = IIllustration(target, None)
-        return illustration
--- a/src/pyams_content/features/menu/portlet/navigation/zmi/templates/double-preview.pt	Thu Jul 12 15:55:45 2018 +0200
+++ b/src/pyams_content/features/menu/portlet/navigation/zmi/templates/double-preview.pt	Thu Jul 12 17:35:20 2018 +0200
@@ -1,22 +1,19 @@
-<div tal:define="settings view.settings">
+<div tal:define="settings view.settings" i18n:domain="pyams_content">
 	<strong tal:content="i18n:settings.title">Title</strong>
 	<tal:var define="subtitle i18n:settings.subtitle" condition="subtitle" content="subtitle" />
 	<ul>
-		<li tal:repeat="menu settings.menus.get_visible_items()">
+		<li tal:repeat="menu settings.menus.get_visible_items(request)">
 			<span tal:content="i18n:menu.title">Title</span>
 			<ul>
-				<li tal:repeat="link menu.get_visible_items()"
-					tal:attributes="illustration view.get_link_illustration(link);">
+				<li tal:repeat="link menu.get_visible_items(request)">
 					<i class="fa fa-fw fa-eye-slash text-danger hint opaque align-base"
 					   tal:condition="not:view.get_link_status(link)"
 					   title="Link target is not published!" i18n:attributes="title"></i>
 					<i class="fa fa-fw fa-file-image-o text-danger hint opaque align-base"
-					   tal:define="illustration view.get_link_illustration(link)"
+					   tal:define="illustration tales:pyams_illustration(link)"
 					   tal:condition="not:illustration and illustration.has_data()"
-					   title="Link has no illustration"></i>
+					   title="Link has no illustration" i18n:attributes="title"></i>
 					<tal:var define="info view.get_link_info(link)">
-						<span tal:content="info.user_title">User title</span>
-						&ndash;
 						<span tal:content="info.inner_title">Inner title</span>
 					</tal:var>
 				</li>
--- a/src/pyams_content/features/menu/portlet/navigation/zmi/templates/simple-preview.pt	Thu Jul 12 15:55:45 2018 +0200
+++ b/src/pyams_content/features/menu/portlet/navigation/zmi/templates/simple-preview.pt	Thu Jul 12 17:35:20 2018 +0200
@@ -2,18 +2,15 @@
 	<strong tal:content="i18n:settings.title">Title</strong>
 	<tal:var define="subtitle i18n:settings.subtitle" condition="subtitle" content="subtitle" />
 	<ul>
-		<li tal:repeat="link settings.links.get_visible_items()"
-			tal:attributes="illustration view.get_link_illustration(link);">
+		<li tal:repeat="link settings.links.get_visible_items(request)">
 			<i class="fa fa-fw fa-eye-slash text-danger hint opaque align-base"
 			   tal:condition="not:view.get_link_status(link)"
 			   title="Link target is not published!" i18n:attributes="title"></i>
 			<i class="fa fa-fw fa-file-image-o text-danger hint opaque align-base"
-			   tal:define="illustration view.get_link_illustration(link)"
+			   tal:define="illustration tales:pyams_illustration(link)"
 			   tal:condition="not:illustration and illustration.has_data()"
 			   title="Link has no illustration" i18n:attributes="title"></i>
 			<tal:var define="info view.get_link_info(link)">
-				<span tal:content="info.user_title">User title</span>
-				&ndash;
 				<span tal:content="info.inner_title">Inner title</span>
 			</tal:var>
 		</li>