Exemplo n.º 1
0
    def __call__(self):
        context = self.context

        languages_tool = getToolByName(context, "portal_languages")
        default_language = languages_tool.getDefaultLanguage()

        request = self.request
        language = request.get("language", default_language)

        url_tool = getToolByName(context, "portal_url")
        folder = url_tool.getPortalObject()

        if language != default_language:
            folder = folder.restrictedTraverse(language)

        if not hasattr(folder.aq_base, "fourohfour"):

            item = createContentInContainer(folder, "Document", checkConstraints=True, title="404 page")

            # Since the document type provides the INameFromTitle
            # behavior, we cannot override it, so we need to
            # rename the object :(

            folder.manage_renameObject(item.id, "fourohfour")

            # Mark the element using the marker interface
            mark(item, IFourOhFourPage)

            # Remember to reindex, marking an object does _not_
            # trigger events.
            item.reindexObject()

        return request.RESPONSE.redirect(folder.absolute_url() + "/fourohfour/edit")
Exemplo n.º 2
0
def applyRecentProjectMarker(obj, event):
    recent = obj.recent
    if recent is True:
        mark(obj, IRecentMarker)
    else:
        erase(obj, IRecentMarker)
    obj.reindexObject(idxs=['object_provides'])
 def mySetup(self):
     self.setRoles(('Manager',))
     id = self.portal.invokeFactory('Document', 'doc')
     options = interfaces.IGetPaidManagementOptions(self.portal)
     options.buyable_types = ['Document']
     mark(self.portal.doc, interfaces.IBuyableMarker)
     self.cart_util = getUtility(IShoppingCartUtility)
Exemplo n.º 4
0
def _apply_interfaces(portal):
    to_apply = {'aeroportos-brasileiros': IAeroporto,
                'aplicativos-e-ferramentas': IAplicativo,
                'guia-do-passageiro': IGuiaDoPassageiro}
    to_apply = {k: v for k, v in to_apply.iteritems() if hasattr(portal, k)}
    for i in to_apply:
        mark(portal[i], to_apply[i])
Exemplo n.º 5
0
 def mySetup(self):
     self.setRoles(('Manager', ))
     id = self.portal.invokeFactory('Document', 'doc')
     options = interfaces.IGetPaidManagementOptions(self.portal)
     options.buyable_types = ['Document']
     mark(self.portal.doc, interfaces.IBuyableMarker)
     self.cart_util = getUtility(IShoppingCartUtility)
    def migrate(self, old, new):
        marker.mark(new, ILogoMarker)

        for name, field in schema.getFieldsInOrder(ILogoContent):
            migrate_simplefield(old, ILogoContent(new), name, name)

        _logger.info("Migrating Logo Content for %s" % new.absolute_url())
Exemplo n.º 7
0
    def test_mode(self):
        portal = self.layer['portal']
        util = getUtility(IStripeUtility)
        settings = get_settings()

        settings.mode = 'test'
        mode = util.get_mode_for_context(portal)
        self.assertEqual(mode, 'test')

        settings.mode = 'live'
        mode = util.get_mode_for_context(portal)
        self.assertEqual(mode, 'live')

        # Now mark with IStripeModeChooser and test overriding the mode by context
        mark(portal, IStripeModeChooser)

        portal.stripe_mode = 'test'
        portal.get_stripe_mode = lambda: 'test'
        mode = util.get_mode_for_context(portal)
        self.assertEqual(mode, 'test')
        
        settings.mode = 'test'
        portal.get_stripe_mode = lambda: 'live'
        mode = util.get_mode_for_context(portal)
        self.assertEqual(mode, 'live')
Exemplo n.º 8
0
def create_ploneconference(p):
    ''' Create Plone Conference folder
    '''
    oIds = p.objectIds()
    oId = 'ploneconf'
    if not oId in oIds:
        title = u'Plone Conference 2013'
        desc = u'Plone Conference 2013'
        _createObjectByType('Folder', p, id=oId,
                            title=title, description=desc)
    o = p[oId]
    o.setLanguage('en')
    # Set INavigationRoot
    mark(o, INavigationRoot)
    # Publish content
    p.portal_workflow.doActionFor(o, 'publish')
    logger.info('Plone Conference folder created')
    sub_folders = [
        ('the-event', 'The Event'),
        ('venue', 'Venue'),
        ('sponsors', 'Sponsors'),
        ('schedule', 'Schedule'),
        ('spread-the-word', 'Spread the Word'),
        ('contact', 'Contact'),
    ]
    for fId, title in sub_folders:
        _createObjectByType('Folder', o, id=fId,
                            title=title)
        folder = o[fId]
        p.portal_workflow.doActionFor(folder, 'publish')
        logger.info('Plone Conference: %s folder created' % title)
