How to use iPreview method in fMBT

Best Python code snippet using fMBT_python

overview.py

Source:overview.py Github

copy

Full Screen

1from AccessControl import getSecurityManager2from five import grok3from opengever.base.browser.helper import get_css_class4from opengever.document.document import IDocumentSchema5from opengever.document.interfaces import ICheckinCheckoutManager6from opengever.ogds.base.interfaces import IContactInformation7from opengever.tabbedview.browser.tabs import OpengeverTab8from plone.directives.dexterity import DisplayForm9from zope.component import getUtility, queryMultiAdapter10try:11 from opengever.pdfconverter.behaviors.preview import IPreviewMarker12 from opengever.pdfconverter.behaviors.preview import IPreview13 from opengever.pdfconverter.behaviors.preview import \14 CONVERSION_STATE_READY15 PDFCONVERTER_AVAILABLE = True16except ImportError:17 PDFCONVERTER_AVAILABLE = False18class Overview(DisplayForm, OpengeverTab):19 grok.context(IDocumentSchema)20 grok.name('tabbedview_view-overview')21 grok.template('overview')22 show_searchform = False23 def creator_link(self):24 info = getUtility(IContactInformation)25 return info.render_link(self.context.Creator())26 def checked_out_link(self):27 manager = queryMultiAdapter(28 (self.context, self.request), ICheckinCheckoutManager)29 if manager.checked_out():30 info = getUtility(IContactInformation)31 return info.render_link(manager.checked_out())32 return None33 def get_css_class(self):34 return get_css_class(self.context)35 def is_preview_supported(self):36 # XXX TODO: should be persistent called two times37 if PDFCONVERTER_AVAILABLE:38 return IPreviewMarker.providedBy(self.context)39 return False40 def is_pdf_download_available(self):41 if self.is_preview_supported():42 if IPreview(43 self.context).conversion_state == CONVERSION_STATE_READY:44 return True45 return False46 def is_checkout_and_edit_available(self):47 manager = queryMultiAdapter(48 (self.context, self.request), ICheckinCheckoutManager)49 if manager.checked_out():50 if manager.checked_out() == \51 getSecurityManager().getUser().getId():52 return True53 else:54 return False55 return manager.is_checkout_allowed()56 def is_download_copy_available(self):57 """Disable copy link when the document is checked58 out by an other user."""59 manager = queryMultiAdapter(60 (self.context, self.request), ICheckinCheckoutManager)61 if manager.checked_out():62 if manager.checked_out() != getSecurityManager().getUser().getId():63 return False...

Full Screen

Full Screen

indexers.py

Source:indexers.py Github

copy

Full Screen

1from Acquisition import aq_base2from plone.dexterity.interfaces import IDexterityContent3from plone.indexer.decorator import indexer4from plone.volto.behaviors.preview import IPreview5@indexer(IPreview)6def hasPreviewImage(obj):7 """8 Indexer for knowing in a catalog search if a content with the IPreview behavior has9 a preview_image10 """11 if obj.aq_base.preview_image:12 return True13 return False14@indexer(IDexterityContent)15def image_field_indexer(obj):16 """Indexer for knowing in a catalog search if a content has any image."""17 base_obj = aq_base(obj)18 image_field = ""19 if getattr(base_obj, "preview_image", False):20 image_field = "preview_image"21 elif getattr(base_obj, "image", False):22 image_field = "image"...

Full Screen

Full Screen

metadata.py

Source:metadata.py Github

copy

Full Screen

1# -*- coding: utf-8 -*-2# Copyright (c) 2013 Infrae. All rights reserved.3# See also LICENSE.txt4from five import grok5from Products.SilvaMetadata.Binding import DefaultMetadataBindingFactory6from silva.core.interfaces import IGhostAware7from silva.core.views.interfaces import IPreviewLayer8class GhostMetadataBindingFactory(DefaultMetadataBindingFactory):9 grok.context(IGhostAware)10 read_only = True11 def get_content(self):12 haunted = self.context.get_haunted()13 if haunted is not None:14 if IPreviewLayer.providedBy(haunted.REQUEST):15 return haunted.get_previewable()16 return haunted.get_viewable()...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run fMBT automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful