src/pyams_content/component/gallery/interfaces/__init__.py
changeset 0 7c0001cacf8e
child 140 67bad9f880ee
equal deleted inserted replaced
-1:000000000000 0:7c0001cacf8e
       
     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 
       
    16 # import standard library
       
    17 
       
    18 # import interfaces
       
    19 from pyams_file.interfaces import IMediaFile
       
    20 from zope.container.interfaces import IContainer, IOrderedContainer
       
    21 
       
    22 # import packages
       
    23 from pyams_file.schema import FileField
       
    24 from pyams_i18n.schema import I18nTextLineField, I18nTextField
       
    25 from pyams_utils.schema import PersistentList
       
    26 from zope.annotation.interfaces import IAttributeAnnotatable
       
    27 from zope.container.constraints import containers, contains
       
    28 from zope.interface import Interface
       
    29 from zope.schema import Choice, Bool, TextLine
       
    30 
       
    31 from pyams_content import _
       
    32 
       
    33 
       
    34 GALLERY_CONTAINER_KEY = 'pyams_content.gallery'
       
    35 GALLERY_FILE_INFO_KEY = 'pyams_content.gallery.info'
       
    36 GALLERY_LINKS_CONTAINER_KEY = 'pyams_content.gallery.links'
       
    37 
       
    38 
       
    39 class IGalleryFile(Interface):
       
    40     """Gallery file marker interface"""
       
    41 
       
    42 
       
    43 class IGalleryFileInfo(Interface):
       
    44     """Gallery file info"""
       
    45 
       
    46     title = I18nTextLineField(title=_("Title"),
       
    47                               required=False)
       
    48 
       
    49     description = I18nTextField(title=_("Description"),
       
    50                                 required=False)
       
    51 
       
    52     author = TextLine(title=_("Author"),
       
    53                       required=False)
       
    54 
       
    55     author_comments = I18nTextField(title=_("Author's comments"),
       
    56                                     description=_("Comments relatives to author's rights management"),
       
    57                                     required=False)
       
    58 
       
    59     sound = FileField(title=_("Audio data"),
       
    60                       description=_("Sound file associated with the current media"),
       
    61                       required=False)
       
    62 
       
    63     sound_title = I18nTextLineField(title=_("Sound title"),
       
    64                                     description=_("Title of associated sound file"),
       
    65                                     required=False)
       
    66 
       
    67     sound_description = I18nTextField(title=_("Sound description"),
       
    68                                       description=_("Short description of associated sound file"),
       
    69                                       required=False)
       
    70 
       
    71     pif_number = TextLine(title=_("PIF number"),
       
    72                           description=_("Number used to identify media into national library database"),
       
    73                           required=False)
       
    74 
       
    75     visible = Bool(title=_("Visible image?"),
       
    76                    description=_("If 'no', this image won't be displayed in front office"),
       
    77                    required=True,
       
    78                    default=True)
       
    79 
       
    80 
       
    81 class IBaseGallery(IOrderedContainer, IAttributeAnnotatable):
       
    82     """Base gallery interface"""
       
    83 
       
    84     containers('.IGalleryContainer')
       
    85 
       
    86     title = I18nTextLineField(title=_("Title"),
       
    87                               description=_("Gallery title, as shown in front-office"),
       
    88                               required=True)
       
    89 
       
    90     description = I18nTextField(title=_("Description"),
       
    91                                 description=_("Gallery description displayed by front-office template"),
       
    92                                 required=False)
       
    93 
       
    94     visible = Bool(title=_("Visible gallery?"),
       
    95                    description=_("If 'no', this gallery won't be displayed in front office"),
       
    96                    required=True,
       
    97                    default=True)
       
    98 
       
    99     def get_visible_images(self):
       
   100         """Get iterator over visible images"""
       
   101 
       
   102 
       
   103 class IGallery(IBaseGallery):
       
   104     """Gallery interface"""
       
   105 
       
   106     contains(IMediaFile)
       
   107 
       
   108 
       
   109 class IGalleryContainer(IContainer):
       
   110     """Galleries container"""
       
   111 
       
   112     contains(IBaseGallery)
       
   113 
       
   114 
       
   115 class IGalleryContainerTarget(Interface):
       
   116     """Galleries container marker interface"""
       
   117 
       
   118 
       
   119 class IGalleryLinksContainer(Interface):
       
   120     """Galleries links container interface"""
       
   121 
       
   122     galleries = PersistentList(title=_("Contained galleries"),
       
   123                                description=_("List of images galleries linked to this object"),
       
   124                                value_type=Choice(vocabulary="PyAMS content galleries"),
       
   125                                required=False)
       
   126 
       
   127 
       
   128 class IGalleryLinksContainerTarget(Interface):
       
   129     """Galleries links container marker interface"""