Exemplo n.º 9
0
    def migrate(self, old, new):
        marker.mark(new, IFlowViewMarker)
            
        for name, field in schema.getFieldsInOrder(IFlowViewSettings):
            migrate_simplefield(old, IFlowViewSettings(new), name, name)

        _logger.info(
            "Migrating FlowView Settings for %s" % new.absolute_url())
Exemplo n.º 10
0
def initPackage(context):
    catalog = api.portal.get_tool('portal_catalog')
    brains = catalog(portal_type='PlominoDatabase')
    for brain in brains:
        db = brain.getObject()
        for doc in db.getAllDocuments():
            if not IIolDocument.providedBy(doc):
                mark(doc, IIolDocument)
Exemplo n.º 11
0
def initPackage(context):
    catalog = api.portal.get_tool('portal_catalog')
    brains = catalog(portal_type='PlominoDatabase')
    for brain in brains:
        db = brain.getObject()
        for doc in db.getAllDocuments():
            if not IIolDocument.providedBy(doc):
                mark(doc,IIolDocument)
Exemplo n.º 12
0
    def render(self):
        folder = self.context

        if not IContainerdownloadablelist.providedBy(folder):
            mark(folder,IContainerdownloadablelist)
            return "I has marked the folders as Containerdownloadablelist!" 
        else:
            return "It has been marked as Containerdownloadablelist!"    
Exemplo n.º 13
0
    def update(self):
        marker.mark(self.context, self.marker)
        self.adapters = {
            self.interface: options.PropertyBag.makeinstance(self.interface),
            self.interface: options.PropertyBag.makeinstance(self.interface)
        }

        return super(BaseEnvironmentForm, self).update()
Exemplo n.º 14
0
    def render(self):
        folder = self.context

        if not IPunishTablelist.providedBy(folder):
            mark(folder,IPunishTablelist)
            return "I has marked the folders as FolderPunishtablelist!" 
        else:
            return "It has been marked as FolderPunishtablelist!"
Exemplo n.º 15
0
    def render(self):
        j = 0
        for obj in self.getMemberList():
            j = j+1
            folder = obj.getObject()

            mark(folder,IContainerTablelist)
        
        return "I has marked %s folders!" % (j) 
Exemplo n.º 16
0
def mark_linked_object(context, event):
    """
    Mark linked object with marker interface to keep title and description in sync.
    """
    if context.getAlias() and context.getAutoTitle():
        obj = context.getAlias()
        if not IAliasLinkedTo.providedBy(obj):
            mark(obj, IAliasLinkedTo)
            setattr(context, '_alias_linked_object', obj.UID())
Exemplo n.º 17
0
    def __call__(self):

        ifid = self.request.form.keys()[0]
        try:
            ifobj = resolve(ifid)
        except:
            return "interface %s can not be resolved" % (ifid)
        context = aq_inner(self.context)
        mark(context, ifobj)
        return "I has marked %s to provide %s" % (context.id, ifid)
def set_actions(context):
    """
    Set registration actions
    """
    if getattr(context, "is_registration_form", False):
        mark(context, IEasyFormRegistrationEnabled)
        updateActionsSchema(context)
    else:
        erase(context, IEasyFormRegistrationEnabled)
    context.reindexObject(idxs=["object_provides"])
Exemplo n.º 19
0
    def __call__(self):

        ifid = self.request.form.keys()[0]
        try:
            ifobj = resolve(ifid)
        except:
            return "interface %s can not be resolved" % (ifid)
        context = aq_inner(self.context)
        mark(context,ifobj)        
        return "I has marked %s to provide %s" % (context.id,ifid)        
Exemplo n.º 20
0
    def update( self ):
        marker.mark( self.context, self.marker)

        # create a temporary object so we don't have to modify context until we're ready to activate
        # it.. this creates some odd behavior on remarking though, where the user is always filling
        # in new values even though previously values are present in the underlying contxt annotation.
        self.adapters = { self.interface : options.PropertyBag.makeinstance( self.interface ),
                          igetpaid.IPayable : options.PropertyBag.makeinstance( igetpaid.IPayable ) }

        return super( PayableForm, self).update()
    def set_navigationroot(self):
        """ Set INavigationRoot on current context object """
        from Products.Five.utilities.marker import mark
        from plone.app.layout.navigation.interfaces import INavigationRoot
        from plone.protect.interfaces import IDisableCSRFProtection
        from zope.interface import alsoProvides

        alsoProvides(self.request, IDisableCSRFProtection)
        mark(self.context, INavigationRoot)

        self.request.response.setStatus(200)
