Пример #1
0
    def Vocabulary(self, content_instance=None):
        """
        Returns a DisplayList.
        """
        # if there's a TALES override, return it as a DisplayList,
        # otherwise, build the DisplayList from fgVocabulary

        fieldContainer = content_instance.findFieldObjectByName(self.__name__)

        try:
            vl = fieldContainer.getFgTVocabulary()
        except AttributeError:
            vl = None
        if vl is not None:
            return DisplayList(data=vl)

        res = DisplayList()
        for line in fieldContainer.fgVocabulary:
            lsplit = line.split('|')
            if len(lsplit) == 2:
                key, val = lsplit
            else:
                key, val = (lsplit[0], lsplit[0])
            res.add(key, val)
        return res
Пример #2
0
 def getStatusCabeca(self):
     """ Retorna a lista de status de Cabecas
     """
     list = DisplayList()
     list.add('Nao', 'Não Precisa')
     list.add('Solicitado', 'Solicitado')
     list.add('EmProducao', 'Em produção')
     list.add('Pronto', 'Pronto')
     return list
Пример #3
0
 def displaySFObjectTypes(self):
     logger.debug('Calling displaySFObjectTypes()')
     """ returns vocabulary for available Salesforce Object Types
         we can create.
     """
     types = self._querySFObjectTypes()
     typesDisplay = DisplayList()
     for type in types:
         typesDisplay.add(type, type)
     return typesDisplay
Пример #4
0
 def attachments(self):
     dl = DisplayList()
     catalog = getToolByName(self, 'portal_catalog')
     path = '/'.join(self.getPhysicalPath())
     brains = catalog(
         portal_type=('File', 'Image',),
         path=dict(query=path, depth=1))
     for brain in brains:
         dl.add(brain.UID, brain.Title)
     return dl
Пример #5
0
 def getAsDisplayList(self, instance, keyCol=0, valueCol=1, **kwargs):
     """Get two columns of each row as a DisplayList - the key columns is
     keyCol, and the value column is valueCol.
     """
     data = self.get(instance, **kwargs)
     lst = DisplayList()
     for d in data:
         cols = self._split(d)
         lst.add(cols[keyCol], cols[valueCol])
     return lst
 def attachments(self):
     dl = DisplayList()
     catalog = getToolByName(self, 'portal_catalog')
     path = '/'.join(self.getPhysicalPath())
     brains = catalog(
         portal_type=('File', 'Image',),
         path=dict(query=path, depth=1))
     for brain in brains:
         dl.add(brain.UID, brain.Title)
     return dl
 def displaySFObjectTypes(self):
     logger.debug('Calling displaySFObjectTypes()')
     """ returns vocabulary for available Salesforce Object Types
         we can create.
     """
     types = self._querySFObjectTypes()
     typesDisplay = DisplayList()
     for type in types:
         typesDisplay.add(type, type)
     return typesDisplay
    def getAvailableGetPaidForms(self):
        """
        We will provide a 'vocabulary' with the predefined form templates available
        It is not possible for the moment to do any kind of form without restriction
        """

        available_template_list = DisplayList()
        for field in self.available_templates.keys():
            available_template_list.add( field, field )
        return available_template_list
Пример #9
0
 def getAsDisplayList(self, instance, keyCol=0, valueCol=1, **kwargs):
     """Get two columns of each row as a DisplayList - the key columns is
     keyCol, and the value column is valueCol.
     """
     data = self.get(instance, **kwargs)
     lst = DisplayList()
     for d in data:
         cols = self._split(d)
         lst.add(cols[keyCol], cols[valueCol])
     return lst
Пример #10
0
 def getListaApresentadores(self):
     """ Retorna a lista de usuários do grupo reporteres
     """
     pg = getToolByName(self, 'portal_groups')
     group = pg.getGroupById('Apresentadores')
     members = group.getGroupMembers()
     list = DisplayList()
     for member in members:
         memberId = member.getMemberId()
         fullname = member.getProperty('fullname', memberId)
         list.add(memberId, fullname)
     return list
