Filter hidden paragraphs in summary
authorThierry Florac <thierry.florac@onf.fr>
Thu, 21 Sep 2017 16:06:29 +0200
changeset 182 0c23e1a6b1b6
parent 181 6d75755407b7
child 183 6a4964dad8aa
Filter hidden paragraphs in summary
src/pyams_content/component/paragraph/zmi/summary.py
src/pyams_content/component/paragraph/zmi/templates/summary.pt
--- a/src/pyams_content/component/paragraph/zmi/summary.py	Thu Sep 21 14:31:04 2017 +0200
+++ b/src/pyams_content/component/paragraph/zmi/summary.py	Thu Sep 21 16:06:29 2017 +0200
@@ -58,7 +58,8 @@
 
     def __init__(self, context, request):
         super(ParagraphsContainerSummaryView, self).__init__(context, request)
-        self.paragraphs = IParagraphContainer(self.context)
+        self.paragraphs = [para for para in IParagraphContainer(self.context).values()
+                           if para.visible]
         self.languages = II18nManager(self.context).get_languages()
 
     def render_paragraph(self, paragraph, language=None):
--- a/src/pyams_content/component/paragraph/zmi/templates/summary.pt	Thu Sep 21 14:31:04 2017 +0200
+++ b/src/pyams_content/component/paragraph/zmi/templates/summary.pt	Thu Sep 21 16:06:29 2017 +0200
@@ -1,9 +1,9 @@
 <tal:var define="langs view.languages" i18n:domain="pyams_content">
 	<tal:if condition="len(langs) == 1">
 		<div class="margin-top-10">
-			<tal:loop repeat="paragraph view.paragraphs.values()"
+			<tal:loop repeat="paragraph view.paragraphs"
 					  replace="structure view.render_paragraph(paragraph)" />
-			<p tal:condition="not:view.paragraphs.values()"
+			<p tal:condition="not:view.paragraphs"
 			   i18n:translate="">This content doesn't contain any paragraph.</p>
 		</div>
 	</tal:if>
@@ -24,9 +24,9 @@
 				<div tal:define="active python:'active' if repeat['lang'].start() else ''"
 					 tal:attributes="class string:clearfix tab-pane ${active} fade in padding-5;
 									 id string:paragraphs-${lang};">
-					<tal:loop repeat="paragraph view.paragraphs.values()"
+					<tal:loop repeat="paragraph view.paragraphs"
 							  replace="structure view.render_paragraph(paragraph, lang)" />
-					<p tal:condition="not:view.paragraphs.values()"
+					<p tal:condition="not:view.paragraphs"
 					   i18n:translate="">This content doesn't contain any paragraph.</p>
 				</div>
 			</tal:loop>