コード例 #1
0
def setupTools(context, logger=None):
    if logger is None:
        logger = LOG
    logger.info('BCCVL site tools handler')
    # only run for this product
    if context.readDataFile('org.bccvl.site.marker.txt') is None:
        return
    portal = context.getSite()

    # setup job catalog
    from org.bccvl.site.job.catalog import setup_job_catalog
    setup_job_catalog(portal)

    # setup userannotation storage
    from org.bccvl.site.userannotation.utility import init_user_annotation
    init_user_annotation()
コード例 #2
0
def upgrade_230_240_1(context, logger=None):
    if logger is None:
        logger = LOG
    # Run GS steps
    portal = api.portal.get()
    setup = api.portal.get_tool('portal_setup')
    setup.runImportStepFromProfile(PROFILE_ID, 'rolemap')
    setup.runImportStepFromProfile(PROFILE_ID, 'actions')
    setup.runImportStepFromProfile(PROFILE_ID, 'typeinfo')
    setup.runImportStepFromProfile(PROFILE_ID, 'workflow')
    setup.runImportStepFromProfile(PROFILE_ID, 'viewlets')
    setup.runImportStepFromProfile(PROFILE_ID, 'plone.app.registry')
    setup.runImportStepFromProfile(PROFILE_ID, 'org.bccvl.site.content')
    setup.runImportStepFromProfile(PROFILE_ID, 'org.bccvl.site.facet')

    # install new dependencies
    qi = getToolByName(portal, 'portal_quickinstaller')
    installable = [p['id'] for p in qi.listInstallableProducts()]
    for product in ['collective.emailconfirmationregistration',
                    'plone.formwidget.captcha',
                    'collective.z3cform.norobots']:
        if product in installable:
            qi.installProduct(product)

    # enable self registration
    from plone.app.controlpanel.security import ISecuritySchema
    security = ISecuritySchema(portal)
    security.enable_self_reg = True
    security.enable_user_pwd_choice = True

    # setup userannotation storage
    from org.bccvl.site.userannotation.utility import init_user_annotation
    from org.bccvl.site.userannotation.interfaces import IUserAnnotationsUtility
    init_user_annotation()
    # migrate current properties into userannotations
    pm = api.portal.get_tool('portal_membership')
    pmd = api.portal.get_tool('portal_memberdata')
    custom_props = [p for p in pmd.propertyIds() if '_oauth_' in p]
    ut = getUtility(IUserAnnotationsUtility)
    for member in pm.listMembers():
        member_annots = ut.getAnnotations(member)
        for prop in custom_props:
            if not member.hasProperty(prop):
                continue
            value = member.getProperty(prop)
            if not value:
                continue
            member_annots[prop] = value
            member.setMemberProperties({prop: ''})
    # remove current properties
    pmd.manage_delProperties(custom_props)

    # setup html filtering
    from plone.app.controlpanel.filter import IFilterSchema
    filters = IFilterSchema(portal)
    # remove some nasty tags:
    current_tags = filters.nasty_tags
    for tag in ('embed', 'object'):
        if tag in current_tags:
            current_tags.remove(tag)
    filters.nasty_tags = current_tags
    # remove some stripped tags:
    current_tags = filters.stripped_tags
    for tag in ('button', 'object', 'param'):
        if tag in current_tags:
            current_tags.remove(tag)
    filters.stripped_tags = current_tags
    # add custom allowed tags
    current_tags = filters.custom_tags
    for tag in ('embed', ):
        if tag not in current_tags:
            current_tags.append(tag)
    filters.custom_tags = current_tags
    # add custom allowed styles
    current_styles = filters.style_whitelist
    for style in ('border-radius', 'padding', 'margin-top', 'margin-bottom', 'background', 'color'):
        if style not in current_styles:
            current_styles.append(style)
    filters.style_whitelist = current_styles

    # configure TinyMCE plugins (can't be done zia tinymce.xml
    tinymce = getToolByName(portal, 'portal_tinymce')
    current_plugins = tinymce.plugins
    if 'media' in current_plugins:
        current_plugins.remove('media')
    tinymce.plugins = current_plugins