Ejemplo n.º 1
0
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
Ejemplo n.º 2
0
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
Ejemplo n.º 3
0
    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'))
Ejemplo n.º 4
0
    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')
Ejemplo n.º 5
0
    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'))
Ejemplo n.º 6
0
def hide_portlets(context):
    """ As eea.design changed, we need to hide left and right plone portlets
    columns. This upgrade step is available only in EEA context
    """
    ctool = getToolByName(context, 'portal_catalog')
    iface = interfaceToName(context, IFacetedNavigable)
    brains = ctool.unrestrictedSearchResults(object_provides=iface)

    logger.info('Hiding plone portlets for %s faceted navigable objects',
                len(brains))

    for brain in brains:
        doc = brain.getObject()
        if not IHidePloneLeftColumn.providedBy(doc):
            logger.info('Hidding left portlet for %s', doc.absolute_url())
            alsoProvides(doc, IHidePloneLeftColumn)
        if not IHidePloneRightColumn.providedBy(doc):
            logger.info('Hidding right portlet for %s', doc.absolute_url())
            alsoProvides(doc, IHidePloneRightColumn)
    logger.info('Hiding plone portlets ... DONE')
 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()
Ejemplo n.º 8
0
def hide_portlets(context):
    """ As eea.design changed, we need to hide left and right plone portlets
    columns. This upgrade step is available only in EEA context
    """
    ctool = getToolByName(context, 'portal_catalog')
    iface = interfaceToName(context, IFacetedNavigable)
    brains = ctool.unrestrictedSearchResults(object_provides=iface)

    logger.info(
        'Hiding plone portlets for %s faceted navigable objects', len(brains))

    for brain in brains:
        doc = brain.getObject()
        if not IHidePloneLeftColumn.providedBy(doc):
            logger.info('Hidding left portlet for %s', doc.absolute_url())
            alsoProvides(doc, IHidePloneLeftColumn)
        if not IHidePloneRightColumn.providedBy(doc):
            logger.info('Hidding right portlet for %s', doc.absolute_url())
            alsoProvides(doc, IHidePloneRightColumn)
    logger.info('Hiding plone portlets ... DONE')
Ejemplo n.º 9
0
 def hide_right_column(self):
     """ Disable plone portlets right column
     """
     return (IHidePloneRightColumn.providedBy(self.canonical) or
             IHidePloneRightColumn.providedBy(self.context))
Ejemplo n.º 10
0
 def hide_right_column(self):
     """ Disable plone portlets right column
     """
     return (IHidePloneRightColumn.providedBy(self.canonical) or
             IHidePloneRightColumn.providedBy(self.context))