def _facetize(item, xml_filename): """ Make an item as faceted navigation """ notify(FacetedWillBeEnabledEvent(item)) alsoProvides(item, IFacetedNavigable) if not IDisableSmartFacets.providedBy(item): alsoProvides(item, IDisableSmartFacets) if not IHidePloneLeftColumn.providedBy(item): alsoProvides(item, IHidePloneLeftColumn) if not IHidePloneRightColumn.providedBy(item): alsoProvides(item, IHidePloneRightColumn) notify(FacetedEnabledEvent(item)) import os.path fpath = os.path.join(os.path.dirname(__file__), 'faceted', xml_filename) with open(fpath) as f: xml = f.read() if not xml.startswith('<?xml version="1.0"'): raise ValueError('Please provide a valid xml file') environ = SnapshotImportContext(item, 'utf-8') importer = queryMultiAdapter((item, environ), IBody) if not importer: raise ValueError('No adapter found') importer.body = xml
def enable(self): """ See IFacetedSubtyper """ if not self.can_enable: return self._redirect('Faceted search navigation not supported') if not super(FacetedSearchSubtyper, self).is_faceted: super(FacetedSearchSubtyper, self).enable() if not IDisableSmartFacets.providedBy(self.context): alsoProvides(self.context, IDisableSmartFacets) if not IFacetedSearchMode.providedBy(self.context): alsoProvides(self.context, IFacetedSearchMode) self._redirect(_('Faceted search enabled'))
def enable(self): """ See IFacetedSubtyper from eea.facetednavigation.subtypes """ if not self.can_enable: return self._redirect('Faceted navigation not supported') notify(FacetedWillBeEnabledEvent(self.context)) alsoProvides(self.context, ICollectionFacetApplied) if not IDisableSmartFacets.providedBy(self.context): alsoProvides(self.context, IDisableSmartFacets) if not IHidePloneRightColumn.providedBy(self.context): alsoProvides(self.context, IHidePloneRightColumn) notify(FacetedEnabledEvent(self.context)) self._redirect(_('Faceted navigation enabled'))
def enable(self): """ See IFacetedSubtyper """ if not self.can_enable_heritor: return self._redirect('Faceted inheritance not supported') notify(FacetedWillBeEnabledEvent(self.context)) alsoProvides(self.context, IFacetedHeritor) if not IDisableSmartFacets.providedBy(self.context): alsoProvides(self.context, IDisableSmartFacets) if not IHidePloneLeftColumn.providedBy(self.context): alsoProvides(self.context, IHidePloneLeftColumn) if not IHidePloneRightColumn.providedBy(self.context): alsoProvides(self.context, IHidePloneRightColumn) notify(FacetedEnabledEvent(self.context)) self._redirect('Faceted inheritance enabled')
def enable(self): """ See IFacetedSubtyper """ if not self.can_enable: return self._redirect('Faceted navigation not supported') notify(FacetedWillBeEnabledEvent(self.context)) alsoProvides(self.context, IFacetedNavigable) if not IDisableSmartFacets.providedBy(self.context): alsoProvides(self.context, IDisableSmartFacets) if not IHidePloneLeftColumn.providedBy(self.context): alsoProvides(self.context, IHidePloneLeftColumn) if not IHidePloneRightColumn.providedBy(self.context): alsoProvides(self.context, IHidePloneRightColumn) notify(FacetedEnabledEvent(self.context)) self._redirect(_('Faceted navigation enabled'))
def _active_faceted(self): subtyper = getMultiAdapter( (self.portal['relatorios'], self.portal['relatorios'].REQUEST), name=u'faceted_subtyper') subtyper.enable() search = getMultiAdapter( (self.portal['relatorios'], self.portal['relatorios'].REQUEST), name=u'faceted_search_subtyper') search.enable() alsoProvides(self.portal['relatorios'], IFacetedNavigable) if not IDisableSmartFacets.providedBy(self.portal['relatorios']): alsoProvides(self.portal['relatorios'], IDisableSmartFacets) if not IHidePloneLeftColumn.providedBy(self.portal['relatorios']): alsoProvides(self.portal['relatorios'], IHidePloneLeftColumn) if not IHidePloneRightColumn.providedBy(self.portal['relatorios']): alsoProvides(self.portal['relatorios'], IHidePloneRightColumn) self._open_relatorios() self.browser.getLink('Enable faceted navigation').click() self.browser.getControl(name='form.button.confirm').click() transaction.commit()
def disable_smart_facets(self): """ Disable 'smart facets hiding' """ return (IDisableSmartFacets.providedBy(self.canonical) or IDisableSmartFacets.providedBy(self.context))