class IAudioTile(IPersistentCoverTile): """ """ title = schema.TextLine( title=_(u'Title'), required=False, ) description = schema.TextLine( title=_(u'Description'), required=False, readonly=False, ) credit = schema.TextLine( title=_(u'Credit'), required=False, readonly=False, ) uuids = schema.List( title=_(u'Audio'), value_type=schema.TextLine(), required=False, readonly=True, )
class IAudioTile(IPersistentCoverTile): """A droppable tile that shows an audio player with description, link and credits. """ title = schema.TextLine( title=_(u'Title'), required=False, ) description = schema.TextLine( title=_(u'Description'), required=False, readonly=False, ) credit = schema.TextLine( title=_(u'Credit'), required=False, readonly=False, ) uuids = schema.List( title=_(u'Audio'), value_type=schema.TextLine(), required=False, readonly=True, )
class IHeaderTile(IPersistentCoverTile): title = schema.TextLine( title=_(u'Title'), required=False, ) link_text = schema.TextLine( title=_(u'Link text'), required=False, ) link_url = schema.TextLine( title=_(u'Link url'), required=False, ) link_boolean = schema.Bool( title=_(u'Title as link?'), required=False, ) uuid = schema.TextLine( title=_(u'UUID'), required=False, readonly=True, )
class IPOTDTile(IPersistentCoverTile): """This tile displays an outstanding photo selected daily.""" title = schema.TextLine( title=_(u'Title'), required=False, default=u'', ) description = schema.Text( title=_(u'Description'), required=False, default=u'', ) photo_credits = schema.TextLine( title=_(u'Credits'), required=False, default=u'', ) image = field.NamedBlobImage( title=_(u'Photo'), required=False, ) uuid = schema.TextLine( title=u'UUID', required=False, readonly=True, )
class IHeaderTile(IPersistentCoverTile): """Header tile, the element dropped populate the data.""" title = schema.TextLine( title=_(u'Title'), required=False, ) link_text = schema.TextLine( title=_(u'Link text'), required=False, ) link_url = schema.TextLine( title=_(u'Link url'), required=False, ) link_boolean = schema.Bool( title=_(u'Title as link?'), required=False, ) uuid = schema.TextLine( title=_(u'UUID'), required=False, readonly=True, )
class IAudioGalleryTile(IListTile): """A droppable tile that shows a gallery of audios with descriptions and links. """ tile_title = schema.TextLine( title=_(u'Header'), required=False, ) title = schema.TextLine( title=_(u'Title'), required=False, ) footer_text = schema.TextLine( title=_(u'Footer Link'), required=False, readonly=False, ) uuids = schema.List( title=_(u'Audios'), value_type=schema.TextLine(), required=False, readonly=True, )
class ISocialTile(IPersistentCoverTile): wid = schema.TextLine( title=_(u'Twitter widget id'), required=False, ) username = schema.TextLine( title=_(u'Twitter username'), required=False, ) facebook_page = schema.TextLine( title=_(u'Facebook Page URL'), required=False, ) number_of_columns = schema.Choice( title=_(u'Columns'), values=( u'1', u'2', u'3', ), required=True, )
class IQuoteTile(INITFTile): """A tile that shows an article quote.""" form.omitted('quote_color') form.no_omit(ITileEditForm, 'quote_color') quote_color = Choice( title=_(u'Quote color'), vocabulary=SimpleVocabulary([ SimpleTerm(value=u'blue', title=_(u'Blue')), SimpleTerm(value=u'green', title=_(u'Green')), ]), required=True, default=u'blue', ) form.omitted('quote') form.no_omit(ITileEditForm, 'quote') quote = schema.Text( title=_(u'Quote'), required=False, ) form.omitted('quote_rights') form.no_omit(ITileEditForm, 'quote_rights') quote_rights = schema.TextLine( title=_(u'Quote Rights'), required=False, )
class IDestaqueTile(IListTile): uuids = schema.List( title=_(u'Elements'), value_type=schema.TextLine(), required=False, ) title = schema.List( title=_(u'Title'), required=False, readonly=True, ) description = schema.Text( title=_(u'Description'), required=False, readonly=True, ) image = NamedImage( title=_(u'Image'), required=False, readonly=True, )
class IVideoTile(IPersistentCoverTile): """ """ title = schema.TextLine( title=_(u'Title'), required=False, ) embed_code = schema.TextLine( title=_(u'Videos'), required=False, readonly=True, ) url = schema.TextLine( title=_(u'Videos'), required=False, readonly=True, ) uuids = schema.List( title=_(u'Videos'), value_type=schema.TextLine(), required=False, readonly=True, )
class IAudioGalleryTile(IListTile): """ """ header = schema.TextLine( title=_(u'Header'), required=False, ) title = schema.TextLine( title=_(u'Title'), required=False, ) footer_text = schema.TextLine( title=_(u'Footer Link'), required=False, readonly=False, ) uuids = schema.List( title=_(u'Audios'), value_type=schema.TextLine(), required=False, readonly=True, )
class IGroupCarouselTile(ICarouselTile): """Display a carousel of items.""" tile_description = schema.Text(title=_(u'Tile Description'), required=False) form.omitted('tile_description') form.no_omit(ITileEditForm, 'tile_description') switch_text = schema.TextLine(title=_(u'Switch Text'), required=False) form.omitted('switch_text') form.no_omit(ITileEditForm, 'switch_text') form.omitted('autoplay')
class IEmDestaqueTile(IPersistentCoverTile): uuids = schema.List( title=_(u'Elements'), value_type=schema.TextLine(), required=False, ) title = schema.TextLine( title=_(u'Title'), required=False, readonly=True, )
class IEmbedTile(IPersistentCoverTile): embed = schema.Text( title=_(u'Embedding code'), required=False, ) title = schema.TextLine( title=_(u'Title'), required=False, ) description = schema.Text( title=_(u'Description'), required=False, )
class ICarouselTile(IListTile): """ """ autoplay = schema.Bool( title=_(u'Auto play'), required=False, default=True, ) form.widget(uuids=TextLinesSortableFieldWidget) uuids = schema.List( title=_(u'Elements'), value_type=schema.TextLine(), required=False, readonly=False, )
class IHighlightsCarousel(ICarouselTile): """Display a carousel of items.""" tile_description = schema.Text(title=_(u'Tile Description'), required=False) form.omitted('tile_description') form.no_omit(ITileEditForm, 'tile_description') form.omitted('autoplay')
class ICollectionTile(IPersistentCoverTile, form.Schema): header = schema.TextLine( title=_(u'Header'), required=False, ) form.omitted('title') form.no_omit(IDefaultConfigureForm, 'title') title = schema.TextLine( title=_(u'Title'), required=False, ) form.omitted('description') form.no_omit(IDefaultConfigureForm, 'description') description = schema.Text( title=_(u'Description'), required=False, ) form.omitted('date') form.no_omit(IDefaultConfigureForm, 'date') date = schema.Datetime( title=_(u'Date'), required=False, ) form.omitted('image') form.no_omit(IDefaultConfigureForm, 'image') image = NamedImage( title=_(u'Image'), required=False, ) # FIXME: this field should be named 'count' form.omitted('number_to_show') form.no_omit(IDefaultConfigureForm, 'number_to_show') number_to_show = schema.List( title=_(u'Number of items to display'), value_type=schema.TextLine(), required=False, ) footer = schema.TextLine( title=_(u'Footer'), required=False, ) uuid = schema.TextLine( title=_(u'UUID'), readonly=True, )
def populate_with_object(self, obj): super(AlbunsTile, self).populate_with_object(obj) # check permissions if ((obj.portal_type in self.accepted_ct()) and (obj.getLayout() == 'galeria_de_albuns')): title = _(u'Gallery albums') link_url = obj.absolute_url() link_text = _(u'Access all Albums') uuid = IUUID(obj, None) data_mgr = ITileDataManager(self) data_mgr.set({ 'title': title, 'link_url': link_url, 'link_text': link_text, 'player': True, 'carrossel': True, 'footer': True, 'uuid': uuid })
class IPhotoGalleryTile(IListTile): """A tile that shows an photo gallery.""" tile_description = schema.Text(title=_(u'Tile Description'), required=False) form.omitted('tile_description') form.no_omit(ITileEditForm, 'tile_description') form.no_omit(ITileEditForm, 'uuids') form.widget(uuids=TextLinesSortableFieldWidget)
def populate_with_object(self, obj): super(AlbunsTile, self).populate_with_object(obj) # check permissions if (obj.portal_type in self.accepted_ct()) and (obj.getLayout() == "galeria_de_albuns"): title = _(u"Gallery albums") link_url = obj.absolute_url() link_text = _(u"Access all Albums") uuid = api.content.get_uuid(obj) data_mgr = ITileDataManager(self) data_mgr.set( { "title": title, "link_url": link_url, "link_text": link_text, "player": True, "carrossel": True, "footer": True, "uuid": uuid, } )
class IBannerRotativoTile(IListTile): """ """ form.omitted('header') form.no_omit(IDefaultConfigureForm, 'header') header = schema.TextLine( title=_(u'Header'), required=False, readonly=True, ) form.omitted('title') form.no_omit(IDefaultConfigureForm, 'title') title = schema.TextLine( title=_(u'Title'), required=False, readonly=True, ) form.omitted('description') form.no_omit(IDefaultConfigureForm, 'description') description = schema.Text( title=_(u'Description'), required=False, readonly=True, ) form.omitted('date') form.no_omit(IDefaultConfigureForm, 'date') date = schema.Datetime( title=_(u'Date'), required=False, readonly=True, ) form.omitted('image') form.no_omit(IDefaultConfigureForm, 'image') image = NamedImage( title=_(u'Image'), required=False, readonly=True, ) layout = schema.Choice( title=u'Layout', values=(u'Banner', u'Chamada de foto', u'Texto sobreposto'), default=u'Banner', required=True, ) form.omitted('uuids') form.no_omit(IDefaultConfigureForm, 'uuids') uuids = schema.List( title=_(u'Elements'), value_type=schema.TextLine(), required=False, readonly=True, )
class IBannerTile(IPersistentCoverTile): title = schema.TextLine( title=_(u'Title'), required=False, ) image = field.NamedBlobImage( title=_(u'Image'), required=False, ) form.no_omit('image_description') form.omitted(IDefaultConfigureForm, 'image_description') image_description = schema.TextLine( title=_(u'ALT'), required=False, ) remote_url = schema.TextLine( title=_(u'URL'), required=False, )
def populate_with_object(self, obj): super(CollectionTile, self).populate_with_object(obj) # check permission if obj.portal_type in self.accepted_ct(): header = obj.Title() # use collection's title as header footer = _(u'More…') # XXX: can we use field's default? uuid = api.content.get_uuid(obj) data_mgr = ITileDataManager(self) data_mgr.set({ 'header': header, 'footer': footer, 'uuid': uuid, })
class IVideoGalleryTile(IListTile): """A droppable tile that shows a gallery of videos with descriptions and links. """ tile_title = schema.TextLine( title=_(u'Header'), required=False, ) form.omitted('title') form.no_omit(IDefaultConfigureForm, 'title') title = schema.TextLine( title=_(u'Title'), required=False, readonly=True, ) subtitle = schema.TextLine( title=_(u'Subtitle'), required=False, readonly=False, ) footer_text = schema.TextLine( title=_(u'Footer Link'), required=False, readonly=False, ) form.omitted('image') form.no_omit(IDefaultConfigureForm, 'image') image = NamedImage( title=_(u'Image'), required=False, readonly=True, )
class IMediaCarouselTile(IListTile): """ """ header = schema.TextLine( title=_(u'Header'), required=False, ) form.omitted('title') form.no_omit(IDefaultConfigureForm, 'title') title = schema.TextLine( title=_(u'Title'), required=False, ) form.omitted('image') form.no_omit(IDefaultConfigureForm, 'image') image = NamedImage( title=_(u'Image'), required=False, readonly=True, ) form.omitted('uuids') form.no_omit(IDefaultConfigureForm, 'uuids') uuids = schema.List( title=_(u'Elements'), value_type=schema.TextLine(), required=False, ) footer_text = schema.TextLine( title=_(u'Footer Link'), required=False, readonly=False, )
class INITFBasicTile(IBasicTile): """A tile that shows general information about news articles. """ subtitle = schema.Text( title=_(u'Subtitle'), required=False, ) form.omitted('section') form.no_omit(IDefaultConfigureForm, 'section') section = schema.Text( title=_(u'Section'), required=False, ) form.no_omit('variacao_titulo') form.omitted(IDefaultConfigureForm, 'variacao_titulo') variacao_titulo = schema.Choice( title=_(u'Change in Title'), values=(u'Normal', u'Grande', u'Gigante'), default=u'Normal', required=True, )
def populate_with_object(self, obj): super(CollectionTile, self).populate_with_object(obj) # check permission if obj.portal_type in self.accepted_ct(): header = obj.Title() # use collection's title as header footer = _(u'More…') # XXX: can we use field's default? uuid = IUUID(obj) data_mgr = ITileDataManager(self) data_mgr.set({ 'header': header, 'footer': footer, 'uuid': uuid, })
class HighlightsCarousel(CarouselTile): """Display a carousel of items.""" index = ViewPageTemplateFile('templates/highlightscarousel.pt') short_name = _(u'msg_short_name_highlightscarousel', default=u'Highlights Carousel') is_configurable = False is_droppable = True is_editable = True limit = 5 * 3 @property def tile_description(self): return self.data['tile_description']
def populate_with_uuids(self, uuids): self.set_limit() data_mgr = ITileDataManager(self) old_data = data_mgr.get() old_data['header'] = _(u'tile List Title') for uuid in uuids: if old_data['uuids']: if type(old_data['uuids']) != list: old_data['uuids'] = [uuid] elif uuid not in old_data['uuids']: old_data['uuids'].append(uuid) else: old_data['uuids'] = [uuid] data_mgr.set(old_data)
def populate_with_uids(self, uuids): self.set_limit() data_mgr = ITileDataManager(self) old_data = data_mgr.get() old_data['header'] = _(u'tile List Title') for uuid in uuids: if old_data['uuids']: if type(old_data['uuids']) != list: old_data['uuids'] = [uuid] elif uuid not in old_data['uuids']: old_data['uuids'].append(uuid) else: old_data['uuids'] = [uuid] data_mgr.set(old_data)
class POTDTile(PersistentCoverTile): """This tile displays an outstanding photo selected daily.""" index = ViewPageTemplateFile('templates/potd.pt') short_name = _(u'msg_short_name_potd', default=u'Photo of the Day') is_configurable = True is_editable = True is_droppable = True @staticmethod def accepted_ct(): return ['Image'] def populate_with_object(self, obj): super(POTDTile, self).populate_with_object(obj) title = safe_unicode(obj.Title()) description = safe_unicode(obj.Description()) rights = safe_unicode(obj.Rights()) image = self.get_image_data(obj) if image: # clear scales if new image is getting saved self.clear_scales() data = { 'title': title, 'description': description, 'uuid': api.content.get_uuid(obj=obj), 'image': image, 'photo_credits': rights, # FIXME: https://github.com/collective/collective.cover/issues/778 'alt_text': description or title, } data_mgr = ITileDataManager(self) data_mgr.set(data) @property def is_empty(self): return not self.has_image def getAlt(self): return self.data.get('description', None) or self.data.get( 'title', None)
class GroupCarouselTile(CarouselTile): """Display a carousel of items.""" index = ViewPageTemplateFile('templates/groupcarousel.pt') short_name = _(u'msg_short_name_groupcarousel', default=u'Group Carousel') is_configurable = False is_droppable = True is_editable = True limit = 4 * 3 @property def description(self): return self.data['tile_description'] @property def switch_text(self): return self.data['switch_text'] def populate_with_object(self, obj): """Add an object to the list of items :param obj: [required] The object to be added :type obj: Content object """ self.populate_with_uuids([self.get_uuid(obj)]) def results(self): """Return the list of objects stored in the tile.""" page = [] for i, item in enumerate(super(GroupCarouselTile, self).results(), start=1): page.append(item) if i % 4 == 0: yield page page = [] if page: yield page def is_empty(self): """Check if the tile is empty.""" return super(GroupCarouselTile, self).results() == []
class PhotoGalleryTile(ListTile): """A tile that shows an photo gallery.""" index = ViewPageTemplateFile('templates/photogallery.pt') short_name = _(u'msg_short_photo_gallery', default=u'Photo Gallery') is_configurable = True is_droppable = True is_editable = True limit = 5 * 3 @staticmethod def accepted_ct(): return ['Image'] def get_description(self, item): """Get the description of the item, or the custom description if set. :param item: [required] The item for which we want the description :type item: Content object :returns: the item description :rtype: unicode """ # First we get the url for the item itself description = item.Description() uuid = self.get_uuid(item) data_mgr = ITileDataManager(self) data = data_mgr.get() uuids = data['uuids'] if uuid in uuids: if uuids[uuid].get('custom_description', u''): # If we had a custom description set, then get that description = uuids[uuid].get('custom_description') return description @staticmethod def get_credits(item): return item.Rights()