add a custom results table for contacts
This commit is contained in:
parent
1426882945
commit
15a6a1f0be
|
@ -172,6 +172,24 @@ class ResultsTasksTable(TasksTable):
|
|||
return self.request.get('table-extra-columns', '')
|
||||
|
||||
|
||||
class ContactsTasksTable(ResultsTable):
|
||||
|
||||
def updateBatch(self):
|
||||
self.batchProvider = ResultsBatchProvider(self.context, self.request, self)
|
||||
self.batchProvider.update()
|
||||
|
||||
def setUpColumns(self):
|
||||
columns = super(ResultsTable, self).setUpColumns()
|
||||
extra_column_names = self.request.get('table-extra-columns', '').split(':')
|
||||
columns = [x for x in columns if not x.__name__.startswith('extra.') or
|
||||
x.__name__ in extra_column_names]
|
||||
blacklist = ['dms.state', 'dms.author', 'pfwbged.folder.unfile']
|
||||
columns = [x for x in columns if not x.__name__ in blacklist]
|
||||
return columns
|
||||
|
||||
def getExtraColumns(self):
|
||||
return self.request.get('table-extra-columns', '')
|
||||
|
||||
|
||||
class ResultsInformationsTable(InformationsTable):
|
||||
|
||||
|
@ -248,6 +266,19 @@ class TaskTypeColumn(column.Column):
|
|||
return term.title
|
||||
|
||||
|
||||
class PositionColumn(column.Column):
|
||||
grok.name('contacts.position')
|
||||
grok.adapts(Interface, Interface, ContactsTasksTable)
|
||||
header = PMF(u"Position")
|
||||
weight = 20
|
||||
|
||||
def renderCell(self, item):
|
||||
try:
|
||||
return u', '.join(item.getObject().get_held_positions_titles())
|
||||
except AttributeError:
|
||||
return '-'
|
||||
|
||||
|
||||
class UnfileColumn(column.IconColumn, column.LinkColumn):
|
||||
grok.name('pfwbged.folder.unfile')
|
||||
grok.adapts(Interface, Interface, ResultsTable)
|
||||
|
@ -279,6 +310,9 @@ def get_appropriate_table_class(context, query):
|
|||
if portal_types is not None and not (set(portal_types) - set(['information'])):
|
||||
# nothing but "tasks", use a more appropriate table
|
||||
table_class = ResultsInformationsTable
|
||||
if portal_types is not None and not (set(portal_types) - set(['person', 'organization'])):
|
||||
# nothing but "contacts", use a more appropriate table
|
||||
table_class = ContactsTasksTable
|
||||
return table_class
|
||||
|
||||
BATCH_SIZE = 10
|
||||
|
|
Reference in New Issue