# HG changeset patch # User Thierry Florac # Date 1441790457 -7200 # Node ID 370b8d6fc9e677ac9e192be8998b7cd0c86bcf62 # Parent 240f2efa4a1f9cc4469d96c490d0a45591cea566 Added audio file conversions display form diff -r 240f2efa4a1f -r 370b8d6fc9e6 src/pyams_media/zmi/media.py --- a/src/pyams_media/zmi/media.py Tue Sep 08 17:12:41 2015 +0200 +++ b/src/pyams_media/zmi/media.py Wed Sep 09 11:20:57 2015 +0200 @@ -9,7 +9,7 @@ # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # FOR A PARTICULAR PURPOSE. # -from pyams_file.interfaces import IMediaFile, IVideo, IThumbnail +from pyams_file.interfaces import IMediaFile, IVideo, IThumbnail, IAudio from pyams_form.interfaces.form import IWidgetsPrefixViewletsManager from pyams_media.ffbase import FFmpeg from pyams_media.ffdocument import FFDocument @@ -39,23 +39,27 @@ from pyams_media import _ -@viewlet_config(name='media.conversions.action', context=IVideo, layer=IPyAMSLayer, view=Interface, +# +# Video conversions +# + +@viewlet_config(name='video.conversions.action', context=IVideo, layer=IPyAMSLayer, view=Interface, manager=IContextActions, permission='manage', weight=15) -class MediaConversionsAction(ToolbarMenuItem): - """Media conversions action""" +class VideoConversionsAction(ToolbarMenuItem): + """Video conversions action""" - label = _("Media conversions...") + label = _("Video conversions...") label_css_class = 'fa fa-fw fa-compress' - url = 'media-conversions.html' + url = 'video-conversions.html' modal_target = True -@pagelet_config(name='media-conversions.html', context=IVideo, layer=IPyAMSLayer, permission='manage') -class MediaConversionsDisplayForm(AdminDialogDisplayForm): - """Media conversions display form""" +@pagelet_config(name='video-conversions.html', context=IVideo, layer=IPyAMSLayer, permission='manage') +class VideoConversionsDisplayForm(AdminDialogDisplayForm): + """Video conversions display form""" - legend = _("Selected media conversions") + legend = _("Selected video conversions") icon_css_class = 'fa fa-fw fa-compress' fields = field.Fields(Interface) @@ -65,11 +69,11 @@ return self.context.title or self.context.filename -@viewlet_config(name='media-conversions-prefix', context=IVideo, layer=IAdminLayer, - view=MediaConversionsDisplayForm, manager=IWidgetsPrefixViewletsManager) -@template_config(template='templates/media-conversions.pt') -class MediaConversionsViewletsPrefix(Viewlet): - """Media conversions display form viewlets prefix""" +@viewlet_config(name='video-conversions-prefix', context=IVideo, layer=IAdminLayer, + view=VideoConversionsDisplayForm, manager=IWidgetsPrefixViewletsManager) +@template_config(template='templates/video-conversions.pt') +class VideoConversionsViewletsPrefix(Viewlet): + """Video conversions display form viewlets prefix""" @property def formats(self): @@ -96,3 +100,54 @@ name = 'video{width}.{extension}'.format(width='-{0}'.format(frame_size) if frame_size else '', extension=converter.format) return name in conversions + + +# +# Audio conversions +# + +@viewlet_config(name='audio.conversions.action', context=IAudio, layer=IPyAMSLayer, view=Interface, + manager=IContextActions, permission='manage', weight=15) +class AudioConversionsAction(ToolbarMenuItem): + """Audio conversions action""" + + label = _("Audio conversions...") + label_css_class = 'fa fa-fw fa-compress' + + url = 'audio-conversions.html' + modal_target = True + + +@pagelet_config(name='audio-conversions.html', context=IAudio, layer=IPyAMSLayer, permission='manage') +class AudioConversionsDisplayForm(AdminDialogDisplayForm): + """Audio conversions display form""" + + legend = _("Selected audio conversions") + icon_css_class = 'fa fa-fw fa-compress' + + fields = field.Fields(Interface) + + @property + def title(self): + return self.context.title or self.context.filename + + +@viewlet_config(name='audio-conversions-prefix', context=IAudio, layer=IAdminLayer, + view=AudioConversionsDisplayForm, manager=IWidgetsPrefixViewletsManager) +@template_config(template='templates/audio-conversions.pt') +class AudioConversionsViewletsPrefix(Viewlet): + """Audio conversions display form viewlets prefix""" + + @property + def converters(self): + utility = query_utility(IMediaConversionUtility) + if utility is not None: + for converter_name in utility.audio_formats: + converter = query_utility(IMediaConverter, name=converter_name) + if converter is not None: + yield converter_name, converter + + def has_conversion(self, converter): + conversions = IMediaConversions(self.context) + name = 'audio.{extension}'.format(extension=converter.format) + return name in conversions diff -r 240f2efa4a1f -r 370b8d6fc9e6 src/pyams_media/zmi/templates/audio-conversions.pt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/pyams_media/zmi/templates/audio-conversions.pt Wed Sep 09 11:20:57 2015 +0200 @@ -0,0 +1,21 @@ + + + + + + + + + + + +
  + Status
+
+ OK + Waiting... +
diff -r 240f2efa4a1f -r 370b8d6fc9e6 src/pyams_media/zmi/templates/media-conversions.pt --- a/src/pyams_media/zmi/templates/media-conversions.pt Tue Sep 08 17:12:41 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,43 +0,0 @@ - - - - - - - - - - - - - - - - - -
  - Original size
- () -
-
- () -
- OK - Waiting... - - N/A - - OK - Waiting... - -
diff -r 240f2efa4a1f -r 370b8d6fc9e6 src/pyams_media/zmi/templates/video-conversions.pt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/pyams_media/zmi/templates/video-conversions.pt Wed Sep 09 11:20:57 2015 +0200 @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + +
  + Original size
+ () +
+
+ () +
+ OK + Waiting... + + N/A + + OK + Waiting... + +
diff -r 240f2efa4a1f -r 370b8d6fc9e6 src/pyams_media/zmi/templates/video-thumbnail.pt --- a/src/pyams_media/zmi/templates/video-thumbnail.pt Tue Sep 08 17:12:41 2015 +0200 +++ b/src/pyams_media/zmi/templates/video-thumbnail.pt Wed Sep 09 11:20:57 2015 +0200 @@ -1,11 +1,10 @@