示例#1
0
    def setUpPloneSite(self, portal):
        # Workaround for the importVocabularies setuphandler calls
        # createSimpleVocabs which throws:
        # KeyError: 'ACTUAL_URL'
        portal.REQUEST["ACTUAL_URL"] = portal.REQUEST["SERVER_URL"]

        # Install all the Plone stuff + content (including the
        # Members folder)
        applyProfile(portal, 'Products.CMFPlone:plone')
        applyProfile(portal, 'Products.CMFPlone:plone-content')

        # quick install ATVocabularyManager or else we don't have
        # portal.portal_vocabularies
        quickInstallProduct(portal, "Products.ATVocabularyManager")
        quickInstallProduct(portal, "Products.PloneHelpCenter")
        quickInstallProduct(portal, "Products.ATCountryWidget")
        quickInstallProduct(portal, "Products.Collage")
        quickInstallProduct(portal, "plonetheme.classic")
        quickInstallProduct(portal, "Products.LinguaPlone")
        quickInstallProduct(portal, 'osha.adaptation')
        quickInstallProduct(portal, 'slc.googlesearch')

        applyProfile(portal, 'osha.policy:default')
        applyProfile(portal, 'osha.theme:default')
        applyProfile(portal, 'slc.linkcollection:default')

        # Needed to properly install content types
        applyProfile(portal, 'Products.RichDocument:default')
        applyProfile(portal, 'Products.RemoteProvider:default')
        applyProfile(portal, 'Products.CaseStudy:default')
        applyProfile(portal, 'Products.OSHContentLink:default')
        applyProfile(portal, 'slc.seminarportal:default')
        applyProfile(portal, 'slc.outdated:default')
        applyProfile(portal, 'Products.PloneHelpCenter:default')
        applyProfile(portal, 'osha.whoswho:default')

        # We need this imports here, otherwise we get an error
        from Products.CMFPlone.tests.utils import MockMailHost
        from Products.MailHost.interfaces import IMailHost

        # Mock MailHost
        mockmailhost = MockMailHost('MailHost')
        portal.MailHost = mockmailhost
        sm = portal.getSiteManager()
        sm.registerUtility(component=mockmailhost, provided=IMailHost)

        # Login as manager and create a test folder
        setRoles(portal, TEST_USER_ID, ['Manager'])
        login(portal, TEST_USER_NAME)
        portal.invokeFactory('Folder', 'folder')

        # Enable Members folder
        from plone.app.controlpanel.security import ISecuritySchema
        security_adapter = ISecuritySchema(portal)
        security_adapter.set_enable_user_folders(True)

        # Commit so that the test browser sees these objects
        portal.portal_catalog.clearFindAndRebuild()
        import transaction
        transaction.commit()
示例#2
0
    def setUpPloneSite(self, portal):
        # Workaround for the importVocabularies setuphandler calls
        # createSimpleVocabs which throws:
        # KeyError: 'ACTUAL_URL'
        portal.REQUEST["ACTUAL_URL"] = portal.REQUEST["SERVER_URL"]

        # Install all the Plone stuff + content (including the
        # Members folder)
        applyProfile(portal, 'Products.CMFPlone:plone')
        applyProfile(portal, 'Products.CMFPlone:plone-content')

        # quick install ATVocabularyManager or else we don't have
        # portal.portal_vocabularies
        quickInstallProduct(portal, "Products.ATVocabularyManager")
        quickInstallProduct(portal, "Products.PloneHelpCenter")
        quickInstallProduct(portal, "Products.ATCountryWidget")
        quickInstallProduct(portal, "Products.Collage")
        quickInstallProduct(portal, "plonetheme.classic")
        quickInstallProduct(portal, "Products.LinguaPlone")
        quickInstallProduct(portal, 'osha.adaptation')
        quickInstallProduct(portal, 'slc.googlesearch')

        applyProfile(portal, 'osha.policy:default')
        applyProfile(portal, 'osha.theme:default')
        applyProfile(portal, 'slc.linkcollection:default')

        # Needed to properly install content types
        applyProfile(portal, 'Products.RichDocument:default')
        applyProfile(portal, 'Products.RemoteProvider:default')
        applyProfile(portal, 'Products.CaseStudy:default')
        applyProfile(portal, 'Products.OSHContentLink:default')
        applyProfile(portal, 'slc.seminarportal:default')
        applyProfile(portal, 'slc.outdated:default')
        applyProfile(portal, 'Products.PloneHelpCenter:default')
        applyProfile(portal, 'osha.whoswho:default')

        # We need this imports here, otherwise we get an error
        from Products.CMFPlone.tests.utils import MockMailHost
        from Products.MailHost.interfaces import IMailHost

        # Mock MailHost
        mockmailhost = MockMailHost('MailHost')
        portal.MailHost = mockmailhost
        sm = portal.getSiteManager()
        sm.registerUtility(component=mockmailhost, provided=IMailHost)

        # Login as manager and create a test folder
        setRoles(portal, TEST_USER_ID, ['Manager'])
        login(portal, TEST_USER_NAME)
        portal.invokeFactory('Folder', 'folder')

        # Enable Members folder
        from plone.app.controlpanel.security import ISecuritySchema
        security_adapter = ISecuritySchema(portal)
        security_adapter.set_enable_user_folders(True)

        # Commit so that the test browser sees these objects
        portal.portal_catalog.clearFindAndRebuild()
        import transaction
        transaction.commit()
def set_up_security(context):
    """ Enable/disable security controlpanel (a.k.a. @@security-controlpanel)
        settings.
    """

    site = context.getSite()
    
    #site security setup!
    security = ISecuritySchema(site)
    security.enable_user_folders = True