Пример #11
0
 def getListaInfografistas(self):
     """ Retorna a lista de membros presentes no grupo
     """
     pg = getToolByName(self, 'portal_groups')
     group = pg.getGroupById('infografistas')
     members = group.getGroupMembers()
     list = DisplayList()
     for member in members:
         memberId = member.getMemberId()
         fullname = member.getProperty('fullname', memberId)
         list.add(memberId, fullname)
     return list
Пример #12
0
 def getListaInfografistas(self):
     """ Retorna a lista de membros presentes no grupo
     """
     pg = getToolByName(self, 'portal_groups')
     group = pg.getGroupById('infografistas')
     members = group.getGroupMembers()
     list = DisplayList()
     for member in members:
         memberId = member.getMemberId()
         fullname = member.getProperty('fullname', memberId)
         list.add(memberId, fullname)
     return list
Пример #13
0
    def fTodosIdiomasVocabulary(self, ):

        unDisplayList = DisplayList()

        unosCodigosYDisplayNames = self.fTodosIdiomasCodesAndDisplayNames()
        if not unosCodigosYDisplayNames:
            return unDisplayList

        for unCodigoIdioma, unDisplayName in unosCodigosYDisplayNames:
            unDisplayList.add(
                unCodigoIdioma,
                unDisplayName,
            )
        return unDisplayList
Пример #14
0
    def __call__(self, **kwargs):
        site = getSite()
        request = aq_get(site, 'REQUEST', None)
        catalog = getToolByName(site, self.catalog)
        allow_blank = False
        if 'allow_blank' in kwargs:
            allow_blank = kwargs.get('allow_blank')
            del (kwargs['allow_blank'])

        self.contentFilter.update(**kwargs)

        # If a secondary deactivation/cancellation workflow is anbled,
        # Be sure and select only active objects, unless other instructions
        # are explicitly specified:
        if "is_active" not in self.contentFilter:
            self.contentFilter["is_active"] = True

        brains = catalog(self.contentFilter)

        items = [('', '')] if allow_blank else []
        for brain in brains:
            if self.key in brain and self.value in brain:
                key = getattr(brain, self.key)
                value = getattr(brain, self.value)
            else:
                obj = brain.getObjec()
                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)
Пример #15
0
 def getSampleTypesVoc(self):
     """
     Returns a DisplayList object with sample types.
     """
     types = self.context.bika_setup.bika_sampletypes.listFolderContents()
     return DisplayList([(element.UID(), element.Title())
                         for element in types])
Пример #16
0
def get_display_list(brains_or_objects=None, none_item=False):
    """
    Returns a DisplayList with the items sorted by Title
    :param brains_or_objects: list of brains or objects
    :param none_item: adds an item with empty uid and text "Select.." in pos 0
    :return: DisplayList (uid, title) sorted by title ascending
    :rtype: DisplayList
    """
    if brains_or_objects is None:
        return get_display_list(list(), none_item)

    items = list()
    for brain in brains_or_objects:
        uid = api.get_uid(brain)
        if not uid:
            continue
        title = api.get_title(brain)
        items.append((uid, title))

    # Sort items by title ascending
    items.sort(lambda x, y: cmp(x[1], y[1]))

    # Add the first item?
    if none_item:
        items.insert(0, ('', t('Select...')))

    return DisplayList(items)
Пример #17
0
 def getInstruments(self):
     bsc = getToolByName(self, 'bika_setup_catalog')
     items = [('', '...Choose an Instrument...')
              ] + [(o.UID, o.Title)
                   for o in bsc(portal_type='Instrument', is_active=True)]
     items.sort(lambda x, y: cmp(x[1].lower(), y[1].lower()))
     return DisplayList(list(items))
Пример #18
0
    def getInstruments(self):
        """Get the allowed instruments
        """
        query = {"portal_type": "Instrument", "inactive_state": "active"}

        if self.getRestrictToMethod():
            query.update({
                "getMethodUIDs": {
                    "query": api.get_uid(self.getRestrictToMethod()),
                    "operator": "or",
                }
            })

        instruments = api.search(query, "bika_setup_catalog")
        items = map(lambda i: (i.UID, i.Title), instruments)

        instrument = self.getInstrument()
        if instrument:
            instrument_uids = map(api.get_uid, instruments)
            if api.get_uid(instrument) not in instrument_uids:
                items.append(
                    (api.get_uid(instrument), api.get_title(instrument)))

        items.sort(lambda x, y: cmp(x[1], y[1]))
        items.insert(0, ("", _("No instrument")))

        return DisplayList(list(items))
