From 109e3fa0181561b5619a8aae83be14b28652bf51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Mon, 19 Dec 2011 11:28:38 +0100 Subject: [PATCH] add column to mail search results --- themis/search/indexer.py | 34 ++++++++++++++++++---- themis/search/mail.pt | 22 ++++++++++++-- themis/search/mail.py | 5 ++++ themis/search/profiles/default/catalog.xml | 12 ++++---- 4 files changed, 60 insertions(+), 13 deletions(-) diff --git a/themis/search/indexer.py b/themis/search/indexer.py index 010121c..dfc33c0 100644 --- a/themis/search/indexer.py +++ b/themis/search/indexer.py @@ -47,6 +47,21 @@ def docMeetingDateIndexer(obj): grok.global_adapter(docMeetingDateIndexer, name="docMeetingDate") +@indexer(plone.dexterity.interfaces.IDexterityItem) +def mailCategoryTxtIndexer(obj): + if obj.portal_type not in ('courrier_entrant', 'courrier_sortant'): + return None + for attr in ('categorie_de_courrier',): + if not hasattr(obj, attr): + continue + if getattr(obj, attr): + return getattr(obj, attr)[0] + return None + +grok.global_adapter(mailCategoryTxtIndexer, name="mailCategoryTxt") + + + def get_data_to_index(obj, data): # if there is no path to text/plain, do nothing transforms = getToolByName(obj, 'portal_transforms') @@ -86,7 +101,7 @@ def mail_dynamic_searchable_text_indexer(obj): return obj.title + ' ' + get_data_to_index(obj, data) -grok.global_adapter(mail_dynamic_searchable_text_indexer, name='MailSearchableText') +grok.global_adapter(mail_dynamic_searchable_text_indexer, name='mailSearchableText') @indexer(plone.dexterity.interfaces.IDexterityItem) @@ -108,7 +123,7 @@ def doc_dynamic_searchable_text_indexer(obj): return obj.title + ' ' + get_data_to_index(obj, data) -grok.global_adapter(doc_dynamic_searchable_text_indexer, name='DocSearchableText') +grok.global_adapter(doc_dynamic_searchable_text_indexer, name='docSearchableText') @indexer(plone.dexterity.interfaces.IDexterityItem) @@ -123,10 +138,17 @@ def contactIndexer(obj): if not v: continue v = v[0] - return v + if ':' in v: + src = ContactsSource() + r = src.fastGetTitleByToken(obj, v) + if not type(r) is unicode: + r = unicode(r, 'utf-8') + return r + else: + return v return None -grok.global_adapter(contactIndexer, name="MailContact") +grok.global_adapter(contactIndexer, name="mailContact") @indexer(plone.dexterity.interfaces.IDexterityItem) def contactFuzzyIndexer(obj): @@ -149,7 +171,7 @@ def contactFuzzyIndexer(obj): return v return None -grok.global_adapter(contactFuzzyIndexer, name="MailContactFuzzy") +grok.global_adapter(contactFuzzyIndexer, name="mailContactFuzzy") @indexer(plone.dexterity.interfaces.IDexterityItem) @@ -236,4 +258,4 @@ def personsFuzzyIndexer(obj): persons.append(item) return ' '.join(persons) -grok.global_adapter(personsFuzzyIndexer, name='DocPersonsFuzzy') +grok.global_adapter(personsFuzzyIndexer, name='docPersonsFuzzy') diff --git a/themis/search/mail.pt b/themis/search/mail.pt index 61e655d..9be2e9b 100644 --- a/themis/search/mail.pt +++ b/themis/search/mail.pt @@ -17,6 +17,7 @@ b_start python:0;b_start request/b_start | b_start; results view/search_results; batch python:Batch(list(results), b_size, int(b_start), orphan=1); + states view/review_states; ">

Recherche de courriers

@@ -35,8 +36,12 @@ + - + + + +
@@ -50,11 +55,24 @@ background: #eee; } +.results table tr td { + padding-right: 1em; +} + +td.type { + text-align: left; + width: 8em; +} + td.date { text-align: right; width: 7em; - padding-right: 1em; } + +td.category { + width: 15em; +} +
diff --git a/themis/search/mail.py b/themis/search/mail.py index 24a3ac4..17e9109 100644 --- a/themis/search/mail.py +++ b/themis/search/mail.py @@ -136,3 +136,8 @@ class SearchView(BrowserView): d[key] = d[key].encode('utf-8') return d + def review_states(self): + d = {} + for label, id in self.context.portal_workflow.listWFStatesByTitle(): + d[id] = label + return d diff --git a/themis/search/profiles/default/catalog.xml b/themis/search/profiles/default/catalog.xml index 6f2ae68..0019971 100644 --- a/themis/search/profiles/default/catalog.xml +++ b/themis/search/profiles/default/catalog.xml @@ -18,20 +18,20 @@ - + - + - + - + @@ -51,7 +51,7 @@ - + @@ -61,6 +61,8 @@ + +