示例#4
0
def importVarious(context):
    """Miscellanous steps import handle
    """
    # We check from our GenericSetup context whether we are running
    if context.readDataFile('pysv.policy_various.txt') is None:
        return  # Not this add-on

    portal = context.getSite()

    # Fetch the adapter
    security_adapter = ISecuritySchema(portal)
    security_adapter.set_enable_user_folders(True)
    def test_home_folder_contents_are_listed_in_portlet_if_enabled(self):
        portal = self.layer['portal']

        registry = getUtility(IRegistry)
        registry['ftw.dashboard.portlets.recentlymodified.'
                 'exclude_members_folder'] = False

        # Enable user folders.
        security_adapter = ISecuritySchema(portal)
        security_adapter.set_enable_user_folders(True)

        # Create a members folder.
        create(Builder('folder').with_id('Members'))

        login(portal, TEST_USER_NAME)
        transaction.commit()

        # Login in the browser for the home folder to be created.
        browser = Browser(portal)
        browser.open(portal.absolute_url() + '/login_form')
        browser.getControl(name='__ac_name').value = TEST_USER_NAME
        browser.getControl(name='__ac_password').value = TEST_USER_PASSWORD
        browser.getControl(name='submit').click()

        # There must be a home folder inside the members folder now.
        membership_tool = getToolByName(portal, 'portal_membership')
        members_folder = membership_tool.getMembersFolder()
        self.assertTrue(members_folder.hasObject('test_user_1_'))

        # Create content in the user's home folder. This content must be
        # present in the portlet.
        home_folder = membership_tool.getHomeFolder()
        create(Builder('document').within(home_folder))

        # Create more content which must be present in the portlet.
        folder = create(Builder('folder'))
        create(Builder('document').within(folder))

        # Get the portlet's content.
        portlet_renderer = self.renderer()
        portlet_content = [brain.getPath() for brain
                           in portlet_renderer._data()]

        self.assertEqual(
            sorted(portlet_content),
            sorted([
                '/plone/folder',
                '/plone/folder/document',
                '/plone/Members',
                '/plone/Members/test_user_1_',
                '/plone/Members/test_user_1_/document',
            ]))
def setupSiteSecurity(portal, logger):
    """
        site security setup!
    """
    secSchema = ISecuritySchema(portal)
    secSchema.set_enable_self_reg(True)
    secSchema.set_enable_user_pwd_choice(False)
    secSchema.set_enable_user_folders(True)
    secSchema.set_use_email_as_login(True)
示例#7
0
    def setUp(self):
        self.portal = self.layer['portal']
        self.catalog = getToolByName(self.portal, 'portal_catalog')
        security_adapter =  ISecuritySchema(self.portal)
        security_adapter.set_enable_user_folders(True)
        self.app = self.layer['app']
        self.portal_url = self.portal.absolute_url()
        self.membership = getToolByName(self.portal, 'portal_membership') 
        setRoles(self.portal, TEST_USER_ID, ['Manager'])
        self.request = self.app.REQUEST

        # create members if needed
        if hasattr(self, 'members') and self.members:
            for member in self.members:
                self.addMember(*member)
示例#8
0
def setupSiteSecurity(portal, out):
    """
        site security setup!
    """
    secSchema = ISecuritySchema(portal)
    secSchema.set_enable_self_reg(True)
    secSchema.set_enable_user_pwd_choice(True)
    secSchema.set_enable_user_folders(True)
示例#9
0
    def setUp(self):
        self.portal = self.layer['portal']
        self.catalog = getToolByName(self.portal, 'portal_catalog')
        security_adapter = ISecuritySchema(self.portal)
        security_adapter.set_enable_user_folders(True)
        self.app = self.layer['app']
        self.portal_url = self.portal.absolute_url()
        self.membership = getToolByName(self.portal, 'portal_membership')
        setRoles(self.portal, TEST_USER_ID, ['Manager'])
        self.request = self.app.REQUEST

        # create members if needed
        if hasattr(self, 'members') and self.members:
            for member in self.members:
                self.addMember(*member)
def configure_extra(context):
    """To configure extra features not already managed by genericsetup"""
    portal_url = getToolByName(context, 'portal_url')
    pm = getToolByName(context, 'portal_membership')
    portal = portal_url.getPortalObject()
    security = ISecuritySchema(portal)

    if not security.enable_self_reg:
        security.enable_self_reg = True

    if not security.enable_user_pwd_choice:
         security.enable_user_pwd_choice = True

    if not security.enable_user_folders:
        security.enable_user_folders = True
    pm.memberarea_type = 'MemberFolder'
示例#11
0
def setupVarious(context):

    if context.readDataFile('trust.template_various.txt') is None:
        return

    remove_front_page(context)
    ISecuritySchema(context.getSite()).set_enable_user_folders(True)
示例#12
0
 def setUpPloneSite(self, portal):
     # super(CPSkinMinisiteLayer).setUpPloneSite(portal)
     portal.portal_workflow.setDefaultChain('simple_publication_workflow')
     # applyProfile(portal, 'plone.app.contenttypes:plone-content')
     applyProfile(portal, 'cpskin.minisite:testing')
     add_behavior('Document', IHiddenTags.__identifier__)
     ISecuritySchema(portal).set_enable_self_reg(True)
示例#13
0
 def setUp(self):
     # turn on self registration
     from plone.app.controlpanel.security import ISecuritySchema
     ISecuritySchema(self.layer['portal']).enable_self_reg = True
     # turn off email validation so we can more easily register users
     self.layer['portal'].validate_email = False
     transaction.commit()
     self.ids_to_remove = []
def configure_extra(context):
    """To configure extra features not already managed by genericsetup"""

    portal_url = getToolByName(context, 'portal_url')
    portal = portal_url.getPortalObject()
    security = ISecuritySchema(portal)

    if not security.enable_self_reg:
        security.enable_self_reg = True

#    if not security.enable_user_pwd_choice:
#        security.enable_user_pwd_choice = True

    if not security.enable_user_folders:
        security.enable_user_folders = True

    if not security.use_email_as_login:
        security.use_email_as_login = True
示例#15
0
def configure_extra(context):
    """To configure extra features not already managed by genericsetup"""

    portal_url = getToolByName(context, 'portal_url')
    portal = portal_url.getPortalObject()
    security = ISecuritySchema(portal)

    if not security.enable_self_reg:
        security.enable_self_reg = True


