def remove_bootstrap(setup_tool):
    """Remove Bootstrap references on resource registries."""
    css_tool = api.portal.get_tool('portal_css')
    css_tool.unregisterResource(REMOVE_CSS)
    logger.info('Removed Bootstrap CSS references.')

    js_tool = api.portal.get_tool('portal_javascripts')
    js_tool.unregisterResource(REMOVE_JS)
    logger.info('Updated Bootstrap JS references.')
def fix_extensions_separator(context):
    """Fix controlpanel valid extensions separator."""
    record = dict(interface=IUploadSettings, name='upload_extensions')
    upload_extensions = api.portal.get_registry_record(**record)
    upload_extensions = upload_extensions.replace(u' ', u'')
    upload_extensions = upload_extensions.replace(u',', u'|')
    record['value'] = upload_extensions
    api.portal.set_registry_record(**record)
    logger.info('Control panel valid extensions separator fixed')
def deprecate_resource_registries(setup_tool):
    """Deprecate resource registries."""
    js_tool = api.portal.get_tool('portal_javascripts')
    js_tool.unregisterResource(id=JS)
    assert JS not in js_tool.getResourceIds()  # nosec

    css_tool = api.portal.get_tool('portal_css')
    css_tool.unregisterResource(id=CSS)
    assert CSS not in css_tool.getResourceIds()  # nosec

    logger.info('Static resources were removed from resource registries')
Exemple #4
0
def remove_useless_behavior(setup_tool):
    """Remove IMultipleUpload behavior."""
    portal_types = api.portal.get_tool('portal_types')
    msg = 'IMultipleUpload behavior removed from {0} content type'
    for t in portal_types.listContentTypes():
        try:
            behaviors = list(portal_types[t].behaviors)
            if UPLOAD_BEHAVIOR in behaviors:
                behaviors.remove(UPLOAD_BEHAVIOR)
                portal_types[t].behaviors = tuple(behaviors)
                logger.info(msg.format(t))
        except AttributeError:  # not a Dexterity-based content type
            pass
def unregister_old_resources(context):
    """Unregister old resources."""
    css_tool = api.portal.get_tool('portal_css')
    resource_list = css_tool.getResourceIds()
    for css in CSS_TO_UNREGISTER:
        if css not in resource_list:
            continue
        css_tool.unregisterResource(css)
    js_tool = api.portal.get_tool('portal_javascripts')
    resource_list = js_tool.getResourceIds()
    for js in JS_TO_UNREGISTER:
        if js not in resource_list:
            continue
        js_tool.unregisterResource(js)
    logger.info('Old resources unregistered')
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')
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')
def update_rolemap(setup_tool):
    """Update roles."""
    profile = 'profile-{0}:default'.format(PROJECTNAME)
    setup_tool.runImportStepFromProfile(profile, 'rolemap')
    logger.info('Role map updated.')
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.')
def update_jsregistry(setup_tool):
    """Update jsregistry"""
    profile = 'profile-{0}:default'.format(PROJECTNAME)
    setup_tool.runImportStepFromProfile(profile, 'jsregistry')
    logger.info('JS registry updated.')