Use default prefix in attachments list
authorThierry Florac <tflorac@ulthar.net>
Wed, 17 Oct 2018 15:27:19 +0200
changeset 184 6815147a533f
parent 183 f543e56f0d07
child 185 32037c8b91e4
Use default prefix in attachments list
src/pyams_default_theme/component/association/templates/association-viewlet.pt
src/pyams_default_theme/component/association/viewlet.py
--- a/src/pyams_default_theme/component/association/templates/association-viewlet.pt	Tue Oct 16 11:16:57 2018 +0200
+++ b/src/pyams_default_theme/component/association/templates/association-viewlet.pt	Wed Oct 17 15:27:19 2018 +0200
@@ -1,4 +1,21 @@
 <ul class="associations">
+	<li tal:define="prefix view.attachments_title_prefix"
+		tal:repeat="item view.attachments">
+		<tal:var define="item_info view.get_link_info(item);
+						 description i18n:item.description;
+						 data i18n:item.data">
+			<p>
+				<tal:if condition="description">
+					${structure:tales:html(description)}
+					<br />
+				</tal:if>
+				<a tal:define="href_data tales:absolute_url(data);"
+				   href="${href_data}" target="_blank">
+					${prefix} ${item_info.user_title}
+				</a>
+			</p>
+		</tal:var>
+	</li>
 	<li tal:repeat="link view.links">
 		<tal:var define="link_info view.get_link_info(link);
 						 description i18n:link.description;">
@@ -15,20 +32,4 @@
 			</p>
 		</tal:var>
 	</li>
-	<li tal:repeat="item view.attachments">
-		<tal:var define="item_info view.get_link_info(item);
-						 description i18n:item.description;
-						 data i18n:item.data">
-			<p>
-				<tal:if condition="description">
-					${structure:tales:html(description)}
-					<br />
-				</tal:if>
-				<a tal:define="href_data tales:absolute_url(data);"
-				   href="${href_data}" target="_blank">
-					${item_info.user_title}
-				</a>
-			</p>
-		</tal:var>
-	</li>
 </ul>
--- a/src/pyams_default_theme/component/association/viewlet.py	Tue Oct 16 11:16:57 2018 +0200
+++ b/src/pyams_default_theme/component/association/viewlet.py	Wed Oct 17 15:27:19 2018 +0200
@@ -16,8 +16,9 @@
 
 from pyams_skin.layer import IPyAMSUserLayer
 from pyams_content.component.association.interfaces import IAssociationContainer, IAssociationInfo
-from pyams_content.component.extfile.interfaces import IExtFile
+from pyams_content.component.extfile.interfaces import IExtFile, IExtFileManagerInfo
 from pyams_content.component.links.interfaces import IBaseLink
+from pyams_i18n.interfaces import II18n
 from pyams_template.template import template_config
 from pyams_viewlet.viewlet import ViewContentProvider, contentprovider_config
 
@@ -49,3 +50,9 @@
                 self.attachments.append(item)
             elif IBaseLink.providedBy(item):
                 self.links.append(item)
+
+    @property
+    def attachments_title_prefix(self):
+        manager_info = IExtFileManagerInfo(self.request.root, None)
+        if manager_info is not None:
+            return II18n(manager_info).query_attribute('default_title_prefix', request=self.request)