Added schema fields for I18n medias and videos with thumbnails
authorThierry Florac <thierry.florac@onf.fr>
Mon, 05 Feb 2018 16:30:25 +0100
changeset 51 2be95c766ed0
parent 50 a736ced99604
child 52 568ef229cc20
Added schema fields for I18n medias and videos with thumbnails
src/pyams_i18n/interfaces/schema.py
src/pyams_i18n/schema.py
--- a/src/pyams_i18n/interfaces/schema.py	Sat Jan 27 00:40:57 2018 +0100
+++ b/src/pyams_i18n/interfaces/schema.py	Mon Feb 05 16:30:25 2018 +0100
@@ -45,6 +45,10 @@
     """I18n media field marker interface"""
 
 
+class II18nThumbnailMediaField(II18nMediaField):
+    """I18n media field with thumbnail marker interface"""
+
+
 class II18nImageField(II18nFileField):
     """I18n image field marker interface"""
 
@@ -57,5 +61,9 @@
     """I18n video field marker interface"""
 
 
+class II18nThumbnailVideoField(II18nVideoField):
+    """I18n video field with thumbnail marker interface"""
+
+
 class II18nAudioField(II18nMediaField):
     """I18n audio field marker interface"""
--- a/src/pyams_i18n/schema.py	Sat Jan 27 00:40:57 2018 +0100
+++ b/src/pyams_i18n/schema.py	Mon Feb 05 16:30:25 2018 +0100
@@ -18,13 +18,15 @@
 # import interfaces
 from pyams_file.interfaces import DELETED_FILE
 from pyams_i18n.interfaces.schema import II18nField, II18nTextLineField, II18nTextField, II18nHTMLField, \
-    II18nFileField, II18nMediaField, II18nImageField, II18nThumbnailImageField, II18nVideoField, II18nAudioField
+    II18nFileField, II18nMediaField, II18nThumbnailMediaField, II18nImageField, II18nThumbnailImageField, \
+    II18nVideoField, II18nThumbnailVideoField, II18nAudioField
 from z3c.form.interfaces import NOT_CHANGED, IDataManager
 from zope.schema.interfaces import RequiredMissing, WrongType
 
 # import packages
 from persistent.mapping import PersistentMapping
-from pyams_file.schema import FileField, MediaField, ImageField, ThumbnailImageField, VideoField, AudioField
+from pyams_file.schema import FileField, MediaField, ThumbnailMediaField, ImageField, ThumbnailImageField, \
+    VideoField, ThumbnailVideoField, AudioField
 from pyams_utils.schema import HTMLField
 from zope.component import getMultiAdapter
 from zope.interface import implementer
@@ -183,6 +185,17 @@
                                             **kwargs)
 
 
+@implementer(II18nThumbnailMediaField)
+class I18nThumbnailMediaField(I18nMediaField):
+    """I18n media field"""
+
+    def __init__(self, key_type=None, value_type=None, value_min_length=None, value_max_length=None, **kwargs):
+        super(I18nFileField, self).__init__(value_type=ThumbnailMediaField(min_length=value_min_length,
+                                                                           max_length=value_max_length,
+                                                                           required=False),
+                                            **kwargs)
+
+
 @implementer(II18nImageField)
 class I18nImageField(I18nMediaField):
     """I18n image field"""
@@ -216,6 +229,17 @@
                                             **kwargs)
 
 
+@implementer(II18nThumbnailVideoField)
+class I18nThumbnailVideoField(I18nFileField):
+    """I18n thumbnail video field"""
+
+    def __init__(self, key_type=None, value_type=None, value_min_length=None, value_max_length=None, **kwargs):
+        super(I18nFileField, self).__init__(value_type=ThumbnailVideoField(min_length=value_min_length,
+                                                                           max_length=value_max_length,
+                                                                           required=False),
+                                            **kwargs)
+
+
 @implementer(II18nAudioField)
 class I18nAudioField(I18nMediaField):
     """I18n audio field"""