#    if not security.enable_user_pwd_choice:
#        security.enable_user_pwd_choice = True

    if not security.enable_user_folders:
        security.enable_user_folders = True

    if not security.use_email_as_login:
        security.use_email_as_login = True
    def test__call__(self):

        #create user
        username = '******'
        passwd = username
        title = 'Test User2'
        properties = {'username' : username,
                      'fullname' : title.encode("utf-8"),
                      'email' : '*****@*****.**',   
                      'teacher_mobile_number': '0821111222',
                      'school': 'CoolSchool',
                      'province': 'WC',
                      'EMIS': '12345',
                      'school_contact_number': '1111',
                      'school_email': '*****@*****.**',
                      'qualification': 'Teacher',
                      'years_teaching': '2',
                      'uuid' : 'qwerty-001',
                     }                       

        security_adapter =  ISecuritySchema(self.portal)
        # enable self-registration of users
        security_adapter.set_enable_self_reg(True)

        regtool = getToolByName(self.portal, 'portal_registration')
        member = regtool.addMember(username, passwd, properties=properties)

        pm = self.portal.portal_membership
        acl = self.portal.acl_users
        acl.session._setupSession(username,self.request.RESPONSE)

        view = self.portal.restrictedTraverse('@@export-user-profiles')
        test_out = view()

        csv_ref = 'test_user_1_,,,,,,,,,,,01/01/2000 00:00:00,\r\n' +\
                  'testuser2,Test User2,[email protected],0821111222,' +\
                  'CoolSchool,WC,12345,1111,[email protected],Teacher,' +\
                  '2,01/01/2000 00:00:00,qwerty-001\r\n'

        self.assertEqual(test_out,csv_ref)
        ct = self.request.response.getHeader("Content-Type")
        self.assertEqual(ct,"text/csv")
    def test_home_folder_contents_are_not_listed_in_portlet(self):
        portal = self.layer['portal']

        # Enable user folders.
        security_adapter = ISecuritySchema(portal)
        security_adapter.set_enable_user_folders(True)

        # Create a members folder.
        create(Builder('folder').with_id('Members'))

        login(portal, TEST_USER_NAME)
        transaction.commit()

        # Login in the browser for the home folder to be created.
        browser = Browser(portal)
        browser.open(portal.absolute_url() + '/login_form')
        browser.getControl(name='__ac_name').value = TEST_USER_NAME
        browser.getControl(name='__ac_password').value = TEST_USER_PASSWORD
        browser.getControl(name='submit').click()

        # There must be a home folder inside the members folder now.
        membership_tool = getToolByName(portal, 'portal_membership')
        members_folder = membership_tool.getMembersFolder()
        self.assertTrue(members_folder.hasObject('test_user_1_'))

        # Create content in the user's home folder. This content must not be
        # present in the portlet.
        home_folder = membership_tool.getHomeFolder()
        create(Builder('document').within(home_folder))

        # Create more content which must be present in the portlet.
        folder = create(Builder('folder'))
        create(Builder('document').within(folder))

        # Render the portlet.
        portlet_renderer = self.renderer()
        portlet_content = [brain.portal_type for brain
                           in portlet_renderer._data()]

        self.assertEqual(
            sorted(portlet_content),
            sorted([u'Document', u'Folder']))
    def test_home_folder_contents_are_displayed(self, browser):
        portal = self.layer['portal']

        registry = getUtility(IRegistry)
        registry['ftw.dashboard.portlets.recentlymodified.'
                 'exclude_members_folder'] = False

        # Enable user folders.
        security_adapter = ISecuritySchema(portal)
        security_adapter.set_enable_user_folders(True)

        # Create a members folder.
        create(Builder('folder').with_id('Members'))

        # Login in the browser for the home folder to be created.
        browser.visit(view='login_form')
        browser.fill({'Login Name': TEST_USER_NAME,
                      'Password': TEST_USER_PASSWORD}).submit()
        transaction.commit()

        # There must be a home folder inside the members folder now.
        membership_tool = getToolByName(portal, 'portal_membership')
        members_folder = membership_tool.getMembersFolder()
        self.assertTrue(members_folder.hasObject('test_user_1_'),
                        msg='There is no members folder.')

        # Create content in the user's home folder. This content must be
        # present in the results.
        home_folder = membership_tool.getHomeFolder()
        create(Builder('document').titled('My Document').within(home_folder))

        # Create more content which must be present in the portlet.
        folder = create(Builder('folder').titled('My Folder'))
        create(Builder('document').titled('Another Document').within(folder))

        browser.visit(portal, view='recently_modified_view')
        browser.css('form[name="searchresults"]')
        content = ', '.join(
            browser.css('form[name="searchresults"] dl dt').text
        )
        self.assertIn('Members', content)
        self.assertIn('My Document', content)
示例#19
0
def setup_security(portal):
    """ Add security controlpanel settings.
    """
    site = api.portal.get()
    #site security setup!
    security = ISecuritySchema(site)
    security.set_enable_user_folders(True)
    security.use_uuid_as_userid(True)
    def test_on_user_initial_login(self):

        # create user
        username = '******'
        passwd = username
        email = '*****@*****.**'
        title = 'Test User1'
        properties = {'username' : username,
                      'fullname' : title.encode("utf-8"),
                      'email' : email,   
                     }

        portal = getSite()
        # allow member folders to be created
        security_adapter =  ISecuritySchema(portal)
        security_adapter.set_enable_user_folders(True)
        # enable self-registration of users
        security_adapter.set_enable_self_reg(True)

        regtool = getToolByName(portal, 'portal_registration')
        member = regtool.addMember(username, passwd, properties=properties)

        pm = portal.portal_membership
        acl = getSite().acl_users
        acl.session._setupSession(username,self.request.RESPONSE)

        # call event
        on_user_initial_login(member,None)

        brains = pm.getHomeFolder().getFolderContents()
        # first 3 folder objects are the ones created in base.py
        # the ones created by on_user_initial_login are effectively objects 4-6
        self.assertEquals(brains[3].getObject().id,'classlists')
        self.assertEquals(brains[3].getObject().getLayout(),'@@classlists')
        self.assertEquals(brains[4].getObject().id,'assessments')
        self.assertEquals(brains[4].getObject().getLayout(),'@@assessments')
        self.assertEquals(brains[5].getObject().id,'evaluations')
        self.assertEquals(brains[5].getObject().getLayout(),'@@evaluationsheets')