Пример #19
0
 def getShowInRepVoc(self):
     """
     Return the different Visibility in Report values.
     """
     return DisplayList([('default', _('Visibility (default)')),
                         ('visible', _('Show in Report')),
                         ('invisible', _('Hide In Report'))])
Пример #20
0
    def Vocabulary(self, content_instance=None):
        #If we have a method providing the list of types go with it,
        #it can always pull allowed_types if it needs to (not that we
        #pass the field name)
        value = ObjectField.Vocabulary(self, content_instance)
        if value:
            return value

        results = []
        catalog = getToolByName(content_instance, 'portal_catalog')
        try:
            ws_path = content_instance.workspacePath()
        except AttributeError:
            ws_path = "/"

        if self.allowed_types:  # we trust that all allowed_types are properly referencable and cataloged
            results = catalog(Type=self.allowed_types, path=ws_path)
        else:
            keys = catalog.uniqueValuesFor('UID')
            results = catalog(UID=keys, path=ws_path)  #... but this should never happen

        results = [(r, r.getObject()) for r in results]
        value = [(r.UID, obj and (str(obj.Title().strip()) or \
                                  str(obj.getId()).strip())  or \
                  log('Field %r: Object at %r could not be found' % \
                      (self.getName(), r.getURL())) or \
                  r.Title or r.UID) for r, obj in results]
        if not self.required:
            value.insert(0, ('', '<no reference>'))
        return DisplayList(value)
Пример #21
0
    def buildSFFieldOptionList(self):
        """Returns a DisplayList of all the fields
           for the currently selected Salesforce object
           type.
        """
        sfFields = self._querySFFieldsForType()

        fieldList = []
        for k, v in sfFields.items():
            # determine whether each field is required and mark appropriately

            if v.updateable or v.createable:
                if v.nillable or v.defaultedOnCreate or not v.createable:
                    fieldList.append((k, k))
                else:
                    fieldList.append((k, str("%s %s" % (k, REQUIRED_MARKER))))
        # We provide our own custom sort mechanism
        # rather than relying on DisplayList's because we
        # want all required fields to appear first in the
        # selection menu.
        fieldList.sort(self._requiredFieldSorter)
        fieldList.insert(0, ('', ''))
        dl = DisplayList(fieldList)

        return dl
Пример #22
0
 def vocabulary_documentStatus(self):
     """ return a list of tuple (status, status desc) for the
     document status select.
     """
     return DisplayList([('open', 'Open'),
                         ('close', 'Close'),
                         ]
                        )
Пример #23
0
 def getMethodsDisplayList(self):
     """Returns a display list with the active methods
     """
     query = dict(portal_type="Method", inactive_state="active")
     items = api.search(query, "bika_setup_catalog")
     items = map(lambda brain: (brain.UID, brain.Title), items)
     items.sort(lambda x, y: cmp(x[1], y[1]))
     return DisplayList(list(items))
Пример #24
0
 def getInstruments(self):
     bsc = getToolByName(self, 'bika_setup_catalog')
     brains = bsc(portal_type='Instrument', is_active=True)
     items = [('', '...Choose an Instrument...')]
     for item in brains:
         items.append((item.UID, item.Title))
     items.sort(lambda x, y: cmp(x[1].lower(), y[1].lower()))
     return DisplayList(list(items))
Пример #25
0
 def Preservations(self, instance=None):
     instance = instance or self
     bsc = getToolByName(instance, 'bika_setup_catalog')
     items = [[c.UID, c.title] for c in bsc(portal_type='Preservation',
                                            is_active=True,
                                            sort_on='sortable_title')]
     items = [['', _('Any')]] + list(items)
     return DisplayList(items)