Exemplo n.º 22
0
def doOnInstall(site, addon_name):

    site_domain = platform.uname()[1]

    forum_id = 'forumail'
    forum_name = 'Forumail'

    user_id = 'forumailer'
    user_name = 'Foru Mailer'

    group_id = 'Forumailers'
    group_name = 'Forumailers'

    # Create forum:
    forum = api.content.create(type='Folder', title=forum_name, container=site)
    # Assign interface for mail-dropping via mailtoplone.base:
    mark(forum, IBlogMailDropBoxMarker)
    # Set default-view of forum:
    forum.setLayout('forumail_view')
    # Create group:
    api.group.create(groupname=group_id, title=group_name)
    # Assign group-permissions to forum:
    forum.manage_setLocalRoles(group_id, ['Contributor', 'Reader'])
    # Update content- and permission-change in portal_catalog:
    forum.reindexObject()
    forum.reindexObjectSecurity()

    # Import contentrule of profile 'forumail'
    # (! If this is done before content-creation and no user is assigned to group,
    # contentrule will righteously complain, that there's nobody to send the mail to.)
    # and complain, no recipients are designated:
    site.portal_setup.runAllImportStepsFromProfile(
        'profile-' + addon_name + ':' + addon_name.split('.')[1],
        ignore_dependencies=True)
    # Assign contentrule to forum:
    assign_rule(forum, forum_id)

    if site_domain != 'localhost.localdomain':

        user_mail = user_id + '@' + site_domain

        # Add user, we need at least one, so collective.contentrule.mailtogroup  will not complain:
        api.user.create(username=user_id,
                        password=user_id,
                        email=user_mail,
                        properties=dict(fullname=user_name))
        # Assign user to group:
        api.group.add_user(groupname=group_id, username=user_id)
        # Create forum-post, should trigger an email-noti:
        post = api.content.create(
            type='News Item',
            title='Welcome to the Forum of "%s"' % site.Title(),
            text='Express yourself, don\'t repress yourself!',
            container=forum)
Exemplo n.º 23
0
def upgrade09(site):
    refcat = getToolByName(site, 'reference_catalog')
    refs = (brain.getObject() for brain in \
               refcat(relationship=config.BACKLINK_RELATIONSHIP))

    for ref in refs:
        if ref:
            obj=ref.getSourceObject()
            mark(obj, IWickedTarget)
            if not IWickedBacklink.providedBy(ref):
                print ref
                mark(ref, IWickedBacklink)
Exemplo n.º 24
0
 def setUp(self):
     self.portal = self.layer['portal']
     self.portal_url = self.portal.absolute_url()
     self.request = self.layer['request']
     # create user
     acl_users = getToolByName(self.portal, 'acl_users')
     acl_users.userFolderAddUser('ploneuser', 'secret', ['Manager'], [])
     # apply changes
     transaction.commit()
     # this marking is not temporary
     # details: http://developer.plone.org/components/interfaces.html#id13
     mark(self.request, ICollectiveRequestPlayer)
Exemplo n.º 25
0
def upgrade09(site):
    refcat = getToolByName(site, 'reference_catalog')
    refs = (brain.getObject() for brain in \
               refcat(relationship=config.BACKLINK_RELATIONSHIP))
    
    for ref in refs:
        if ref:
            obj=ref.getSourceObject()
            mark(obj, IWickedTarget)
            if not IWickedBacklink.providedBy(ref):
                print ref
                mark(ref, IWickedBacklink)
Exemplo n.º 26
0
 def setUp(self):
     self.portal = self.layer['portal']
     self.portal_url = self.portal.absolute_url()
     self.request = self.layer['request']
     # create user
     acl_users = getToolByName(self.portal, 'acl_users')
     acl_users.userFolderAddUser('ploneuser', 'secret', ['Manager'], [])
     # apply changes
     transaction.commit()
     # this marking is not temporary
     # details: http://developer.plone.org/components/interfaces.html#id13
     mark(self.request, ICollectiveRequestPlayer)
