Total Complexity | 1 |
Total Lines | 31 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | # -*- coding: utf-8 -*- |
||
2 | |||
3 | from bika.lims import api |
||
4 | from bika.lims.interfaces import IClient |
||
5 | from plone.indexer import indexer |
||
6 | from senaite.core.interfaces.catalog import IClientCatalog |
||
7 | |||
8 | |||
9 | @indexer(IClient, IClientCatalog) |
||
10 | def client_searchable_text(instance): |
||
11 | """Extract search tokens for ZC text index |
||
12 | """ |
||
13 | |||
14 | tokens = [ |
||
15 | instance.getClientID(), |
||
16 | instance.getName(), |
||
17 | instance.getPhone(), |
||
18 | instance.getFax(), |
||
19 | instance.getEmailAddress(), |
||
20 | instance.getTaxNumber(), |
||
21 | ] |
||
22 | |||
23 | # extend address lines |
||
24 | tokens.extend(instance.getPrintAddress()) |
||
25 | |||
26 | # remove duplicates and filter out emtpies |
||
27 | tokens = filter(None, set(tokens)) |
||
28 | |||
29 | # return a single unicode string with all the concatenated tokens |
||
30 | return u" ".join(map(api.safe_unicode, tokens)) |
||
31 |