示例#21
0
def setupSiteSecurity(portal):
    """
        site security setup!
    """
    logger = logging.getLogger("fatac.content")
    secSchema = ISecuritySchema(portal)

    # Activa el poder crear carpetes d'usuari al fer login un usuari
    if secSchema.get_enable_user_folders() == False:
        secSchema.set_enable_user_folders(True)
        logger.info("fatac.content >> enabled user folder creation")

    # Activa el registre automatic d'usuaris al site
    if secSchema.get_enable_self_reg() == False:
        secSchema.set_enable_self_reg(True)
        logger.info("fatac.content >> enabled user registration")

    # Set the username to email login
    if secSchema.get_use_email_as_login() == False:
        secSchema.set_use_email_as_login(True)
        logger.info("fatac.content >> enabled username as email login")

    # Afegim propietat en els grups per controlar qui es el creador / Administradors
    gd_tool = getToolByName(portal, 'portal_groupdata')
    if not hasattr(gd_tool, 'delegated_group_member_managers'):
        gd_tool._setProperty('delegated_group_member_managers', (), 'lines')
        logger.info("fatac.content >> add group member managers property to portal_groupdata")

    # Si no esta creada la carpeta de grups la creem
    if "Groups" not in portal.objectIds():
        crearObjecte(portal, "Groups", "Folder", 'Groups', 'Carpeta contenidora de les carpetes de grup')
        logger.info("fatac.content >> Groups folder added")

    gtool = getToolByName(portal, 'portal_groups')
    if 'Reviewers' in gtool.listGroupNames():
        gtool.removeGroup("Reviewers")
        logger.info("fatac.content >> Removed 'Reviewers' group")
示例#22
0
    def setUpPloneSite(self, portal):
        # Install all the Plone stuff + content (including the
        # Members folder)
        applyProfile(portal, 'Products.CMFPlone:plone')
        applyProfile(portal, 'Products.CMFPlone:plone-content')

        quickInstallProduct(portal, "Products.LinguaPlone")

        applyProfile(portal, 'slc.publications:default')

        # Login as manager and create a test folder
        setRoles(portal, TEST_USER_ID, ['Manager'])
        login(portal, TEST_USER_NAME)
        portal.invokeFactory('Folder', 'folder')

        # Enable Members folder
        from plone.app.controlpanel.security import ISecuritySchema
        security_adapter = ISecuritySchema(portal)
        security_adapter.set_enable_user_folders(True)

        # Commit so that the test browser sees these objects
        portal.portal_catalog.clearFindAndRebuild()
        import transaction
        transaction.commit()
示例#23
0
    def setUpPloneSite(self, portal):
        # Install all the Plone stuff + content (including the
        # Members folder)
        applyProfile(portal, 'Products.CMFPlone:plone')
        applyProfile(portal, 'Products.CMFPlone:plone-content')

        quickInstallProduct(portal, "Products.LinguaPlone")

        applyProfile(portal, 'slc.publications:default')

        # Login as manager and create a test folder
        setRoles(portal, TEST_USER_ID, ['Manager'])
        login(portal, TEST_USER_NAME)
        portal.invokeFactory('Folder', 'folder')

        # Enable Members folder
        from plone.app.controlpanel.security import ISecuritySchema
        security_adapter = ISecuritySchema(portal)
        security_adapter.set_enable_user_folders(True)

        # Commit so that the test browser sees these objects
        portal.portal_catalog.clearFindAndRebuild()
        import transaction
        transaction.commit()
def configureSecurity(context):
    """
    Setup portal security for heavy write test scenario
    """
    if not context.readDataFile('configure_security.txt'):
        return
    
    portal = context.getSite()
    security = ISecuritySchema(portal)
    
    #set anonymous registration
    security.set_enable_self_reg(True)
    
    #set email validation
    security.set_enable_user_pwd_choice(True)
    
    #set member area creation flag
    security.set_enable_user_folders(True)

    security.allow_anon_views_about = True
示例#25
0
def setupRegistration(site):
    securitySchema = ISecuritySchema(site)
    securitySchema.enable_self_reg = True
    securitySchema.enable_user_pwd_choice = True
def set_up_security(site):
    secSchema = ISecuritySchema(site)
    secSchema.set_enable_self_reg(True)
示例#27
0
 def self_register_enabled(self):
     return ISecuritySchema(self.portal).enable_self_reg
示例#28
0
def set_up_security(site):
    secSchema = ISecuritySchema(site)
    secSchema.set_enable_self_reg(True)
