Пример #1
0
def fix_resources_references(setup_tool):
    """Fix resource references after static files reorganization."""
    css_tool = api.portal.get_tool('portal_css')
    if OLD in css_tool.getResourceIds():
        css_tool.getResource(OLD).setCompression('none')
        css_tool.renameResource(OLD, NEW)
    logger.info('Updated CSS references.')
Пример #2
0
def install_new_dependencies(setup_tool):
    dependencies = ('collective.js.cycle2',)
    qi = api.portal.get_tool('portal_quickinstaller')
    for p in dependencies:
        if not qi.isProductInstalled(p):
            qi.installProducts([p])
            logger.info('{0} installed'.format(p))
Пример #3
0
def install_new_dependencies(context, logger=None):
    logger = logging.getLogger(PROJECTNAME)
    dependencies = ('collective.js.cycle2',)
    qi = api.portal.get_tool('portal_quickinstaller')
    for p in dependencies:
        if not qi.isProductInstalled(p):
            qi.installProducts([p])
            logger.info(u'{0} installed'.format(p))
Пример #4
0
def apply_profile(context, logger=None):
    """Apply upgrade profile; this includes:

    - remove character counter resources from CSS and JS registries
    - remove character counter control panel records from registry
    - rename galleria view in News Article content type
    - cook CSS and JS resources
    """
    if logger is None:
        # Called as upgrade step: define our own logger
        logger = logging.getLogger(PROJECTNAME)

    profile = 'profile-collective.nitf.upgrades.v2000:default'
    setup = api.portal.get_tool('portal_setup')
    setup.runAllImportStepsFromProfile(profile)

    portal_css = api.portal.get_tool('portal_css')
    portal_css.cookResources()
    logger.info(u'CSS resources cooked')
    portal_js = api.portal.get_tool('portal_javascripts')
    portal_js.cookResources()
    logger.info(u'JS resources cooked')
Пример #5
0
def reindex_searchable_text(setup_tool):
    """Reindex news articles to fix SearchableText."""
    test = 'test' in setup_tool.REQUEST  # used to ignore transactions on tests
    logger.info('Reindexing the catalog')
    catalog = api.portal.get_tool('portal_catalog')
    results = catalog(portal_type='collective.nitf.content')
    logger.info('Found {0} news articles'.format(len(results)))
    for n, obj in enumerate(get_valid_objects(results), start=1):
        catalog.catalog_object(obj, idxs=['SearchableText'])
        if n % 1000 == 0 and not test:
            transaction.commit()
            logger.info('{0} items processed.'.format(n))

    if not test:
        transaction.commit()
    logger.info('Done.')
Пример #6
0
def update_layouts(setup_tool):
    # update existing objects
    logger.info('Updating layout of news articles')
    results = api.content.find(portal_type='collective.nitf.content')
    logger.info('Found {0} news articles'.format(len(results)))
    i = 0
    for obj in get_valid_objects(results):
        if obj.getLayout() == 'nitf_galleria':
            obj.setLayout('slideshow_view')
            i += 1
        logger.info('{0} news articles updated'.format(i))
Пример #7
0
def reindex_news_articles(setup_tool):
    """Reindex news articles to fix interfaces."""
    test = 'test' in setup_tool.REQUEST  # used to ignore transactions on tests
    logger.info(
        'Reindexing the catalog. '
        'This process could take a long time on large sites. Be patient.')
    catalog = api.portal.get_tool('portal_catalog')
    results = api.content.find(portal_type='collective.nitf.content')
    logger.info('Found {0} news articles'.format(len(results)))
    n = 0
    for obj in get_valid_objects(results):
        catalog.catalog_object(obj, idxs=['object_provides'], update_metadata=False)
        n += 1
        if n % 1000 == 0 and not test:
            transaction.commit()
            logger.info('{0} items processed.'.format(n))

    if not test:
        transaction.commit()
    logger.info('Done.')
Пример #8
0
def update_layouts(context, logger=None):
    if logger is None:
        # Called as upgrade step: define our own logger
        logger = logging.getLogger(PROJECTNAME)

    # update existing objects
    logger.info(u'Updating layout of News Articles')
    catalog = api.portal.get_tool('portal_catalog')
    results = catalog(portal_type='collective.nitf.content')
    logger.info(u'{0} News Articles found'.format(len(results)))
    i = 0
    for item in results:
        obj = item.getObject()
        if obj.getLayout() == 'nitf_galleria':
            obj.setLayout('slideshow_view')
            i += 1
        logger.info(u'{0} News Articles updated'.format(i))
Пример #9
0
def update_configlet(setup_tool):
    """Update control panel configlet."""
    profile = 'profile-{0}:default'.format(PROJECTNAME)
    setup_tool.runImportStepFromProfile(profile, 'controlpanel')
    logger.info('Control panel configlet updated.')
Пример #10
0
def cook_css_resources(context):  # pragma: no cover
    """Cook CSS resources."""
    css_tool = api.portal.get_tool('portal_css')
    css_tool.cookResources()
    logger.info('CSS resources were cooked')
Пример #11
0
def cook_javascript_resources(context):  # pragma: no cover
    """Cook JavaScript resources."""
    js_tool = api.portal.get_tool('portal_javascripts')
    js_tool.cookResources()
    logger.info('JavaScript resources were cooked')
Пример #12
0
def update_behaviors(setup_tool):
    """Update News Article behaviors."""
    fti = getUtility(IDexterityFTI, name='collective.nitf.content')
    fti.behaviors = tuple(set(fti.behaviors) | BEHAVIORS_TO_ADD)
    logger.info('News Article behaviors updated.')