def test_fix_interface_for_document(self): self.obj.portal_type = 'Document' self.catalog.reindexObject(self.obj) self.portal.restrictedTraverse('fix_base_classes')() self.assertTrue(IDocument.providedBy(self.obj))
def test_factory(self): fti = queryUtility( IDexterityFTI, name='Document' ) factory = fti.factory new_object = createObject(factory) self.assertTrue(IDocument.providedBy(new_object))
def available(self): if api.user.is_anonymous(): return False if IDocument.providedBy(self.context): return getattr(self.context, 'layout', '') == 'booking-view' else: return self.context.is_rent()
def test_factory(self): fti = queryUtility( IDexterityFTI, name='Document' ) factory = fti.factory new_object = createObject(factory) self.failUnless(IDocument.providedBy(new_object))
def test_document_is_migrated(self): from Products.ATContentTypes.content.document import ATDocument from plone.app.contenttypes.migration.migration import DocumentMigrator from plone.app.contenttypes.interfaces import IDocument at_document = self.createATCTobject(ATDocument, 'document') migrator = self.get_migrator(at_document, DocumentMigrator) migrator.migrate() new_document = self.portal['document'] self.assertTrue(IDocument.providedBy(new_document)) self.assertTrue(at_document is not new_document)
def canLogo(self): if has_dx and (IDocument.providedBy(self.context) or IImage.providedBy(self.context)): return True if hasattr(self.context, 'getText'): return True if hasattr(self.context, 'tag'): return True if self.context.portal_type == 'FlashMovie': return True return False
def test_document_is_migrated(self): from plone.app.contenttypes.migration.migration import DocumentMigrator from plone.app.contenttypes.interfaces import IDocument self.portal.invokeFactory('Document', 'document') at_document = self.portal['document'] applyProfile(self.portal, 'plone.app.contenttypes:default') migrator = self.get_migrator(at_document, DocumentMigrator) migrator.migrate() dx_document = self.portal['document'] self.assertTrue(IDocument.providedBy(dx_document)) self.assertTrue(at_document is not dx_document)
def test_migrate_class_also_updates_provided_interfaces_info(self): if getFSVersionTuple() > (5, ): from plone.app.contenttypes.content import Link from plone.app.contenttypes.interfaces import ILink from plone.app.contenttypes.interfaces import IDocument else: from Products.ATContentTypes.content.link import ATLink as Link from Products.ATContentTypes.interfaces import IATLink as ILink from Products.ATContentTypes.interfaces import IATDocument as IDocument obj = create(Builder('document')) self.assertTrue(IDocument.providedBy(obj)) self.assertFalse(ILink.providedBy(obj)) class Step(UpgradeStep): def __call__(self): self.migrate_class(obj, Link) Step(self.portal_setup) self.assertFalse(IDocument.providedBy(obj), 'Document interface not removed in migration') self.assertTrue(ILink.providedBy(obj), 'Link interface not added in migration')
def test_interfaces(self): self.folder.invokeFactory('Document', 'd1') target = self.folder['d1'] draft = Draft() proxy = DraftProxy(draft, target) self.assertFalse(IDraft.providedBy(proxy)) self.assertTrue(IDraftProxy.providedBy(proxy)) if HAS_PLONE_APP_CONTENTTYPES: from plone.app.contenttypes.interfaces import IDocument self.assertTrue(IDocument.providedBy(proxy)) elif HAS_ATCONTENTTYPES: from Products.ATContentTypes.interfaces import IATDocument self.assertTrue(IATDocument.providedBy(proxy))
def test_interfaces(self): self.folder.invokeFactory('Document', 'd1') target = self.folder['d1'] draft = Draft() proxy = DraftProxy(draft, target) self.failIf(IDraft.providedBy(proxy)) self.failUnless(IDraftProxy.providedBy(proxy)) if HAS_PLONE_APP_CONTENTTYPES: from plone.app.contenttypes.interfaces import IDocument self.failUnless(IDocument.providedBy(proxy)) elif HAS_ATCONTENTTYPES: from Products.ATContentTypes.interfaces import IATDocument self.failUnless(IATDocument.providedBy(proxy))
def logo(self): logo = self.getItems() if not logo: return None if getattr(logo, 'image_sizes', None): sizes = logo.image_sizes['base'] return { 'id': logo.getId, 'content': '<img width="%s" height="%s" title="%s" alt="%s" src="%s"/>' % (str(sizes[0]), str( sizes[1]), logo.Description, logo.Title, logo.getPath()) } else: logo = logo.getObject() if has_dx and IImage.providedBy(logo): return { 'id': logo.id, 'content': ImageScaling(logo, self.request).tag(title=logo.Description()) } elif hasattr(logo, 'tag'): return { 'id': logo.id, 'content': logo.tag(title=logo.Description()) } elif has_dx and IDocument.providedBy(logo): return { 'id': logo.id, 'content': logo.text and logo.text.raw or '' } elif hasattr(logo, 'getText'): return {'id': logo.id, 'content': logo.getText()} elif logo.portal_type == 'FlashMovie': return { 'id': logo.id, 'content': ObjectView(logo, self.request, 'flashmovie_macro_flashobject.pt') } return None
def fetchPreviews(context, virtual_url_parts=[], vr_path=''): """ calls the docconv service and stores pdf and preview images on the object """ fetcher = IPreviewFetcher(context) if IDocument.providedBy(context): if not virtual_url_parts or not vr_path: logger.warn('No virtual hosting info, cannot get local images! ' 'Skipping %s' % '/'.join(context.getPhysicalPath())) return fetcher_args = (virtual_url_parts, vr_path) else: fetcher_args = () try: fetcher(*fetcher_args) except Exception as e: logger.warn('fetchPreviews failed: {0}'.format(e)) return context.reindexObject()
def realestate_obj(self): if IDocument.providedBy(self.context): return get_first_realestate_obj() else: return self.context
def test_assert_at_contenttypes(self): from plone.app.contenttypes.interfaces import IDocument self.portal.invokeFactory('Document', 'document') at_document = self.portal['document'] self.assertEqual('ATDocument', at_document.meta_type) self.assertFalse(IDocument.providedBy(at_document))
def test_adding(self): self.portal.invokeFactory('Document', 'doc1') self.assertTrue(IDocument.providedBy(self.portal['doc1']))
def test_adding(self): self.portal.invokeFactory( 'Document', 'doc1' ) self.assertTrue(IDocument.providedBy(self.portal['doc1']))
def getSolgemaBandeaux(self): bandeaux = self.getItems() bandeauxList = [] base_ajax_content_load = self.request.get('ajax_content_load') base_ajax_load = self.request.get('ajax_load') setattr(self.request, 'ajax_content_load', 1) setattr(self.request, 'ajax_load', 1) for bandeau in bandeaux: bdict = {} if getattr(bandeau, 'image_sizes', None): height = str(bandeau.image_sizes['base'][1]) url = str(bandeau.getPath() + '/image') try: title = str(bandeau.Description) except: try: title = str(bandeau.Description.encode('utf-8')) except: try: title = str(bandeau.Description.decode('utf-8')) except: title = safe_unicode(bandeau.Description) if getattr(bandeau, 'bannerImageLink', ''): link = str(self.context.absolute_url() + '/resolveuid/' + bandeau.bannerImageLink) else: link = None repeat = getattr(bandeau, 'backgroundRepeat', None) if not repeat: repeat = 'no-repeat' repeat = str(repeat) align = getattr(bandeau, 'backgroundAlign', None) if not align: align = 'left' align = str(align) cssClass = 'bandeau_image' cssStyle = 'position:relative;' if getattr(bandeau, 'backgroundExtend', False): cssClass += ' backgroundExtend' if getattr(bandeau, 'backgroundFixed', False): cssClass += ' backgroundFixed' if len(bandeauxList) == 0: cssClass += ' ' + bandeau.id.replace( '.', '_') + ' carousel-banner-content selected' cssStyle += ' display:block;' else: cssClass += ' ' + bandeau.id.replace( '.', '_') + ' carousel-banner-content' cssStyle += ' display:none;' if link: backgrounddiv = '<a style="display:block; height:%spx; width:100%%; background:transparent url(%s) %s %s top;" title="%s" class="%s" href="%s"></a>' % ( height, url, repeat, align, title, cssClass, link) else: backgrounddiv = '<div style="height:%spx; width:100%%; background:transparent url(%s) %s %s top;" title="%s" class="%s"></div>' % ( height, url, repeat, align, title, cssClass) # bandeauxList.append({'id':bandeau.id, 'content':bandeau.tag(title=bandeau.Description())}) bdict = { 'id': bandeau.id, 'content': backgrounddiv, 'cssClass': cssClass, 'cssStyle': cssStyle, 'url': url, 'link': link, 'align': align, 'repeat': repeat } else: bandeau = bandeau.getObject() if (has_dx and IImage.providedBy(bandeau)) or hasattr( bandeau, 'tag'): if hasattr(bandeau, 'getHeight'): height = bandeau.getHeight() else: height = ImageScaling(bandeau, self.request).scale().height if has_dx and IImage.providedBy(bandeau): url = bandeau.absolute_url() else: url = str(bandeau.absolute_url() + '/image') title = bandeau.title bkg = IBackgroundContent(bandeau, None) repeat = getattr(bkg, 'backgroundRepeat', None) if not repeat: repeat = 'no-repeat' align = getattr(bkg, 'backgroundAlign', None) if not align: align = 'left' align = str(align) cssClass = 'bandeau_image' cssStyle = 'position:relative;' if getattr(bkg, 'backgroundExtend', False): cssClass += ' backgroundExtend' if getattr(bkg, 'backgroundFixed', False): cssClass += ' backgroundFixed' if len(bandeauxList) == 0: cssClass += ' ' + bandeau.id.replace( '.', '_') + ' carousel-banner-content selected' cssStyle += ' display:block;' else: cssClass += ' ' + bandeau.id.replace( '.', '_') + ' carousel-banner-content' cssStyle += ' display:none;' if getattr(bkg, 'bannerImageLink', ''): link = str(self.context.absolute_url() + '/resolveuid/' + bkg.bannerImageLink) else: link = None if link: backgrounddiv = '<a style="display:block; height:%spx; width:100%%; background:transparent url(%s) %s %s top;" title="%s" class="%s" href="%s"></a>' % ( height, url, repeat, align, title, cssClass, link) else: backgrounddiv = '<div style="height:%spx; width:100%%; background:transparent url(%s) %s %s top;" title="%s" class="%s"></div>' % ( height, url, repeat, align, title, cssClass) bdict = { 'id': bandeau.id, 'content': backgrounddiv, 'cssClass': cssClass, 'cssStyle': cssStyle, 'url': url, 'link': link, 'align': align, 'repeat': repeat } elif has_dx and IDocument.providedBy(bandeau): bdict['id'] = bandeau.id bdict['content'] = bandeau.text and bandeau.text.raw or '' elif hasattr(bandeau, 'getText') and not bandeau.portal_type in [ 'Topic', 'Collection' ]: try: bdict['id'] = bandeau.id bdict['content'] = bandeau.getText() except: raise ValueError('error with: ' + str(bandeau)) elif bandeau.portal_type == 'Collage': bdict['id'] = bandeau.id bdict['content'] = ObjectView(bandeau, self.request, 'collage_renderer.pt') elif bandeau.portal_type == 'FlashMovie': bdict['id'] = bandeau.id bdict['content'] = ObjectView( bandeau, self.request, 'flashmovie_macro_flashobject.pt') elif bandeau.portal_type == 'Folder': bdict['id'] = bandeau.id bdict['content'] = ObjectView(bandeau, self.request, 'folder_renderer.pt') else: bdict['id'] = bandeau.id bdict['content'] = bandeau() bandeauxList.append(bdict) if not base_ajax_content_load: delattr(self.request, 'ajax_content_load') if not base_ajax_load: delattr(self.request, 'ajax_load') return bandeauxList