def setupPortalContent(portal):
    # delete all content in the root
    for objId in ('front-page', 'news', 'events'):
        if portal.hasObject(objId):
            portal.manage_delObjects(ids=objId)

    # disable tabs
    pprop = getToolByName(portal, 'portal_properties')
    pprop.site_properties._updateProperty('disable_folder_sections', True)

    pw = getToolByName(portal, 'portal_workflow')

    for folder_id, layout, title, allowed_types in sitefolders:
        if not portal.hasObject(folder_id):
            portal.invokeFactory(type_name='Folder', id=folder_id, title=title)
        folder = portal._getOb(folder_id)
        if layout:
            folder.setLayout(layout)
        folder.setConstrainTypesMode(ENABLED)
        folder.setLocallyAllowedTypes(allowed_types)
        folder.setImmediatelyAddableTypes(allowed_types)

        # Nobody is allowed to modify the constraints or tweak the
        # display here
        folder.manage_permission(ModifyConstrainTypes, roles=[])
        folder.manage_permission(ModifyViewTemplate, roles=[])

    # allow members to create activities
    portal.activities.manage_setLocalRoles('AuthenticatedUsers',
        ['Contributor', 'Editor', 'Reader'])

    # allow members to create images in images folder
    portal.images.manage_setLocalRoles('AuthenticatedUsers',
        ['Contributor', 'Editor', 'Reader'])

    # allow member folders to be created
    security_adapter =  ISecuritySchema(portal)
    security_adapter.set_enable_user_folders(True)
    # enable self-registration of users
    security_adapter.set_enable_self_reg(True)

    # create howto and pedagogic folders in videos folder
    videosfolder = portal._getOb('videos')
    if not videosfolder.hasObject('howto'):
        videosfolder.invokeFactory(type_name='Folder', id='howto',
                                   title='How To')
    if not videosfolder.hasObject('pedagogic'):
        videosfolder.invokeFactory(type_name='Folder', id='pedagogic',
                                   title='Pedagogic')
    # create basic language topictree
    topicfolder = portal._getOb('topictrees')
    if not topicfolder.hasObject('language'):
        topicfolder.invokeFactory('collective.topictree.topictree',
                                  'language', title='Language')
        langtree = topicfolder._getOb('language')
        langtree.use_with_activities = True
        langtree.use_with_resources = True
        langtree.invokeFactory('collective.topictree.topic',
                               'afrikaans', title='Afrikaans')
        langtree.invokeFactory('collective.topictree.topic',
                               'english', title='English')
        langtree.invokeFactory('collective.topictree.topic',
                               'isindebele', title='IsiNdebele')
        langtree.invokeFactory('collective.topictree.topic',
                               'isixhosa', title='IsiXhosa')
        langtree.invokeFactory('collective.topictree.topic',
                               'isizulu', title='IsiZulu')
        langtree.invokeFactory('collective.topictree.topic',
                               'sepedi', title='SePedi')
        langtree.invokeFactory('collective.topictree.topic',
                               'setswana', title='Setswana')
        langtree.invokeFactory('collective.topictree.topic',
                               'siswati', title='SiSwati')
        langtree.invokeFactory('collective.topictree.topic',
                               'tshivenda', title='Tshivenda')
        langtree.invokeFactory('collective.topictree.topic',
                               'xitsonga', title='Xitsonga')

    if not topicfolder.hasObject('grade'):
        topicfolder.invokeFactory('collective.topictree.topictree',
                                  'grade', title='Grade')
        tree = topicfolder._getOb('grade')
        tree.use_with_activities = True
        tree.use_with_resources = True
        for i in range(1,5):
            grade_id = 'grade%s' % i
            grade_title = 'Grade %s' % i
            tree.invokeFactory('collective.topictree.topic',
                               grade_id, title=grade_title)

    if not topicfolder.hasObject('term'):
        topicfolder.invokeFactory('collective.topictree.topictree',
                                  'term', title='Term')
        tree = topicfolder._getOb('term')
        tree.use_with_activities = True
        tree.use_with_resources = False
        for i in range(1,5):
            term_id = 'term%s' % i
            term_title = 'Term %s' % i
            tree.invokeFactory('collective.topictree.topic',
                               term_id, title=term_title)

    if not topicfolder.hasObject('subject'):
        topicfolder.invokeFactory('collective.topictree.topictree',
                                  'subject', title='Subject')
        tree = topicfolder._getOb('subject')
        tree.use_with_activities = True
        tree.use_with_resources = True
        tree.invokeFactory('collective.topictree.topic',
                           'lang', title='Language')
        tree.invokeFactory('collective.topictree.topic',
                           'mathematics', title='Mathematics')
        tree.invokeFactory('collective.topictree.topic',
                           'lifeskills', title='Life Skills')


    # set cookie auth url
    acl = getToolByName(portal, 'acl_users')
    acl.credentials_cookie_auth.login_path = '@@select-profile'

    # set TinyMCE link using UIDs
    ptmce = getToolByName(portal, 'portal_tinymce')
    ptmce.link_using_uids = True

    # language settings
    pl = getToolByName(portal, 'portal_languages')
    # nr - IsiNdebele
    # xh - IsiXhosa
    # zu - IsiZulu
    # st - seSotho sa Leboa (Sepedi)
    # tn - Setswana
    # ss - SiSwati
    # ve - Tshivenda
    # ts - Xitsonga

    # nd - ndebele north

    # set allowed languages
    pl.supported_langs = ['af','en','nr','xh','zu','x-nso','st','tn','ss','ve',
                          'ts']

    # Use cookie for manual override. 
    pl.use_cookie_negotiation = True
    # Set the language cookie always
    pl.set_cookie_everywhere = True
示例#30
0
 def test_setuphanders__set_enable_user_folders(self):
     from plone.app.controlpanel.security import ISecuritySchema
     self.assertTrue(ISecuritySchema(self.portal).get_enable_user_folders())
