Esempio n. 1
0
 def __call__(self, context):
     site = getSite()
     request = aq_get(site, 'REQUEST', None)
     items = []
     for client in site.clients.objectValues('Client'):
         objects = list(client.objectValues('Contact'))
         objects.sort(lambda x, y: cmp(x.getFullname().lower(),
                                       y.getFullname().lower()))
         xitems = [(to_utf8(item.getFullname()), item.getFullname())
                   for item in objects]
         xitems = [SimpleTerm(i[1], i[1], i[0]) for i in xitems]
         items += xitems
     return SimpleVocabulary(items)
Esempio n. 2
0
 def __call__(self, context):
     site = getSite()
     request = aq_get(site, 'REQUEST', None)
     items = []
     for client in site.clients.objectValues('Client'):
         objects = list(client.objectValues('Contact'))
         objects.sort(lambda x, y: cmp(x.getFullname().lower(),
                                       y.getFullname().lower()))
         xitems = [(to_utf8(item.getFullname()), item.getFullname())
                   for item in objects]
         xitems = [SimpleTerm(i[1], i[1], i[0]) for i in xitems]
         items += xitems
     return SimpleVocabulary(items)
Esempio n. 3
0
    def __call__(self, context):
        portal = getSite()
        wftool = getToolByName(portal, 'portal_workflow', None)
        if wftool is None:
            return SimpleVocabulary([])

        # XXX This is evil. A vocabulary shouldn't be request specific.
        # The sorting should go into a separate widget.

        # we get REQUEST from wftool because context may be an adapter
        request = aq_get(wftool, 'REQUEST', None)

        wf = wftool.getWorkflowById('bika_ar_workflow')
        items = wftool.listWFStatesByTitle(filter_similar=True)
        items_dict = dict([(i[1], t(i[0])) for i in items])
        items_list = [(k, v) for k, v in items_dict.items()]
        items_list.sort(lambda x, y: cmp(x[1], y[1]))
        terms = [SimpleTerm(k, title=u'%s' % v) for k, v in items_list]
        return SimpleVocabulary(terms)
Esempio n. 4
0
 def __call__(self, context):
     site = getSite()
     request = aq_get(site, 'REQUEST', None)
     items = []
     wf = site.portal_workflow
     for folder in self.folders:
         folder = site.restrictedTraverse(folder)
         for portal_type in self.portal_types:
             objects = list(folder.objectValues(portal_type))
             objects = [o for o in objects if
                        wf.getInfoFor(o, 'inactive_state') == 'active']
             if not objects:
                 continue
             objects.sort(lambda x, y: cmp(x.Title().lower(),
                                           y.Title().lower()))
             xitems = [(t(item.Title()), item.Title()) for item in objects]
             xitems = [SimpleTerm(i[1], i[1], i[0]) for i in xitems]
             items += xitems
     return SimpleVocabulary(items)
Esempio n. 5
0
    def __call__(self, context):
        portal = getSite()
        wftool = getToolByName(portal, 'portal_workflow', None)
        if wftool is None:
            return SimpleVocabulary([])

        # XXX This is evil. A vocabulary shouldn't be request specific.
        # The sorting should go into a separate widget.

        # we get REQUEST from wftool because context may be an adapter
        request = aq_get(wftool, 'REQUEST', None)

        wf = wftool.getWorkflowById('bika_ar_workflow')
        items = wftool.listWFStatesByTitle(filter_similar=True)
        items_dict = dict([(i[1], t(i[0])) for i in items])
        items_list = [(k, v) for k, v in items_dict.items()]
        items_list.sort(lambda x, y: cmp(x[1], y[1]))
        terms = [SimpleTerm(k, title=u'%s' % v) for k, v in items_list]
        return SimpleVocabulary(terms)
Esempio n. 6
0
    def __call__(self, **kwargs):
        site = getSite()
        request = aq_get(site, 'REQUEST', None)
        catalog = getToolByName(site, self.catalog)
        if 'inactive_state' in catalog.indexes():
            self.contentFilter['inactive_state'] = 'active'
        if 'cancellation_state' in catalog.indexes():
            self.contentFilter['cancellation_state'] = 'active'
        self.contentFilter.update(**kwargs)
        objects = (b.getObject() for b in catalog(self.contentFilter))

        items = []
        for obj in objects:
            key = obj[self.key]
            key = callable(key) and key() or key
            value = obj[self.value]
            value = callable(value) and value() or value
            items.append((key, t(value)))

        return DisplayList(items)
Esempio n. 7
0
    def __call__(self, **kwargs):
        site = getSite()
        request = aq_get(site, 'REQUEST', None)
        catalog = getToolByName(site, self.catalog)
        if 'inactive_state' in catalog.indexes():
            self.contentFilter['inactive_state'] = 'active'
        if 'cancellation_state' in catalog.indexes():
            self.contentFilter['cancellation_state'] = 'active'
        self.contentFilter.update(**kwargs)
        objects = (b.getObject() for b in catalog(self.contentFilter))

        items = []
        for obj in objects:
            key = obj[self.key]
            key = callable(key) and key() or key
            value = obj[self.value]
            value = callable(value) and value() or value
            items.append((key, t(value)))

        return DisplayList(items)
Esempio n. 8
0
 def __call__(self, context):
     site = getSite()
     request = aq_get(site, 'REQUEST', None)
     items = []
     wf = site.portal_workflow
     for folder in self.folders:
         folder = site.restrictedTraverse(folder)
         for portal_type in self.portal_types:
             objects = list(folder.objectValues(portal_type))
             objects = [
                 o for o in objects
                 if wf.getInfoFor(o, 'inactive_state') == 'active'
             ]
             if not objects:
                 continue
             objects.sort(lambda x, y: cmp(x.Title().lower(),
                                           y.Title().lower()))
             xitems = [(t(item.Title()), item.Title()) for item in objects]
             xitems = [SimpleTerm(i[1], i[1], i[0]) for i in xitems]
             items += xitems
     return SimpleVocabulary(items)