Ejemplo n.º 1
0
def generate_attachment_preview_images(obj):
    if not IAttachmentStoragable.providedBy(obj):
        return
    attachment_storage = IAttachmentStorage(obj)
    for att_id in attachment_storage.keys():
        attachment = attachment_storage.get(att_id)
        if not pi_api.previews.has_previews(attachment):
            pi_api.previews.generate_previews(attachment)
Ejemplo n.º 2
0
def generate_attachment_preview_images(obj):
    if (IAttachmentStoragable is not None and
            IAttachmentStoragable.providedBy(obj)):
        attachment_storage = IAttachmentStorage(obj)
        for att_id in attachment_storage.keys():
            docconv = IDocconv(attachment_storage.get(att_id))
            if not docconv.has_thumbs():
                docconv.generate_all()
Ejemplo n.º 3
0
def generate_attachment_preview_images(obj):
    if not IAttachmentStoragable.providedBy(obj):
        return
    attachment_storage = IAttachmentStorage(obj)
    for att_id in attachment_storage.keys():
        attachment = attachment_storage.get(att_id)
        if not pi_api.previews.has_previews(attachment):
            pi_api.previews.generate_previews(attachment)
Ejemplo n.º 4
0
def generate_attachment_preview_images(obj):
    if not IAttachmentStoragable.providedBy(obj):
        return
    attachment_storage = IAttachmentStorage(obj)
    for att_id in attachment_storage.keys():
        attachment = attachment_storage.get(att_id)
        if not pi_api.previews.has_previews(attachment):
            log.debug('generate_attachment_preview_images'
                      ' - generating attachment preview')
            generate_previews_async(attachment)
 def attachments(self):
     """ Get preview images for status update attachments """
     if all([
             self.is_attachment_supported(),
             self.is_preview_supported(),
             IAttachmentStoragable.providedBy(self.status),
     ]):
         storage = IAttachmentStorage(self.status)
         attachments = storage.values()
         for attachment in attachments:
             docconv = IDocconv(attachment)
             if docconv.has_thumbs():
                 url = api.portal.get().absolute_url()
                 yield ('{portal_url}/@@status-attachments/{status_id}/'
                        '{attachment_id}/thumb').format(
                            portal_url=url,
                            status_id=self.status.getId(),
                            attachment_id=attachment.getId())
 def attachments(self):
     """ Get preview images for status update attachments """
     if all([
         self.is_attachment_supported(),
         self.is_preview_supported(),
             IAttachmentStoragable.providedBy(self.status),
     ]):
         storage = IAttachmentStorage(self.status)
         attachments = storage.values()
         for attachment in attachments:
             docconv = IDocconv(attachment)
             if docconv.has_thumbs():
                 url = api.portal.get().absolute_url()
                 yield ('{portal_url}/@@status-attachments/{status_id}/'
                        '{attachment_id}/thumb').format(
                            portal_url=url,
                            status_id=self.status.getId(),
                            attachment_id=attachment.getId())
    def attachments(self):
        """ Get preview images for status update attachments """
        if not self.is_attachment_supported():
            return []
        if not self.is_preview_supported():
            return []
        if not IAttachmentStoragable.providedBy(self.status):
            return []

        storage = IAttachmentStorage(self.status)
        items = storage.values()
        if not items:
            return []

        attachments = []
        portal_url = api.portal.get().absolute_url()
        base_url = '{portal_url}/@@status-attachments/{status_id}'.format(
            portal_url=portal_url,
            status_id=self.status.getId(),
        )
        for item in items:
            item_url = '/'.join((base_url, item.getId()))
            docconv = IDocconv(item)
            if docconv.has_thumbs():
                url = '/'.join((item_url, 'thumb'))
            elif isinstance(item, Image):
                images = api.content.get_view(
                    'images',
                    item.aq_base,
                    self.request,
                )
                url = '/'.join((
                    item_url,
                    images.scale(scale='preview').url.lstrip('/')
                ))
            else:
                # We need a better fallback image. See #See #122
                url = '/'.join((
                    api.portal.get().absolute_url(),
                    '++theme++ploneintranet.theme/generated/media/logo.svg'))
            if url:
                attachments.append(dict(img_src=url, link=item_url))
        return attachments
Ejemplo n.º 8
0
 def attachments(self):
     """ Get preview images for status update attachments
     """
     storage = IAttachmentStorage(self.context, {})
     items = storage.values()
     return map(self.item2attachments, items)
Ejemplo n.º 9
0
 def attachments(self):
     """ Get preview images for status update attachments
     """
     storage = IAttachmentStorage(self.context, {})
     items = storage.values()
     return map(self.item2attachments, items)