Beispiel #1
0
 def getSearches(self, contentType):
     '''Returns the list of searches that are defined for p_contentType.
        Every list item is a dict that contains info about a search or about
        a group of searches.'''
     appyClass = self.getAppyClass(contentType)
     res = []
     visitedGroups = {} # Names of already visited search groups
     for search in ClassDescriptor.getSearches(appyClass):
         # Determine first group label, we will need it.
         groupLabel = ''
         if search.group:
             groupLabel = '%s_searchgroup_%s' % (contentType, search.group)
         # Add an item representing the search group if relevant
         if search.group and (search.group not in visitedGroups):
             group = {'name': search.group, 'isGroup': True,
                      'labelId': groupLabel, 'searches': [],
                      'label': self.translate(groupLabel),
                      'descr': self.translate('%s_descr' % groupLabel),
             }
             res.append(group)
             visitedGroups[search.group] = group
         # Add the search itself
         searchLabel = '%s_search_%s' % (contentType, search.name)
         dSearch = {'name': search.name, 'isGroup': False,
                    'label': self.translate(searchLabel),
                    'descr': self.translate('%s_descr' % searchLabel)}
         if search.group:
             visitedGroups[search.group]['searches'].append(dSearch)
         else:
             res.append(dSearch)
     return res
Beispiel #2
0
 def getSearches(self, contentType):
     '''Returns the list of searches that are defined for p_contentType.
        Every list item is a dict that contains info about a search or about
        a group of searches.'''
     appyClass = self.getAppyClass(contentType)
     res = []
     visitedGroups = {}  # Names of already visited search groups
     for search in ClassDescriptor.getSearches(appyClass):
         # Determine first group label, we will need it.
         groupLabel = ''
         if search.group:
             groupLabel = '%s_searchgroup_%s' % (contentType, search.group)
         # Add an item representing the search group if relevant
         if search.group and (search.group not in visitedGroups):
             group = {
                 'name': search.group,
                 'isGroup': True,
                 'labelId': groupLabel,
                 'searches': [],
                 'label': self.translate(groupLabel),
                 'descr': self.translate('%s_descr' % groupLabel),
             }
             res.append(group)
             visitedGroups[search.group] = group
         # Add the search itself
         searchLabel = '%s_search_%s' % (contentType, search.name)
         dSearch = {
             'name': search.name,
             'isGroup': False,
             'label': self.translate(searchLabel),
             'descr': self.translate('%s_descr' % searchLabel)
         }
         if search.group:
             visitedGroups[search.group]['searches'].append(dSearch)
         else:
             res.append(dSearch)
     return res