예제 #1
0
 def _contents(self, types=None):
     """
     Returns a lazy sequence of catalog brain objects for contained
     items, filtered by one or more portal_type, sorted newest first.
     """
     if types is None:
         q = local_query(self.context, {})
     else:
         if isinstance(types, basestring):
             types = (str(types),)  # wrap in tuple
         q = self.sorted_query({}, types=types)
     return self.catalog.unrestrictedSearchResults(q)
예제 #2
0
 def _contents(self, types=None):
     """
     Returns a lazy sequence of catalog brain objects for contained
     items, filtered by one or more portal_type, sorted newest first.
     """
     if types is None:
         q = local_query(self.context, {})
     else:
         if isinstance(types, basestring):
             types = (str(types), )  # wrap in tuple
         q = self.sorted_query({}, types=types)
     return self.catalog.unrestrictedSearchResults(q)
예제 #3
0
 def sorted_query(self, query, types=None):
     query = dict(query.items())  # copy
     query = local_query(self.context, query, types)
     query['sort_on'] = 'modified'
     query['sort_order'] = 'descending'
     return query
예제 #4
0
def project_reports(project, catalog):
    q = local_query(project, {}, types=(REPORT_TYPE, ), depth=10)
    brains = catalog.unrestrictedSearchResults(q)
    return brains
예제 #5
0
 def sorted_query(self, query, types=None):
     query = dict(query.items())  # copy
     query = local_query(self.context, query, types)
     query['sort_on'] = 'modified'
     query['sort_order'] = 'descending'
     return query
예제 #6
0
 def groups(self):
     """
     listing groups: returns tuple of dict containing label and result
     sequence of catalog brains from query; template should use these.
     """
     result = []
     queries = (
         (
             'Unsubmitted past forms',
             local_query(
                 self.context,
                 {
                     'review_state': 'visible',
                     'end': {
                         'query': DateTime(),  # specify now so...
                         'range': 'max',  # older than now
                     },
                     'sort_on': 'end',
                     'sort_order': 'ascending',
                 },
                 types=FORM_TYPES,
             )),
         (
             'Upcoming forms',
             local_query(
                 self.context,
                 {
                     'review_state': 'visible',
                     'end': {
                         'query': DateTime(),  # specify now and...
                         'range': 'min',  # form end date in future
                     },
                     'sort_on': 'start',
                     'sort_order': 'ascending',
                 },
                 types=FORM_TYPES,
             )),
         (
             'Submitted recently',
             local_query(
                 self.context,
                 {
                     'review_state': {
                         'query': ('submitted', 'archived'),
                         'operator': 'or',
                     },
                     'modified': {
                         'query': DateTime() - 60,  # last 60 days
                         'range': 'min',
                     },
                     'sort_on': 'modified',
                     'sort_order': 'descending',
                 },
                 types=FORM_TYPES,
             )),
     )
     for label, query in queries:
         result.append({
             'label': label,
             'result': self.search(label, query)
         })
     return tuple(result)
예제 #7
0
def project_reports(project, catalog):
    q = local_query(project, {}, types=(REPORT_TYPE,), depth=10)
    brains = catalog.unrestrictedSearchResults(q)
    return brains
예제 #8
0
 def groups(self):
     """
     listing groups: returns tuple of dict containing label and result
     sequence of catalog brains from query; template should use these.
     """
     result = []
     queries = (
         (
             'Unsubmitted past forms',
             local_query(
                 self.context,
                 {
                     'review_state': 'visible',
                     'end': {
                         'query': DateTime(),  # specify now so...
                         'range': 'max',       # older than now
                     },
                     'sort_on': 'end',
                     'sort_order': 'ascending',
                 },
                 types=FORM_TYPES,
                 )
             ),
         (
             'Upcoming forms',
             local_query(
                 self.context,
                 {
                     'review_state': 'visible',
                     'end': {
                         'query': DateTime(),  # specify now and...
                         'range': 'min',       # form end date in future
                     },
                     'sort_on': 'start',
                     'sort_order': 'ascending',
                 },
                 types=FORM_TYPES,
                 )
             ),
         (
             'Submitted recently',
             local_query(
                 self.context,
                 {
                     'review_state': {
                         'query': ('submitted', 'archived'),
                         'operator': 'or',
                     },
                     'modified': {
                         'query': DateTime() - 60,  # last 60 days
                         'range': 'min',
                     },
                     'sort_on': 'modified',
                     'sort_order': 'descending',
                 },
                 types=FORM_TYPES,
                 )
             ),
     )
     for label, query in queries:
         result.append({'label': label,
                        'result': self.search(label, query)})
     return tuple(result)