Updated thumbnails view to get correct timestamp for each thumbnail
authorThierry Florac <thierry.florac@onf.fr>
Mon, 02 Jul 2018 17:06:34 +0200
changeset 112 c84c4fc33e5b
parent 111 6d7a963f5c98
child 113 97e1ed0fc7c7
Updated thumbnails view to get correct timestamp for each thumbnail
src/pyams_file/zmi/image.py
src/pyams_file/zmi/templates/image-thumbnails.pt
--- a/src/pyams_file/zmi/image.py	Thu Jun 28 10:38:47 2018 +0200
+++ b/src/pyams_file/zmi/image.py	Mon Jul 02 17:06:34 2018 +0200
@@ -643,9 +643,10 @@
                 selection = thumbnails.get_selection(name)
                 transaction.commit()
                 thumbnails = IThumbnail(selection)
-            thumbnails.get_thumbnail('200x128')
+            thumbnail = thumbnails.get_thumbnail('200x128')
             thumbnailers.setdefault(translate(adapter.section), []).append({'name': name,
-                                                                            'label': translate(adapter.label)})
+                                                                            'label': translate(adapter.label),
+                                                                            'thumbnail': thumbnail})
         transaction.commit()
         return thumbnailers
 
--- a/src/pyams_file/zmi/templates/image-thumbnails.pt	Thu Jun 28 10:38:47 2018 +0200
+++ b/src/pyams_file/zmi/templates/image-thumbnails.pt	Mon Jul 02 17:06:34 2018 +0200
@@ -1,5 +1,7 @@
-<tal:loop repeat="thumbnailer view.get_thumbnails().items()" i18n:domain="pyams_file">
-	<tal:var define="section thumbnailer[0]; adapters thumbnailer[1];">
+<tal:loop define="thumbnails extension:thumbnails(context)"
+		  repeat="thumbnailer view.get_thumbnails().items()" i18n:domain="pyams_file">
+	<tal:var define="section thumbnailer[0];
+					 adapters thumbnailer[1];">
 		<fieldset class="no-padding">
 			<legend class="inner switcher" data-ams-switcher-state="open" tal:content="section"></legend>
 			<tal:loop repeat="adapter adapters">
@@ -10,8 +12,9 @@
 					<div class="bordered">
 						<img tal:define="base extension:absolute_url(context);
 										 name adapter['name'];
-										 thname '{0}:'.format(name) if name else '';"
-							 tal:attributes="src string:${base}/++thumb++${thname}200x128.jpeg?_=${extension:timestamp(context)}" />
+										 thname '{0}:'.format(name) if name else '';
+										 thumbnail adapter['thumbnail'];"
+							 tal:attributes="src string:${base}/++thumb++${thname}200x128.jpeg?_=${extension:timestamp(thumbnail)}" />
 					</div>
 				</div>
 			</tal:loop>