Exemplo n.º 27
0
    def update(self):
        marker.mark(self.context, self.marker)

        # create a temporary object so we don't have to modify context until we're ready to activate
        # it.. this creates some odd behavior on remarking though, where the user is always filling
        # in new values even though previously values are present in the underlying contxt annotation.
        self.adapters = {
            self.interface: options.PropertyBag.makeinstance(self.interface),
            igetpaid.IPayable:
            options.PropertyBag.makeinstance(igetpaid.IPayable)
        }

        return super(PayableForm, self).update()
Exemplo n.º 28
0
    def _set_sql_folder_id(self, value):
        old_value = self.context.sql_folder_id
        if value:
            self.context.sql_folder_id = value
        else:
            self.context.sql_folder_id = None
        if value != old_value:
            site = getSite()
            old_object = None
            if old_value:
                if hasattr(old_value,
                           'startswith') and old_value.startswith('/'):
                    try:
                        old_object = site.restrictedTraverse(old_value)
                    except:
                        pass
                else:
                    try:
                        old_object = uuidToObject(old_value)
                    except:
                        pass
            new_object = None
            if value:
                try:
                    new_object = uuidToObject(value)
                except:
                    pass
            if old_object:
                marker.erase(old_object, ISQLTraverser)
                if IAnnotations(old_object).get(
                        'collective.behavior.sql.sql_type'):
                    del IAnnotations(
                        old_object)['collective.behavior.sql.sql_type']


#                catalog = getToolByName(getSite(), "portal_catalog")
#                ordering = old_object.getOrdering()
#                virtualbrains = catalog.searchResults(portal_type=self.context.id, sql_virtual=True)
#                for brain in virtualbrains:
#                    while brain.getId in ordering.idsInOrder():
#                        ordering.notifyRemoved(brain.getId)
            if new_object:
                marker.mark(new_object, ISQLTraverser)
                IAnnotations(new_object)[
                    'collective.behavior.sql.sql_type'] = self.context.id
            else:
                registerPublisherForFTI(self)
Exemplo n.º 29
0
def install( self ):

    out = StringIO()

    print >> out, "Installing Alchemist OrgPeople Example"

    # ensure dependencies
    self.portal_quickinstaller.installProduct('CMFonFive')

    print >> out, "Adding Person Container"
    container = AlchemistContainer( "people", "Products.orgpeople.domain.Person", "People")
    mark( container, IPersonContainer )
    
    portal = self.portal_url.getPortalObject()    
    portal._setObject( container.id, container )

    return out.getvalue()
Exemplo n.º 30
0
def doOnInstall(site, addon_name):

    site_domain = platform.uname()[1]

    forum_id = 'forumail'
    forum_name = 'Forumail'

    user_id = 'forumailer'
    user_name = 'Foru Mailer'

    group_id = 'Forumailers'
    group_name = 'Forumailers'

    # Create forum:    
    forum = api.content.create(type='Folder', title=forum_name, container=site)
    # Assign interface for mail-dropping via mailtoplone.base:
    mark(forum, IBlogMailDropBoxMarker)
    # Set default-view of forum:
    forum.setLayout('forumail_view')
    # Create group:
    api.group.create(groupname=group_id, title=group_name)
    # Assign group-permissions to forum:
    forum.manage_setLocalRoles(group_id, ['Contributor', 'Reader'])
    # Update content- and permission-change in portal_catalog:
    forum.reindexObject()
    forum.reindexObjectSecurity()

 
    # Import contentrule of profile 'forumail' 
    # (! If this is done before content-creation and no user is assigned to group,
    # contentrule will righteously complain, that there's nobody to send the mail to.)
    # and complain, no recipients are designated:
    site.portal_setup.runAllImportStepsFromProfile('profile-' + addon_name + ':' + addon_name.split('.')[1], ignore_dependencies=True)
    # Assign contentrule to forum:
    assign_rule(forum, forum_id)

    if site_domain != 'localhost.localdomain':
        
        user_mail = user_id + '@' + site_domain

        # Add user, we need at least one, so collective.contentrule.mailtogroup  will not complain:
        api.user.create(username=user_id, password=user_id, email=user_mail, properties=dict(fullname=user_name))
        # Assign user to group:
        api.group.add_user(groupname=group_id, username=user_id)
        # Create forum-post, should trigger an email-noti:
        post = api.content.create(type='News Item', title='Welcome to the Forum of "%s"'%site.Title(), text='Express yourself, don\'t repress yourself!', container=forum)
