def __init__(self, context, request): super(DocumentsTab, self).__init__(context, request) # default implementation if has_ftwfile(self.context): # ftw.file implementation self.sort_on = 'documentDate' else: self.sort_on = 'effective'
def get_items(self): """Returns all items to be displayed. """ ftwfile = has_ftwfile(self.context) for brain in self._brains(): yield {'title': self.convert(brain.Title), 'effective': helper.readable_date( brain, getattr( brain, ftwfile and 'documentDate' or 'effective')), 'modified': helper.readable_date( brain, getattr(brain, 'modified')), 'creator': self.get_creator(brain), }
def columns(self): # default implementation date_column = {'column': 'effective', 'column_title': _(u'column_date', default=u'date'), 'transform': helper.readable_date_text, 'width': 100} # ftw.file implementation if has_ftwfile(self.context): date_column['column'] = 'documentDate' date_column['column_title'] = fileMF(u'label_document_date', default=u'Document date') columns = ( {'column': '', 'column_title': '', 'transform': helper.path_checkbox, 'sortable': False, 'width': 30}, {'column': 'getIcon', 'sort_index': 'getContentType', 'column_title': _(u'column_type', default=u'Type'), 'transform': workspace_helper.icon_or_sprite, 'width': 35}, {'column': 'Title', 'column_title': _(u'column_title', default=u'Title'), 'sort_index': 'sortable_title', 'transform': helper.link(icon=False, tooltip=True)}, ) + (date_column,) + ( # Add variable date column {'column': 'Creator', 'column_title': _(u'column_creator', default=u'Creator'), 'sort_index': 'sortable_creator', 'transform': helper.readable_author}, {'column': 'modified', 'column_title': _(u'column_modified', default=u'modified'), 'transform': helper.readable_date_text, 'width': 80}, ) return columns