示例#31
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
示例#32
0
    def setUp(self):
        self.portal = self.layer['portal']
        self.request = self.layer['request']
        self.topictrees = self.portal.topictrees
        self.activities = self.portal.activities
        self.resources = self.portal.resources
        self.videos = self.portal.videos
        self.videos_howto = self.portal.videos.howto
        self.videos_pedagogic = self.portal.videos.pedagogic
        setRoles(self.portal, TEST_USER_ID, ['Manager'])
        self.intids = getUtility(IIntIds)

        # create members folder
        self.portal.invokeFactory(type_name='Folder', id='Members',
                                     title='Members')

        # language directory and topics are created by setuphandlers
        if not self.topictrees.hasObject('language'):
            self.topictrees.invokeFactory('collective.topictree.topictree',
                                          'language', title='Language')
        topictree = self.topictrees._getOb('language')
        topictree.use_with_activities = True
        topictree.use_with_resources = True

        if not topictree.hasObject('afrikaans'):
            topictree.invokeFactory('collective.topictree.topic',
                                    'afrikaans', title='Afrikaans')
        if not topictree.hasObject('english'):
            topictree.invokeFactory('collective.topictree.topic',
                                    'english', title='English')
        if not topictree.hasObject('xhosa'):
            topictree.invokeFactory('collective.topictree.topic',
                                    'xhosa', title='Xhosa')

        # add topictree 2 for grades with topic grade1
        if not self.topictrees.hasObject('grade'):
            self.topictrees.invokeFactory('collective.topictree.topictree',
                                          'grade', title='Grade')
        topictree2 = self.topictrees._getOb('grade')
        topictree2.use_with_activities = True
        topictree2.use_with_resources = True

        if not topictree2.hasObject('grade1'):
            topictree2.invokeFactory('collective.topictree.topic',
                                    'grade1', title='Grade1')

        # add topictree 3 for subjects with topic mathematics
        if not self.topictrees.hasObject('subject'):
            self.topictrees.invokeFactory('collective.topictree.topictree',
                                          'subject', title='Subject')
        topictree3 = self.topictrees._getOb('subject')
        topictree3.use_with_activities = True
        topictree3.use_with_resources = True

        if not topictree3.hasObject('mathematics'):
            topictree2.invokeFactory('collective.topictree.topic',
                                    'mathematics', title='Mathematics')

        self.topictree = topictree
        self.topic1 = topictree._getOb('afrikaans')
        self.topic2 = topictree2._getOb('grade1')
        self.topic3 = topictree3._getOb('mathematics')       

        # add 2 resources
        self.resources.invokeFactory('tarmii.theme.content.teacherresource',
                                      'resource1', title='Resource1')
        self.res1 = self.resources._getOb('resource1')
        self.resources.invokeFactory('tarmii.theme.content.teacherresource',
                                      'resource2', title='Resource2')
        self.res2 = self.resources._getOb('resource2')
       
        # link resource1 to topic1 and topic2
        topic_list = [RelationValue(self.intids.getId(self.topic1)),
                      RelationValue(self.intids.getId(self.topic2))]
        self.res1.topics = topic_list
        notify(ObjectModifiedEvent(self.res1))

        # link resource2 to topic2
        topic_list = [RelationValue(self.intids.getId(self.topic2))]
        self.res2.topics = topic_list
        notify(ObjectModifiedEvent(self.res2))

        # add 2 video thumbnails
        self.videos_howto.invokeFactory('Image','vid1thumb', title='Video1')
        self.vid1thumb = self.videos_howto._getOb('vid1thumb')
        self.videos_howto.invokeFactory('Image','vid2thumb', title='Video2')
        self.vid2thumb = self.videos_howto._getOb('vid2thumb')


        # allow member folders to be created
        security_adapter =  ISecuritySchema(self.portal)
        security_adapter.set_enable_user_folders(True)
        # enable self-registration of users
        security_adapter.set_enable_self_reg(True)

        pm = getSite().portal_membership
        # create members folder
        pm.createMemberArea()
        members_folder = pm.getHomeFolder()

        # create classlists folder in members folder
        members_folder.invokeFactory(type_name='Folder', id='classlists_',
                                     title='Class Lists')
        self.classlists = members_folder._getOb('classlists_')
        # create assessments folder in members folder
        members_folder.invokeFactory(type_name='Folder', id='assessments_',
                                     title='Assessments')
        self.assessments = members_folder._getOb('assessments_')
   
        # create evaluation folder in members folder
        members_folder.invokeFactory(type_name='Folder', id='evaluation_',
                                     title='Evaluation')
        self.evaluationsheets = members_folder._getOb('evaluation_')

       
        self.classlists.invokeFactory('upfront.classlist.content.classlist',
                                      'list1', title='List1')
        self.classlist1 = self.classlists._getOb('list1')
        self.classlists.invokeFactory('upfront.classlist.content.classlist',
                                      'list2', title='List2')
        self.classlist2 = self.classlists._getOb('list2')

        self.assessments.invokeFactory('upfront.assessment.content.assessment',
                                      'test1', title='Test1')
        self.assessment1 = self.assessments._getOb('test1')
        self.assessments.invokeFactory('upfront.assessment.content.assessment',
                                      'test2', title='Test2')
        self.assessment2 = self.assessments._getOb('test2')

        eval_factory = 'upfront.assessment.content.evaluationsheet'
        self.evaluationsheets.invokeFactory(eval_factory,
                                      'evalsheet1', title='EvalSheet1')
        self.evaluationsheet1 = self.evaluationsheets._getOb('evalsheet1')
        self.evaluationsheets.invokeFactory(eval_factory,
                                      'evalsheet2', title='EvalSheet2')
        self.evaluationsheet2 = self.evaluationsheets._getOb('evalsheet2')

        classlist1_intid = self.intids.getId(self.classlist1)
        classlist2_intid = self.intids.getId(self.classlist2)
        self.evaluationsheet1.classlist = RelationValue(classlist1_intid)
        self.evaluationsheet2.classlist = RelationValue(classlist2_intid)

        assessment1_intid = self.intids.getId(self.assessment1)
        assessment2_intid = self.intids.getId(self.assessment2)
        self.evaluationsheet1.assessment = RelationValue(assessment1_intid)
        self.evaluationsheet2.assessment = RelationValue(assessment2_intid)

        notify(ObjectModifiedEvent(self.evaluationsheet1))
        notify(ObjectModifiedEvent(self.evaluationsheet2))
        

        # create activities
        self.activities.invokeFactory('upfront.assessmentitem.content.assessmentitem',
                                      'assessmentitem1', title='Activity1')
        self.activity1 = self.activities._getOb('assessmentitem1')
        self.activities.invokeFactory('upfront.assessmentitem.content.assessmentitem',
                                      'assessmentitem2', title='Activity2')
        self.activity2 = self.activities._getOb('assessmentitem2')
        self.activities.invokeFactory('upfront.assessmentitem.content.assessmentitem',
                                      'assessmentitem3', title='Activity3')
        self.activity3 = self.activities._getOb('assessmentitem3')

        # link activity1 to topic1, topic2, topic3
        topic_list = [RelationValue(self.intids.getId(self.topic1)),
                      RelationValue(self.intids.getId(self.topic2)),
                      RelationValue(self.intids.getId(self.topic3))]
        self.activity1.topics = topic_list
        notify(ObjectModifiedEvent(self.activity1))

        # link activity2 to topic2 and topic3
        topic_list = [RelationValue(self.intids.getId(self.topic2)),
                      RelationValue(self.intids.getId(self.topic3))]
        self.activity2.topics = topic_list
        notify(ObjectModifiedEvent(self.activity2))

        # add activities to assessment1
        self.assessment1.assessment_items = [
                            RelationValue(self.intids.getId(self.activity1)),
                            RelationValue(self.intids.getId(self.activity2)),
                            RelationValue(self.intids.getId(self.activity3)),
                            ]
        notify(ObjectModifiedEvent(self.assessment1))

        self.activities.invokeFactory('upfront.assessmentitem.content.assessmentitem',
                                      'assessmentitem4', title='Activity4')
        self.activity4 = self.activities._getOb('assessmentitem4')