Exemplo n.º 31
0
def create_pythonbrasil(p):
    ''' Create PythonBrasil folder
    '''
    oIds = p.objectIds()
    oId = 'pythonbrasil'
    if not oId in oIds:
        title = u'PythonBrasil [9]'
        desc = u'PythonBrasil [9]'
        _createObjectByType('Folder', p, id=oId,
                            title=title, description=desc)
    o = p[oId]
    o.setLanguage('pt-br')
    # Set INavigationRoot
    mark(o, INavigationRoot)
    # Publish content
    p.portal_workflow.doActionFor(o, 'publish')
    logger.info('PythonBrasil folder created')
Exemplo n.º 32
0
def add_cnrd_member(site, userId, last, first, email, password, portrait=None):
    context = site["people"]

    if userId in context:
        print "Couldn't add %s, a vc-member with this id already exists." % (id)
        return

    member_obj = add_member_object(context, userId, u"%s %s" % (first, last), email.strip(), sendInvitation=False)
    add_plone_member(member_obj, password)
    activate_member_object(member_obj)
    mark(context[userId], IDemoContent)

    if portrait:
        context[userId].portrait = portrait

    context[userId].role = "student"

    notify(ObjectModifiedEvent(context[userId]))
Exemplo n.º 33
0
    def setUp(self):
        portal = self.layer['portal']
        setRoles(portal, TEST_USER_ID, ('Manager', ))
        portal.invokeFactory('Folder', 'cishanzixun')
        portal['cishanzixun'].invokeFactory('Folder',
                                            'gongyixinwen',
                                            title=u"公益新闻",
                                            description=u"公益新闻")
        portal.invokeFactory('Folder', 'aixingongshi')

        portal['aixingongshi'].invokeFactory('Folder',
                                             'juanzenggongshi',
                                             title=u"捐赠公示",
                                             description=u"捐赠公示")

        self.target = portal['aixingongshi']['juanzenggongshi']
        mark(self.target, ifobj)
        self.portal = portal
Exemplo n.º 34
0
    def _set_sql_folder_id(self, value):
        old_value = self.context.sql_folder_id
        self.context.sql_folder_id = value
        if value != old_value:
            old_object = old_value and old_value.to_object or None
            new_object = value and value.to_object or None
            if old_object:
                marker.erase(old_object, ISQLTraverser)
                if IAnnotations(old_object).get('collective.behavior.sql.sql_type'):
                    del IAnnotations(old_object)['collective.behavior.sql.sql_type']
                catalog = getToolByName(getSite(), "portal_catalog")
#                ordering = old_object.getOrdering()
                virtualbrains = catalog.searchResults(portal_type=self.context.id, sql_virtual=True)
#                for brain in virtualbrains:
#                    while brain.getId in ordering.idsInOrder():
#                        ordering.notifyRemoved(brain.getId)
            if new_object:
                marker.mark(new_object, ISQLTraverser)
                IAnnotations(new_object)['collective.behavior.sql.sql_type'] = self.context.id
Exemplo n.º 35
0
def _create_content(item, container):
    new = container.get(item['id'], None)
    if not new:

        new = api.content.create(type=item['type'],
                                 container=container,
                                 title=item['title'],
                                 description=item['description'],
                                 id=item['id'],
                                 safe_id=False)
        logger.info('Created item {}'.format(new.absolute_url()))

    if item.get('layout', False):
        new.setLayout(item['layout'])
    if item.get('query', False):
        new.query = item['query']
    if item.get('sort_on', False):
        new.sort_on = item['sort_on']
    if item.get('sort_reversed', False):
        new.sort_reversed = item['sort_reversed']
    if item.get('image', False):
        new.image = item['image']
    if item.get('markif', False):
        try:
            ifobj = resolve(item['markif'])
            mark(new, ifobj)
        except BaseException:
            pass
    if item.get('default-page', False):
        new.setDefaultPage(item['default-page'])
    if item.get('allowed_types', False):
        _constrain(new, item['allowed_types'])
    if item.get('local_roles', False):
        for local_role in item['local_roles']:
            api.group.grant_roles(groupname=local_role['group'],
                                  roles=local_role['roles'],
                                  obj=new)
    if item.get('publish', False):
        api.content.transition(new, to_state=item.get('state', 'published'))
    new.reindexObject()
    # call recursively for children
    for subitem in item.get('children', []):
        _create_content(subitem, new)
