Added schema fields for medias and videos with thumbnails
authorThierry Florac <thierry.florac@onf.fr>
Mon, 05 Feb 2018 16:28:59 +0100
changeset 81 ba60c42b58ee
parent 80 59a808015208
child 82 a4450d2886bf
Added schema fields for medias and videos with thumbnails
src/pyams_file/interfaces/__init__.py
src/pyams_file/schema.py
--- a/src/pyams_file/interfaces/__init__.py	Fri Jan 26 17:15:51 2018 +0100
+++ b/src/pyams_file/interfaces/__init__.py	Mon Feb 05 16:28:59 2018 +0100
@@ -123,9 +123,15 @@
 class DELETED_FILE(object):
     def __repr__(self):
         return '<DELETED_FILE>'
+
+
 DELETED_FILE = DELETED_FILE()
 
 
+class IThumbnailField(Interface):
+    """Generic field interface with thumbnail"""
+
+
 class IFileField(IBytes):
     """File object field interface"""
 
@@ -136,18 +142,26 @@
     """Media file object field interface"""
 
 
+class IThumbnailMediaField(IMediaField, IThumbnailField):
+    """Media object field with thumbnail interface"""
+
+
 class IImageField(IMediaField):
     """Image file object field interface"""
 
 
-class IThumbnailImageField(IImageField):
-    """Image object field with cthumb interface"""
+class IThumbnailImageField(IImageField, IThumbnailField):
+    """Image object field with thumbnail interface"""
 
 
 class IVideoField(IMediaField):
     """Video file field interface"""
 
 
+class IThumbnailVideoField(IVideoField, IThumbnailField):
+    """Video object field with thumbnail interface"""
+
+
 class IAudioField(IMediaField):
     """Audio file field interface"""
 
--- a/src/pyams_file/schema.py	Fri Jan 26 17:15:51 2018 +0100
+++ b/src/pyams_file/schema.py	Mon Feb 05 16:28:59 2018 +0100
@@ -15,8 +15,8 @@
 # import standard library
 
 # import interfaces
-from pyams_file.interfaces import IFile, IFileField, IMediaFile, IMediaField, IImage, IImageField, \
-    IThumbnailImageField, IVideo, IVideoField, IAudio, IAudioField, DELETED_FILE
+from pyams_file.interfaces import IFile, IFileField, IMediaFile, IMediaField, IImage, IImageField, IVideo, IVideoField, \
+    IAudio, IAudioField, IThumbnailMediaField, IThumbnailImageField, IThumbnailVideoField, DELETED_FILE
 from z3c.form.interfaces import NOT_CHANGED
 from zope.schema.interfaces import WrongType, RequiredMissing
 
@@ -57,6 +57,11 @@
     schema = IMediaFile
 
 
+@implementer(IThumbnailMediaField)
+class ThumbnailMediaField(MediaField):
+    """Custom field used to store media properties with thumbnail selection"""
+
+
 @implementer(IImageField)
 class ImageField(MediaField):
     """Custom field used to handle image properties"""
@@ -76,6 +81,11 @@
     schema = IVideo
 
 
+@implementer(IThumbnailVideoField)
+class ThumbnailVideoField(VideoField):
+    """Custom field used to store video properties with thumbnail selection"""
+
+
 @implementer(IAudioField)
 class AudioField(MediaField):
     """Custom field used to store audio file"""