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)
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)
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
def project_reports(project, catalog): q = local_query(project, {}, types=(REPORT_TYPE, ), depth=10) brains = catalog.unrestrictedSearchResults(q) return brains
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)
def project_reports(project, catalog): q = local_query(project, {}, types=(REPORT_TYPE,), depth=10) brains = catalog.unrestrictedSearchResults(q) return brains
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)