Exemplo n.º 36
0
def install(self):

    out = StringIO()

    print >> out, "Installing Alchemist OrgPeople Example"

    # ensure dependencies
    self.portal_quickinstaller.installProduct('CMFonFive')

    print >> out, "Adding Person Container"
    container = AlchemistContainer("people",
                                   "Products.orgpeople.domain.Person",
                                   "People")
    mark(container, IPersonContainer)

    portal = self.portal_url.getPortalObject()
    portal._setObject(container.id, container)

    return out.getvalue()
Exemplo n.º 37
0
    def __iter__(self):
        for item in self.previous:
            if not self.condition(item):
                logging.getLogger("jsonmigrator.marker").debug("Condition not satisfied")
                yield item
                continue

            pathkey = self.pathkey(*item.keys())[0]
            # not enough info
            if not pathkey:
                logging.getLogger("jsonmigrator.marker").debug("Path not supplied")
                yield item
                continue

            path = item[pathkey]
            ## Skip the Plone site object itself
            # if not path:
            # yield item
            # continue

            obj = self.context.unrestrictedTraverse(path.encode().lstrip("/"), None)

            # path doesn't exist
            if obj is None:
                logging.getLogger("jsonmigrator.marker").debug("No object at path")
                yield item
                continue

            interface_name = self.interface
            if interface_name is None:
                logging.getLogger("jsonmigrator.marker").warning("interface option not set")
                yield item
                continue

            try:
                interface_class = resolve(interface_name)
                mark(obj, interface_class)
            except Exception, e:
                logging.getLogger("jsonmigrator.marker").error("Error setting interface %s", str(e))
                pass

            yield item
Exemplo n.º 38
0
    def share_with_principal(self, principal_id, role):
        """ Setup proper share role for this principal
        """
        logger.info("Setting up proper %s role for %s", role, principal_id)
        print "Sharing", principal_id, role

        contexts = [self.context]
        wc = self.get_wc(self.context)
        if wc:
            contexts.append(wc)

        site = getSite()
        for location in PLONE_LOCATIONS:
            if self.context.aq_parent.id != 'countries':
                continue
            obj = site.unrestrictedTraverse(location + self.context.id)
            if obj:
                contexts.append(obj)
        for folder in contexts:
            self.assign_role_to_principal(folder, role, principal_id)
            if ICountryPage not in list(providedBy(folder)):
                mark(folder, ICountryPage)
Exemplo n.º 39
0
def fillBasicPortalStructure(plonesite, fresh):
    """
    """
    createPloneObjects(plonesite, BASICSTRUCTURE2, fresh)
    # Now mark certain objects as undeleteable
    mark(plonesite.esd['front-page'], IDocumentPoolUndeleteable)
    mark(plonesite.esd.overview, IDocumentPoolUndeleteable)
    mark(plonesite.esd.recent, IDocumentPoolUndeleteable)
Exemplo n.º 40
0
 def __init__(self, context):
     self.context = context
     mark(context, IMapEnabled)
Exemplo n.º 41
0
def handleCheckout( event ):
    marker.mark( event.working_copy, interfaces.IWorkingCopy )
    marker.mark( event.object, interfaces.IBaseline )
Exemplo n.º 42
0
 def render(self):
     portal = api.portal.get()
     mark(portal, IBannerEnabled)
     return self.request.response.redirect(portal.absolute_url())
Exemplo n.º 43
0
def handleCheckout(event):
    marker.mark(event.working_copy, interfaces.IWorkingCopy)
    marker.mark(event.object, interfaces.IBaseline)
Exemplo n.º 44
0
    def applyChanges(self, data):
        fivemarker.mark(self.context, ISolgemaRichMenuMarker)
        changes = super(z3cManageSolgemaRichMenuAttributes, self).applyChanges(data)
        aq_inner(self.context).reindexObject()
#        global_cache.invalidate('Solgema.RichMenu.viewlets.common.firstLevelTabs')
        return changes
