Removed and reordered illustration properties
authorThierry Florac <thierry.florac@onf.fr>
Wed, 25 Apr 2018 16:20:15 +0200
changeset 536 1e10e634ec13
parent 535 d01efcb4d332
child 537 21152756d312
Removed and reordered illustration properties
src/pyams_content/component/illustration/__init__.py
src/pyams_content/component/illustration/interfaces/__init__.py
src/pyams_content/component/illustration/zmi/paragraph.py
--- a/src/pyams_content/component/illustration/__init__.py	Fri Apr 13 14:33:15 2018 +0200
+++ b/src/pyams_content/component/illustration/__init__.py	Wed Apr 25 16:20:15 2018 +0200
@@ -52,13 +52,11 @@
 class Illustration(Persistent, Contained, RenderedContentMixin):
     """Illustration persistent class"""
 
+    _data = I18nFileProperty(IIllustration['data'])
     title = FieldProperty(IIllustration['title'])
     alt_title = FieldProperty(IIllustration['alt_title'])
     description = FieldProperty(IIllustration['description'])
     author = FieldProperty(IIllustration['author'])
-    _data = I18nFileProperty(IIllustration['data'])
-    filename = FieldProperty(IIllustration['filename'])
-    language = FieldProperty(IIllustration['language'])
     renderer = FieldProperty(IIllustration['renderer'])
 
     @property
@@ -98,11 +96,6 @@
             info = IFileInfo(data)
             info.title = II18n(illustration).get_attribute('title', lang, request)
             info.description = II18n(illustration).get_attribute('alt_title', lang, request)
-            if not illustration.filename:
-                illustration.filename = info.filename
-            else:
-                info.filename = illustration.filename
-            info.language = illustration.language
 
 
 @subscriber(IObjectAddedEvent, context_selector=IIllustration)
@@ -169,7 +162,7 @@
                         output.append(missing_lang_value.format(field=translate(IIllustration[attr].title),
                                                                 lang=lang))
         if has_data:
-            for attr in ('author', 'filename'):
+            for attr in ('author', ):
                 value = getattr(self.context, attr)
                 if not value:
                     output.append(missing_value.format(field=translate(IIllustration[attr].title)))
--- a/src/pyams_content/component/illustration/interfaces/__init__.py	Fri Apr 13 14:33:15 2018 +0200
+++ b/src/pyams_content/component/illustration/interfaces/__init__.py	Wed Apr 25 16:20:15 2018 +0200
@@ -38,6 +38,10 @@
 class IIllustration(IRenderedContent):
     """Illustration paragraph"""
 
+    data = I18nThumbnailMediaField(title=_("Image or video data"),
+                                   description=_("Image or video content"),
+                                   required=False)
+
     title = I18nTextLineField(title=_("Legend"),
                               required=False)
 
@@ -53,19 +57,6 @@
                       description=_("Name of picture's author"),
                       required=False)
 
-    data = I18nThumbnailMediaField(title=_("Image or video data"),
-                                   description=_("Image or video content"),
-                                   required=False)
-
-    filename = TextLine(title=_("Save file as..."),
-                        description=_("Name under which the file will be saved"),
-                        required=False)
-
-    language = Choice(title=_("Language"),
-                      description=_("File's content language"),
-                      vocabulary="PyAMS base languages",
-                      required=False)
-
     renderer = Choice(title=_("Illustration template"),
                       description=_("Presentation template used for illustration"),
                       vocabulary=ILLUSTRATION_RENDERERS,
@@ -85,17 +76,3 @@
     data = I18nThumbnailMediaField(title=_("Image or video data"),
                                    description=_("Image or video content"),
                                    required=True)
-
-    filename = TextLine(title=_("Save file as..."),
-                        description=_("Name under which the file will be saved"),
-                        required=False)
-
-    language = Choice(title=_("Language"),
-                      description=_("File's content language"),
-                      vocabulary="PyAMS base languages",
-                      required=False)
-
-    renderer = Choice(title=_("Illustration template"),
-                      description=_("Presentation template used for illustration"),
-                      vocabulary=ILLUSTRATION_RENDERERS,
-                      default='default')
--- a/src/pyams_content/component/illustration/zmi/paragraph.py	Fri Apr 13 14:33:15 2018 +0200
+++ b/src/pyams_content/component/illustration/zmi/paragraph.py	Wed Apr 25 16:20:15 2018 +0200
@@ -9,6 +9,7 @@
 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
 # FOR A PARTICULAR PURPOSE.
 #
+from zope.schema._schema import getFieldNamesInOrder
 
 __docformat__ = 'restructuredtext'
 
@@ -70,7 +71,8 @@
     dialog_class = 'modal-large'
     icon_css_class = 'fa fa-fw fa-file-image-o'
 
-    fields = field.Fields(IIllustrationParagraph).omit('__parent__', '__name__', 'visible')
+    fields = field.Fields(IIllustrationParagraph).select('data', 'title', 'alt_title', 'description',
+                                                         'author', 'renderer')
     ajax_handler = 'add-illustration.json'
     edit_permission = MANAGE_CONTENT_PERMISSION
 
@@ -103,7 +105,8 @@
     dialog_class = 'modal-large'
     icon_css_class = 'fa fa-fw fa-file-image-o'
 
-    fields = field.Fields(IIllustrationParagraph).omit('__parent__', '__name__', 'visible')
+    fields = field.Fields(IIllustrationParagraph).select('data', 'title', 'alt_title', 'description',
+                                                         'author', 'renderer')
     fields['renderer'].widgetFactory = RendererFieldWidget
 
     ajax_handler = 'properties.json'