示例#33
0
    def setUp(self):
        self.portal = self.layer['portal']
        setRoles(self.portal, TEST_USER_ID, ['Manager'])
        self.request = self.layer['request']
        self.intids = getUtility(IIntIds)

        # create members folder
        self.portal.invokeFactory(type_name='Folder', id='Members',
                                     title='Members')

        self.portal.invokeFactory(type_name='Folder', id='topictrees',
                                  title='Topic Trees')
        folder = self.portal._getOb('topictrees')

        self.topictrees = self.portal.topictrees
        self.topictrees.invokeFactory('collective.topictree.topictree',
                                      'language', title='Language')
        topictree = self.topictrees._getOb('language')

        topictree.invokeFactory('collective.topictree.topic',
                                'afrikaans', title='Afrikaans')
        self.topic1 = topictree._getOb('afrikaans')
        topictree.invokeFactory('collective.topictree.topic',
                                'english', title='English')
        self.topic2 = topictree._getOb('english')
        topictree.invokeFactory('collective.topictree.topic',
                                'xhosa', title='Xhosa')
        self.topic3 = topictree._getOb('xhosa')

        self.topictree = topictree

        # allow member folders to be created
        security_adapter =  ISecuritySchema(self.portal)
        security_adapter.set_enable_user_folders(True)
        # enable self-registration of users
        security_adapter.set_enable_self_reg(True)

        pm = getSite().portal_membership
        # create members folder
        pm.createMemberArea()
        members_folder = pm.getHomeFolder()

        # create classlists folder in members folder
        members_folder.invokeFactory(type_name='Folder', id='classlists',
                                     title='Class Lists')
        self.classlists = members_folder._getOb('classlists')

        # create assessments folder in members folder
        members_folder.invokeFactory(type_name='Folder', id='assessments',
                                     title='Assessments')
        self.assessments = members_folder._getOb('assessments')
    
        # create evaluation folder in members folder
        members_folder.invokeFactory(type_name='Folder', id='evaluation',
                                     title='Evaluation')
        self.evaluationsheets = members_folder._getOb('evaluation')

        # create classlists
        self.classlists.invokeFactory('upfront.classlist.content.classlist',
                                      'list1', title='Classlist1')
        self.classlist1 = self.classlists._getOb('list1')
        self.classlists.invokeFactory('upfront.classlist.content.classlist',
                                      'list2', title='Classlist2')
        self.classlist2 = self.classlists._getOb('list2')

        # add 3 learners to classlist1
        self.classlist1.invokeFactory('upfront.classlist.content.learner',
                                      'learner1', title='Learner1')
        self.learner1 = self.classlist1._getOb('learner1')
        self.classlist1.invokeFactory('upfront.classlist.content.learner',
                                      'learner2', title='Learner2')
        self.learner2 = self.classlist1._getOb('learner2')
        self.classlist1.invokeFactory('upfront.classlist.content.learner',
                                      'learner3', title='Learner3')
        self.learner3 = self.classlist1._getOb('learner3')

        # some details for learner1
        self.learner1.code = '1'
        self.learner1.name = 'John'
        self.learner1.gender = 'Male'

        # some details for learner2
        self.learner2.code = '2'
        self.learner2.name = 'Jennie'
        self.learner2.gender = 'Female'

        # some details for learner3
        self.learner3.code = '3'
        self.learner3.name = 'Nomsa'
        self.learner3.gender = 'Female'

        language_vocab = availableLanguages(self.classlist1).__iter__()
        #associate each language with a learner
        lang = language_vocab.next()
        self.learner1.home_language = RelationValue(lang.value)
        lang = language_vocab.next()
        self.learner2.home_language = RelationValue(lang.value)
        lang = language_vocab.next()
        self.learner3.home_language = RelationValue(lang.value)

        notify(ObjectModifiedEvent(self.learner1))
        notify(ObjectModifiedEvent(self.learner2))
        notify(ObjectModifiedEvent(self.learner3))


        # create assessments
        self.assessments.invokeFactory('upfront.assessment.content.assessment',
                                      'assessment1', title='Assessment1')
        self.assessment1 = self.assessments._getOb('assessment1')
        self.assessments.invokeFactory('upfront.assessment.content.assessment',
                                      'assessment2', title='Assessment2')
        self.assessment2 = self.assessments._getOb('assessment2')


        self.portal.invokeFactory(type_name='Folder', id='activities',
                                  title='Activities')
        self.activities = self.portal._getOb('activities')

        # create activities
        self.activities.invokeFactory('upfront.assessmentitem.content.assessmentitem',
                                      'assessmentitem1', title='Activity1')
        self.activity1 = self.activities._getOb('assessmentitem1')
        self.activities.invokeFactory('upfront.assessmentitem.content.assessmentitem',
                                      'assessmentitem2', title='Activity2')
        self.activity2 = self.activities._getOb('assessmentitem2')
        self.activities.invokeFactory('upfront.assessmentitem.content.assessmentitem',
                                      'assessmentitem3', title='Activity3')
        self.activity3 = self.activities._getOb('assessmentitem3')

        self.activity1.rating_scale =\
            [{'rating': 4, 'label': u'Excellent'}, 
            {'rating': 3, 'label': u'Good'},
            {'rating': 2, 'label': u'Satisfactory'},
            {'rating': 1, 'label': u'Needs improvement'}]

        self.activity2.rating_scale =\
            [{'rating': 4, 'label': u'Excellent'}, 
            {'rating': 3, 'label': u'Good'},
            {'rating': 2, 'label': u'Satisfactory'},
            {'rating': 1, 'label': u'Needs improvement'}]

        self.activity3.rating_scale =\
            [{'rating': 4, 'label': u'Excellent'}, 
            {'rating': 3, 'label': u'Good'},
            {'rating': 2, 'label': u'Satisfactory'},
            {'rating': 1, 'label': u'Needs improvement'}]

        #create 2 extra topics
        topictree.invokeFactory('collective.topictree.topic',
                                'maths', title='Maths')
        self.topic4 = topictree._getOb('maths')
        topictree.invokeFactory('collective.topictree.topic',
                                'science', title='Science')
        self.topic5 = topictree._getOb('science')

        #associate activity1 with topic4
        self.activity1.topics = [RelationValue(self.intids.getId(self.topic4))]
        #associate activity2 with topic5
        self.activity2.topics = [RelationValue(self.intids.getId(self.topic5))]
        notify(ObjectModifiedEvent(self.activity1))
        notify(ObjectModifiedEvent(self.activity2))

        # add activities to assessment1
        self.assessment1.assessment_items = [
                            RelationValue(self.intids.getId(self.activity1)),
                            RelationValue(self.intids.getId(self.activity2)),
                            RelationValue(self.intids.getId(self.activity3)),
                            ]
        notify(ObjectModifiedEvent(self.assessment1))


        # create evaluationsheets
        eval_factory = 'upfront.assessment.content.evaluationsheet'
        self.evaluationsheets.invokeFactory(eval_factory,
                                      'evalsheet1', title='EvalSheet1')
        self.evaluationsheet1 = self.evaluationsheets._getOb('evalsheet1')
        self.evaluationsheets.invokeFactory(eval_factory,
                                      'evalsheet2', title='EvalSheet2')
        self.evaluationsheet2 = self.evaluationsheets._getOb('evalsheet2')

        classlist1_intid = self.intids.getId(self.classlist1)
        self.evaluationsheet1.classlist = RelationValue(classlist1_intid)
        self.evaluationsheet2.classlist = RelationValue(classlist1_intid)

        assessment1_intid = self.intids.getId(self.assessment1)
        self.evaluationsheet1.assessment = RelationValue(assessment1_intid)
        self.evaluationsheet2.assessment = RelationValue(assessment1_intid)

        notify(ObjectModifiedEvent(self.evaluationsheet1))
        # do not notify(ObjectModifiedEvent(self.evaluationsheet2)) as
        # it will be used to specifically to test eventhandlers

        # manually call eventhandlers to create evaluation objects
        # (they were called but all fields were not ready)
        on_evaluationsheet_created(self.evaluationsheet1,None)

        self.evaluation1 = self.evaluationsheet1.getFolderContents()[0].getObject()
        self.evaluation1.evaluation[0]['rating'] = 0
        self.evaluation1.evaluation[1]['rating'] = 0
        self.evaluation1.evaluation[2]['rating'] = 0
        notify(ObjectModifiedEvent(self.evaluation1))

        self.evaluation2 = self.evaluationsheet1.getFolderContents()[1].getObject()
        self.evaluation2.evaluation[0]['rating'] = 0
        self.evaluation2.evaluation[1]['rating'] = 0
        self.evaluation2.evaluation[2]['rating'] = 0
        notify(ObjectModifiedEvent(self.evaluation2))

        self.evaluation3 = self.evaluationsheet1.getFolderContents()[2].getObject()
        self.evaluation3.evaluation[0]['rating'] = 0
        self.evaluation3.evaluation[1]['rating'] = 0
        self.evaluation3.evaluation[2]['rating'] = 0
        notify(ObjectModifiedEvent(self.evaluation3))