Пример #26
0
 def getAvailableStudents2(self):
     """return all registered users of the tutor-web"""
     pm = self.portal_membership
     results = pm.listMembers()
     pair = []
     for r in results:
         pair.append((r.UID, r.Title))
     return DisplayList(pair)
Пример #27
0
    def vocabulary_releases(self):
        """ Return all available releases for this story.
        """
        releases = []
        for release in self.getProjectReleases():
            releases.append((release.id, release.title))

        return DisplayList(releases)
Пример #28
0
 def getSampleConditionsVoc(self):
     """
     Returns a DisplayList object with sample condtions.
     """
     cons = self.context.bika_setup.\
         bika_sampleconditions.listFolderContents()
     return DisplayList([(element.UID(), element.Title())
                         for element in cons])
 def moduleVersions(self):
     """A DisplayList of module versions"""
     retval = []
     try:
         retval = [(elt.version,elt.version) for elt in self.content.getHistory(self.getModuleId())]
     except:
         pass
     return DisplayList(retval)
Пример #30
0
 def getAnalysesNamesVoc(self):
     """
     Returns a DisplayList object with analyses names.
     """
     ans = self.context.bika_setup.\
         bika_analysisservices.listFolderContents()
     return DisplayList([(element.UID(), element.Title())
                         for element in ans])
Пример #31
0
    def __init__(self, context, request, data=None):
        super(Widget, self).__init__(context, request, data)

        voc = getUtility(IVocabularyFactory,
                         'eea.faceted.vocabularies.CurrentUser')
        voc = [(term.value, term.title or term.value) for term in voc(context)
               if term.value]
        self.edit_schema['user'].vocabulary = DisplayList(voc)
Пример #32
0
 def getActionVoc(self):
     """
     Return the different action available
     """
     return DisplayList([('repeat', _('Repeat')),
                         ('duplicate', _('Duplicate')),
                         ('setresult', _('Set result')),
                         ('setvisibility', _('Set Visibility'))])
Пример #33
0
 def getWorksheetOptionsVoc(self):
     """
     Return the the available options to carry on realted with a worksheet
     """
     return DisplayList([('current', "To the current worksheet"),
                         ('to_another', "To another worksheet"),
                         ('create_another', "Create another worksheet"),
                         ('no_ws', "No worksheet")])
Пример #34
0
 def _getAvailableMethodsDisplayList(self):
     """ Returns a DisplayList with the available Methods
         registered in Bika-Setup. Only active Methods are fetched.
     """
     bsc = getToolByName(self, 'bika_setup_catalog')
     items = [(i.UID, i.Title)
              for i in bsc(portal_type='Method', inactive_state='active')]
     items.sort(lambda x, y: cmp(x[1], y[1]))
     return DisplayList(list(items))
Пример #35
0
 def getContainers(self, instance=None):
     # On first render, the containers must be filtered
     instance = instance or self
     separate = self.getSeparate()
     containers = getContainers(instance,
                                allow_blank=True,
                                show_container_types=not separate,
                                show_containers=separate)
     return DisplayList(containers)
Пример #36
0
 def getWorksheetTemplates(self):
     """ List of templates
         Used in bika_listing.pt
     """
     bsc = getToolByName(self.context, 'bika_setup_catalog')
     return DisplayList([(c.UID, c.Title)
                         for c in bsc(portal_type='WorksheetTemplate',
                                      inactive_state='active',
                                      sort_on='sortable_title')])
Пример #37
0
 def getStatusCabeca(self):
     """ Retorna a lista de status de Cabecas
     """
     list = DisplayList()
     list.add('Nao','Não Precisa')
     list.add('Solicitado', 'Solicitado')
     list.add('EmProducao','Em produção')
     list.add('Pronto', 'Pronto')
     return list
Пример #38
0
 def getSourceTypeVocabulary(self):
     """All supported repository types """
     d = DisplayList()
     for t in self.source_types:
         d.add(t,t)
     return d
Пример #39
0
    def getAttachmentSizes(self):
        voc = DisplayList()
        voc.add('10', '10 kilobyte')
        voc.add('100', '100 kilobyte')
        voc.add('1000', '1 megabyte')
        voc.add('10000', '10 megabyte')
        voc.add('-1', 'unlimited')

        return voc