Exemplo n.º 45
0
 def __init__(self, context):
     if 'collective.behavior.sql.behavior.behaviors.ISQLContent' in context.behaviors:
         if not ISQLDexterityFTI.providedBy(context):
             # mark this DexterityFTI with our marker so that we can use custom adapters and views (++add++, ...)
             marker.mark(context, ISQLDexterityFTI)
         if not 'sql_connection' in [a['id'] for a in context._properties]:
             context._properties = context._properties + (
                 {
                     'id': 'sql_connection',
                     'type': 'string',
                     'mode': 'w',
                     'label': 'SQL Connections',
                     'description': 'SQL Connections to the databases.'
                 },
                 {
                     'id': 'sql_table',
                     'type': 'string',
                     'mode': 'w',
                     'label': 'SQL Table',
                     'description': "Name of the SQL Table used for data source for "
                                    "this type."
                 },
                 {
                     'id': 'sql_id_column',
                     'type': 'string',
                     'mode': 'w',
                     'label': 'SQL ID Column',
                     'description': "The column that will be the source if ID."
                 },
                 {
                     'id': 'sql_WHERE',
                     'type': 'string',
                     'mode': 'w',
                     'label': 'WHERE',
                     'description': "Use a custom WHERE clause to filter the sql table. You must specify only the WHERE clause and not the whole query clause. Example:WHERE type = 'public'"
                 },
                 {
                     'id': 'sql_fields_columns',
                     'type': 'lines',
                     'mode': 'w',
                     'label': 'SQL Fields Columns',
                     'description': "Stores the correspondance between field and sql column."
                 },
 #                {
 #                    'id': 'sql_folder_id',
 #                    'type': 'string',
 #                    'mode': 'w',
 #                    'label': "Folder ID",
 #                    'description': "The ID of the virtal folder that contains the sql items. If left blank, the id of the type."
 #                },
             )
             context.sql_connection = ''
             context.sql_table = ''
             context.sql_id_column = ''
             context.sql_WHERE = ''
             context.sql_fields_columns = []
             context.sql_folder_id = None
             context.sql_modification_timestamp_column = None
             context.sql_modification_last_timestamp = None
             context.klass = 'collective.behavior.sql.content.SQLDexterityItem'
     self.context = context
 def test_banned_styles_not_in_tinymce(self):
     mark(self.portal, ITinyMCE)
     view = self.portal.restrictedTraverse('tinymce-getstyle')()
     for banned_style in TINYMCE_BANNED_STYLES:
         self.assertNotIn(banned_style, view)
Exemplo n.º 47
0
 def __init__(self, context, request):
     super(BaseFlowView, self).__init__(context, request)
     marker.mark( self.context, IFlowViewMarker )
Exemplo n.º 48
0
def initializeAreas(pm_tool, acl_tool, request, member_folder_id=None):
    """
    Creates custom content in the member's folder.
    Create group spaces and content for the member's groups.
    
    1. Create private space for the user.
    2. Create public space for user if they are a member of parliament.
    3. Populate the public space with custom content
    4. Create group home folder for any groups (except a parliament) this user is a member of.
        3.1 Create a private space for the group home folder.
        3.2 Create a public space for the group home folder
        3.3 Populate the public space with custom content.
    """
    portal = getSite()
    sm = getSecurityManager()

    tmp_user = BaseUnrestrictedUser(sm.getUser().getId(),'', ['Manager'],'')
    newSecurityManager(None, tmp_user)    
    acl_tool = getToolByName(portal, 'acl_users')
    
    if "groups" in portal.objectIds():
        groups_space = portal["groups"]
    if member_folder_id:
        member = pm_tool.getMemberById(decleanId(member_folder_id))
    else:
        member = pm_tool.getAuthenticatedMember()
    member_id = member.getId()
    folder = pm_tool.getHomeFolder(member_id)
         
    #All members get a private workspace area.
    create_space(folder, "private_space", "Private Space", "private", member_id, member, "PrivateFolder")   
    member_groupIds = member.getGroupIds()
    for member_groupId in member_groupIds:
        group_membership_roles = doSearch(acl_tool, member_groupId)
        if "bungeni.MP" in group_membership_roles:
            create_space(folder, "web_space", "Web Space", "publish", member_id, member, "PublicFolder")
            parent_space = getattr(folder, "web_space")
            mark(parent_space, IMemberSpace)    
            parent_space.setLayout("space_view")  
            create_content(parent_space, MEMBER_SPACE_CONTENT, member, "publish")


    groups_space = portal["groups"]

    for member_groupId in member_groupIds:
        group_membership_roles = doSearch(acl_tool, member_groupId)
        #if group home folder does not exist
        #it is cheaper to check if the group home folder already exists, then exit if it does
        for bungeni_group in acl_tool.bungeni_groups.enumerateGroups():

            if (member_groupId == bungeni_group["id"]) and ("bungeni.MP" not in group_membership_roles) and (bungeni_group["id"]not in groups_space.objectIds()):
                group = acl_tool.bungeni_groups.getGroupById(bungeni_group["id"])                 
                create_space(groups_space, bungeni_group["id"],
                    bungeni_group["title"], "private", bungeni_group["id"], 
                    group, "Folder")
                parent_space = getattr(groups_space, bungeni_group["id"])               
                create_space(parent_space, "private_space", "Private Space", 
                    "private", bungeni_group["id"], 
                    group, "PrivateFolder")                       
                create_space(parent_space, "web_space", "Web Space", 
                    "publish", bungeni_group["id"], 
                     group, "PublicFolder") 
                parent_space = getattr(parent_space, "web_space")
                mark(parent_space, IGroupSpace)  
                parent_space.setLayout("space_view")
                create_content(parent_space, GROUP_SPACE_CONTENT, group, "publish")
