コード例 #1
0
def AreasVocabulary(context):
    """Return the available areas inside an Ombuds Office. This vocabulary is
    context sensitive and must be called from a Claim.
    """
    context = aq_inner(context)
    if IOmbudsOffice.providedBy(context):
        # we should be adding a claim
        parent = context
    elif IClaim.providedBy(context):
        # we are viewing a Claim
        parent = aq_parent(context)
        assert IOmbudsOffice.providedBy(parent)
    else:
        return EMPTY

    items = []
    for i in parent.areas:
        title = i['area']
        value = queryUtility(IIDNormalizer).normalize(title)
        items.append(SimpleTerm(value=value, title=title))
    return SimpleVocabulary(items)
 def test_factory(self):
     fti = queryUtility(IDexterityFTI, name='OmbudsOffice')
     factory = fti.factory
     new_object = createObject(factory)
     self.assertTrue(IOmbudsOffice.providedBy(new_object))
 def test_adding(self):
     self.assertTrue(IOmbudsOffice.providedBy(self.office))
 def test_factory(self):
     fti = queryUtility(IDexterityFTI, name='OmbudsOffice')
     factory = fti.factory
     new_object = createObject(factory)
     self.assertTrue(IOmbudsOffice.providedBy(new_object))
 def test_adding(self):
     self.assertTrue(IOmbudsOffice.providedBy(self.office))