src/pyams_content/component/gallery/interfaces/__init__.py
changeset 1059 34e6d07ea2e9
parent 1058 1fe028e17f70
child 1060 29b1aaf9e080
equal deleted inserted replaced
1058:1fe028e17f70 1059:34e6d07ea2e9
     1 #
       
     2 # Copyright (c) 2008-2015 Thierry Florac <tflorac AT ulthar.net>
       
     3 # All Rights Reserved.
       
     4 #
       
     5 # This software is subject to the provisions of the Zope Public License,
       
     6 # Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
       
     7 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
       
     8 # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
       
     9 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
       
    10 # FOR A PARTICULAR PURPOSE.
       
    11 #
       
    12 
       
    13 __docformat__ = 'restructuredtext'
       
    14 
       
    15 from zope.annotation.interfaces import IAttributeAnnotatable
       
    16 from zope.container.constraints import containers, contains
       
    17 from zope.container.interfaces import IOrderedContainer
       
    18 from zope.interface import Interface
       
    19 from zope.schema import Bool, Choice, TextLine
       
    20 
       
    21 from pyams_content.component.paragraph.interfaces import IBaseParagraph
       
    22 from pyams_content.features.renderer.interfaces import IRenderedContent
       
    23 from pyams_file.schema import AudioField, MediaField
       
    24 from pyams_i18n.schema import I18nTextField, I18nTextLineField
       
    25 
       
    26 from pyams_content import _
       
    27 
       
    28 
       
    29 GALLERY_CONTAINER_KEY = 'pyams_content.gallery'
       
    30 GALLERY_RENDERERS = 'PyAMS.gallery.renderers'
       
    31 
       
    32 
       
    33 class IGalleryItem(Interface):
       
    34     """Gallery item base interface"""
       
    35 
       
    36     containers('.IGallery')
       
    37 
       
    38 
       
    39 class IGalleryFile(IGalleryItem):
       
    40     """Gallery file marker interface"""
       
    41 
       
    42     data = MediaField(title=_("Image or video data"),
       
    43                       description=_("Image or video content"),
       
    44                       required=True)
       
    45 
       
    46     title = I18nTextLineField(title=_("Legend"),
       
    47                               required=False)
       
    48 
       
    49     alt_title = I18nTextLineField(title=_("Accessibility title"),
       
    50                                   description=_("Alternate title used to describe media content"),
       
    51                                   required=False)
       
    52 
       
    53     description = I18nTextField(title=_("Description"),
       
    54                                 required=False)
       
    55 
       
    56     author = TextLine(title=_("Author"),
       
    57                       description=_("Name of document's author"),
       
    58                       required=True)
       
    59 
       
    60     sound = AudioField(title=_("Audio data"),
       
    61                        description=_("Sound file associated with the current media"),
       
    62                        required=False)
       
    63 
       
    64     sound_title = I18nTextLineField(title=_("Sound title"),
       
    65                                     description=_("Title of associated sound file"),
       
    66                                     required=False)
       
    67 
       
    68     sound_description = I18nTextField(title=_("Sound description"),
       
    69                                       description=_("Short description of associated sound file"),
       
    70                                       required=False)
       
    71 
       
    72     visible = Bool(title=_("Visible media?"),
       
    73                    description=_("If 'no', this media won't be displayed in front office"),
       
    74                    required=True,
       
    75                    default=True)
       
    76 
       
    77 
       
    78 GALLERY_FILE_HIDDEN_FIELDS = ('__parent__', '__name__', 'visible')
       
    79 
       
    80 
       
    81 class IBaseGallery(IOrderedContainer, IAttributeAnnotatable, IRenderedContent):
       
    82     """Base gallery interface"""
       
    83 
       
    84     renderer = Choice(title=_("Gallery template"),
       
    85                       description=_("Presentation template used for this gallery"),
       
    86                       vocabulary=GALLERY_RENDERERS,
       
    87                       default='default')
       
    88 
       
    89     def append(self, value, notify=True):
       
    90         """Append new file to gallery
       
    91 
       
    92         @param value: the media object to append
       
    93         @param boolean notify: if 'False', the given value object is pre-located so that
       
    94             adding events are not notified
       
    95         """
       
    96 
       
    97     def get_visible_medias(self):
       
    98         """Get iterator over visible medias"""
       
    99 
       
   100 
       
   101 class IGallery(IBaseGallery):
       
   102     """Gallery interface"""
       
   103 
       
   104     contains(IGalleryItem)
       
   105 
       
   106     title = I18nTextLineField(title=_("Title"),
       
   107                               description=_("Gallery title, as shown in front-office"),
       
   108                               required=False)
       
   109 
       
   110     description = I18nTextField(title=_("Description"),
       
   111                                 description=_("Gallery description displayed by front-office template"),
       
   112                                 required=False)
       
   113 
       
   114 
       
   115 class IGalleryTarget(IAttributeAnnotatable):
       
   116     """Gallery container target marker interface"""
       
   117 
       
   118 
       
   119 GALLERY_PARAGRAPH_TYPE = 'Gallery'
       
   120 GALLERY_PARAGRAPH_NAME = _("Medias gallery")
       
   121 
       
   122 
       
   123 class IGalleryParagraph(IBaseGallery, IBaseParagraph):
       
   124     """Gallery paragraph"""