示例#34
0
def setupVarious(context, logger=None):
    if logger is None:
        logger = LOG
    logger.info('BCCVL site package setup handler')

    # only run for this product
    if context.readDataFile('org.bccvl.site.marker.txt') is None:
        return
    portal = context.getSite()

    # install Products.AutoUserMakerPASPLugin
    qi = getToolByName(portal, 'portal_quickinstaller')
    if 'AutoUserMakerPASPLugin' in (p['id'] for
                                    p in qi.listInstallableProducts()):
        qi.installProduct('AutoUserMakerPASPlugin')

    # set default front-page
    portal.setDefaultPage('front-page')

    # Setup cookie settings
    sess = portal.acl_users.session
    sess.manage_changeProperties(
        mod_auth_tkt=True,
    )
    # set cookie secret from celery configuration
    from org.bccvl.tasks.celery import app
    cookie_cfg = app.conf.get('bccvl', {}).get('cookie', {})
    if cookie_cfg.get('secret', None):
        sess._shared_secret = cookie_cfg.get('secret').encode('utf-8')
        sess.manage_changeProperties(
            secure=cookie_cfg.get('secure', True)
        )

    # setup default groups
    groups = [
        {'id': 'Knowledgebase Contributor',
         'title': 'Knowledgebase Contributor',
         #'roles': ['...', '...']
         'description': 'Users in this group can contribute to knowledge base'
         },
        {'id': 'Knowledgebase Editor',
         'title': 'Knowledgebase Editor',
         'description': 'Users in this group can manage knowledgebase content'
         }]
    gtool = getToolByName(portal, 'portal_groups')
    for group in groups:
        if gtool.getGroupById(group['id']):
            gtool.editGroup(**group)
        else:
            gtool.addGroup(**group)

    # 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 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:
        # disable media plugin which get's in the way all the time
        current_plugins.remove('media')
    tinymce.plugins = current_plugins