Corrected thumbnails access
authorThierry Florac <thierry.florac@onf.fr>
Fri, 04 Dec 2015 16:34:30 +0100
changeset 19 179f9381965b
parent 18 54505b8bad88
child 20 30a34a5cb19c
Corrected thumbnails access
src/pyams_media/zmi/__init__.py
src/pyams_media/zmi/media.py
src/pyams_media/zmi/templates/video-conversions.pt
src/pyams_media/zmi/templates/video-thumbnail.pt
--- a/src/pyams_media/zmi/__init__.py	Fri Dec 04 16:33:41 2015 +0100
+++ b/src/pyams_media/zmi/__init__.py	Fri Dec 04 16:34:30 2015 +0100
@@ -69,8 +69,9 @@
     id = 'video_properties'
     tab_label = _("Video conversion")
     legend = None
-    fields = field.Fields(IMediaConversionUtility).select('video_formats', 'video_frame_size', 'video_audio_sampling',
-                                                          'video_audio_bitrate', 'video_quantisation')
+    fields = field.Fields(IMediaConversionUtility).select('video_formats', 'video_frame_size',
+                                                          'video_bitrate', 'video_quantisation',
+                                                          'video_audio_sampling', 'video_audio_bitrate')
     label_css_class = 'control-label col-md-4'
     input_css_class = 'col-md-8'
 
--- a/src/pyams_media/zmi/media.py	Fri Dec 04 16:33:41 2015 +0100
+++ b/src/pyams_media/zmi/media.py	Fri Dec 04 16:34:30 2015 +0100
@@ -99,6 +99,12 @@
                                                  extension=converter.format)
         return name in conversions
 
+    def get_conversion(self, converter, frame_size):
+        conversions = IMediaConversions(self.context)
+        name = 'video{width}.{extension}'.format(width='-{0}'.format(frame_size) if frame_size else '',
+                                                 extension=converter.format)
+        return conversions.get(name)
+
 
 #
 # Audio conversions
--- a/src/pyams_media/zmi/templates/video-conversions.pt	Fri Dec 04 16:33:41 2015 +0100
+++ b/src/pyams_media/zmi/templates/video-conversions.pt	Fri Dec 04 16:34:30 2015 +0100
@@ -19,8 +19,13 @@
 			<td tal:content="converter.label" i18n:translate="" class="padding-right-20"></td>
 			<td tal:define="converted view.has_conversion(converter, None)"
 				class="text-align-center">
-				<span tal:condition="converted"
-					  class="txt-color-green" i18n:translate="">OK</span>
+				<tal:if condition="converted">
+					<a tal:define="conversion view.get_conversion(converter, None);
+								   url extension:absolute_url(conversion);"
+					   tal:attributes="href string:${url}?download=1">
+						<span class="txt-color-green" i18n:translate="">OK</span>
+					</a>
+				</tal:if>
 				<span tal:condition="not converted"
 					  class="txt-color-orange" i18n:translate="">Waiting...</span>
 			</td>
@@ -28,11 +33,16 @@
 				<td class="text-center padding-x-10"
 					tal:define="frame_width format[1][0];
 								maybe frame_width < original_size[0];
-								converted view.has_conversion(converter, format);">
+								converted view.has_conversion(converter, format[0]);">
 					<span tal:condition="not maybe">N/A</span>
 					<tal:if condition="maybe">
-						<span tal:condition="converted"
-							  class="txt-color-green" i18n:translate="">OK</span>
+						<tal:if condition="converted">
+							<a tal:define="conversion view.get_conversion(converter, format[0]);
+										   url extension:absolute_url(conversion);"
+							   tal:attributes="href string:${url}?download=1">
+								<span class="txt-color-green" i18n:translate="">OK</span>
+							</a>
+						</tal:if>
 						<span tal:condition="not converted"
 							  class="txt-color-orange" i18n:translate="">Waiting...</span>
 					</tal:if>
--- a/src/pyams_media/zmi/templates/video-thumbnail.pt	Fri Dec 04 16:33:41 2015 +0100
+++ b/src/pyams_media/zmi/templates/video-thumbnail.pt	Fri Dec 04 16:34:30 2015 +0100
@@ -19,7 +19,7 @@
 					tal:condition="video_type"
 					tal:attributes="type video_type;
 									src extension:absolute_url(conversion);
-									media 'all and (max-width: {0[0]}px)'.format(media_width) if media_width else None;" />
+									media 'all and (max-width: {0}px)'.format(media_width) if media_width else None;" />
 		</tal:loop>
 	</video>
 </div>