diff -r 000000000000 -r 7c0001cacf8e src/pyams_content/component/gallery/interfaces/__init__.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/pyams_content/component/gallery/interfaces/__init__.py Thu Oct 08 13:37:29 2015 +0200 @@ -0,0 +1,129 @@ +# +# Copyright (c) 2008-2015 Thierry Florac +# All Rights Reserved. +# +# This software is subject to the provisions of the Zope Public License, +# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. +# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED +# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS +# FOR A PARTICULAR PURPOSE. +# + +__docformat__ = 'restructuredtext' + + +# import standard library + +# import interfaces +from pyams_file.interfaces import IMediaFile +from zope.container.interfaces import IContainer, IOrderedContainer + +# import packages +from pyams_file.schema import FileField +from pyams_i18n.schema import I18nTextLineField, I18nTextField +from pyams_utils.schema import PersistentList +from zope.annotation.interfaces import IAttributeAnnotatable +from zope.container.constraints import containers, contains +from zope.interface import Interface +from zope.schema import Choice, Bool, TextLine + +from pyams_content import _ + + +GALLERY_CONTAINER_KEY = 'pyams_content.gallery' +GALLERY_FILE_INFO_KEY = 'pyams_content.gallery.info' +GALLERY_LINKS_CONTAINER_KEY = 'pyams_content.gallery.links' + + +class IGalleryFile(Interface): + """Gallery file marker interface""" + + +class IGalleryFileInfo(Interface): + """Gallery file info""" + + title = I18nTextLineField(title=_("Title"), + required=False) + + description = I18nTextField(title=_("Description"), + required=False) + + author = TextLine(title=_("Author"), + required=False) + + author_comments = I18nTextField(title=_("Author's comments"), + description=_("Comments relatives to author's rights management"), + required=False) + + sound = FileField(title=_("Audio data"), + description=_("Sound file associated with the current media"), + required=False) + + sound_title = I18nTextLineField(title=_("Sound title"), + description=_("Title of associated sound file"), + required=False) + + sound_description = I18nTextField(title=_("Sound description"), + description=_("Short description of associated sound file"), + required=False) + + pif_number = TextLine(title=_("PIF number"), + description=_("Number used to identify media into national library database"), + required=False) + + visible = Bool(title=_("Visible image?"), + description=_("If 'no', this image won't be displayed in front office"), + required=True, + default=True) + + +class IBaseGallery(IOrderedContainer, IAttributeAnnotatable): + """Base gallery interface""" + + containers('.IGalleryContainer') + + title = I18nTextLineField(title=_("Title"), + description=_("Gallery title, as shown in front-office"), + required=True) + + description = I18nTextField(title=_("Description"), + description=_("Gallery description displayed by front-office template"), + required=False) + + visible = Bool(title=_("Visible gallery?"), + description=_("If 'no', this gallery won't be displayed in front office"), + required=True, + default=True) + + def get_visible_images(self): + """Get iterator over visible images""" + + +class IGallery(IBaseGallery): + """Gallery interface""" + + contains(IMediaFile) + + +class IGalleryContainer(IContainer): + """Galleries container""" + + contains(IBaseGallery) + + +class IGalleryContainerTarget(Interface): + """Galleries container marker interface""" + + +class IGalleryLinksContainer(Interface): + """Galleries links container interface""" + + galleries = PersistentList(title=_("Contained galleries"), + description=_("List of images galleries linked to this object"), + value_type=Choice(vocabulary="PyAMS content galleries"), + required=False) + + +class IGalleryLinksContainerTarget(Interface): + """Galleries links container marker interface"""