def __call__(self, context): site = getSite() mtool = getToolByName(site, 'portal_membership') users = mtool.searchForMembers(roles=self.roles) items = [(item.getProperty('fullname'), item.getId()) for item in users] items.sort(lambda x, y: cmp(x[0].lower(), y[0].lower())) items = [SimpleTerm(i[1], i[1], i[0]) for i in items] return SimpleVocabulary(items)
def __call__(self, context): translate = context.translate types = (('AnalysisRequest', translate(to_utf8(_('Analysis Request')))), ('Batch', translate(to_utf8(_('Batch')))), ('Sample', translate(to_utf8(_('Sample')))), ('ReferenceSample', translate(to_utf8(_('Reference Sample')))), ('Worksheet', translate(to_utf8(_('Worksheet'))))) items = [SimpleTerm(i[0], i[0], i[1]) for i in types] return SimpleVocabulary(items)
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)
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)
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)
def __call__(self, context): out = [ SimpleTerm(x['id'], x['id'], x['title']) for x in getStickerTemplates() ] return SimpleVocabulary(out)