Exemplo n.º 49
0
def install( self, reinstall=False ):
    out = StringIO()
    setup_tool = getToolByName(self, 'portal_setup')
    setup_tool.runAllImportStepsFromProfile('profile-Solgema.EnvironmentViewlets:default', purge_old=False)
    if not reinstall:
        portal = getToolByName( self, 'portal_url').getPortalObject()
        wftool = getToolByName(portal, 'portal_workflow')
        for oldPortalType in oldContentsInterfaces.keys():
            oldContents = portal.portal_catalog.searchResults({'portal_type':oldPortalType,})
            for oldContent in oldContents:
                bandeau = oldContent.getObject()
                baseid = bandeau.id
                baseimage = bandeau.getImage()
                basetitle = bandeau.pretty_title_or_id()
                basedescription = bandeau.Description()
                basewf = wftool.getInfoFor(bandeau, 'review_state')

                parent = aq_parent(aq_inner(bandeau))

                parent.manage_delObjects(baseid)

                _createObjectByType('Image', parent, id=baseid,
                                title=basetitle,
                                description=basedescription, 
                                image=baseimage, 
                                excludeFromNav=True,
                                excludeFromContent=True,)

                newBandeau = getattr(parent, baseid)
                newBandeau.setLanguage('fr')
                newBandeau.unmarkCreationFlag()
                marker.mark( newBandeau, oldContentsInterfaces[oldPortalType] )
                newBandeau.reindexObject()

                if basewf == 'published':
                    wftool.doActionFor(newBandeau, 'publish')
                if basewf == 'visible':
                    wftool.doActionFor(newBandeau, 'show')

        oldCoordonnees = portal.portal_catalog.searchResults({'portal_type':'Coordonnees'})
        for oldContent in oldCoordonnees:
            bandeau = oldContent.getObject()
            baseiddisplay = bandeau.id
            basedisplay = bandeau.getCoordonnees_display()
            basetitledisplay = bandeau.pretty_title_or_id()+' Affichage'
            baseidprint = bandeau.id+'_print'
            baseprint = bandeau.getCoordonnees_print()
            basetitleprint = bandeau.pretty_title_or_id()+' Impression'
            basedescription = bandeau.Description()
            basewf = wftool.getInfoFor(bandeau, 'review_state')

            parent = aq_parent(aq_inner(bandeau))

            parent.manage_delObjects(baseiddisplay)

            _createObjectByType('Document', parent, id=baseiddisplay,
                            title=basetitledisplay,
                            description=basedescription, 
                            text=basedisplay, 
                            excludeFromNav=True,
                            excludeFromContent=True,)

            _createObjectByType('Document', parent, id=baseidprint,
                            title=basetitleprint,
                            description=basedescription, 
                            text=baseprint, 
                            excludeFromNav=True,
                            excludeFromContent=True,)

            newCoordDisplay = getattr(parent, baseiddisplay)
            newCoordDisplay.setLanguage('fr')
            newCoordDisplay.unmarkCreationFlag()
            marker.mark( newCoordDisplay, interfaces.IFooterMarker )
            newCoordDisplay.reindexObject()

            if basewf == 'published':
                wftool.doActionFor(newCoordDisplay, 'publish')
            if basewf == 'visible':
                wftool.doActionFor(newCoordDisplay, 'show')

            newCoordPrint = getattr(parent, baseidprint)
            newCoordPrint.setLanguage('fr')
            newCoordPrint.unmarkCreationFlag()
            marker.mark( newCoordPrint, interfaces.IPrintFooterMarker )
            newCoordPrint.reindexObject()

            if basewf == 'published':
                wftool.doActionFor(newCoordPrint, 'publish')
            if basewf == 'visible':
                wftool.doActionFor(newCoordPrint, 'show')