Did I find the right examples for you? yes no

All Samples(2)  |  Call(0)  |  Derive(0)  |  Import(2)

src/c/o/collective.contact.plonegroup-0.2/src/collective/contact/plonegroup/browser/settings.py   collective.contact.plonegroup(Download)
from Products.statusmessages.interfaces import IStatusMessage
from .. import _
from ..config import ORGANIZATIONS_REGISTRY, FUNCTIONS_REGISTRY, PLONEGROUP_ORG
 
 
    def __call__(self, context):
        portal = getSite()
        terms = []
        pcat = portal.portal_catalog
        brains = pcat(portal_type='organization', id=PLONEGROUP_ORG)
        if not brains:
            terms.append(SimpleTerm(None, token="unfound",
                                    title=_(u"You must define an organization with id '${pgo}' !",
                                            mapping={'pgo': PLONEGROUP_ORG})))
            terms.append(SimpleTerm(None, token="multifound", title=_(u"You must have only one organization "
                                                                      "with id '${pgo}' !",
                                                                      mapping={'pgo': PLONEGROUP_ORG})))
            return SimpleVocabulary(terms)
 
    portal = getSite()
    pcat = portal.portal_catalog
    brains = pcat(portal_type='organization', id=PLONEGROUP_ORG)
    if brains:
        return '/'.join(brains[0].getObject().getPhysicalPath())

src/c/o/collective.contact.plonegroup-0.2/src/collective/contact/plonegroup/tests/test_settings.py   collective.contact.plonegroup(Download)
from plone.registry.interfaces import IRegistry
from collective.contact.plonegroup.testing import IntegrationTestCase
from ..config import ORGANIZATIONS_REGISTRY, FUNCTIONS_REGISTRY, PLONEGROUP_ORG
from collective.contact.plonegroup.browser import settings
 
        # Organizations creation
        self.portal.invokeFactory('directory', 'contacts')
        self.portal['contacts'].invokeFactory('organization', PLONEGROUP_ORG, title='My organization')
        own_orga = self.portal['contacts'][PLONEGROUP_ORG]
        own_orga.invokeFactory('organization', 'department1', title='Department 1')
        # When multiple own organizations
        self.portal['contacts'].invokeFactory('organization', 'temporary', title='Temporary')
        self.portal['contacts']['temporary'].invokeFactory('organization', PLONEGROUP_ORG,
                                                           title='Duplicated organization')
        services = getUtility(IVocabularyFactory, name=u'collective.contact.plonegroup.organization_services')
        voc_dic = services(self).by_token
        voc_list = [voc_dic[key].title for key in voc_dic.keys()]
        self.assertEquals(voc_list, [u"You must have only one organization with id '${pgo}' !"])
        # When own organization not found
        self.portal['contacts'].manage_delObjects(ids=[PLONEGROUP_ORG])