aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSix <unknown>2011-05-03 21:54:55 -0400
committerSix <unknown>2011-05-03 21:54:55 -0400
commitc175d4cfeae34a4da151de3a3f7aedbad6af7049 (patch)
tree986da2d998394c95845078bc0aea492055640d9e
parent9210fcab1d7267f172557a4589434095ef5211c0 (diff)
downloadd2-c175d4cfeae34a4da151de3a3f7aedbad6af7049.tar.bz2
d2-c175d4cfeae34a4da151de3a3f7aedbad6af7049.tar.xz
d2-c175d4cfeae34a4da151de3a3f7aedbad6af7049.zip
added a way to add spaces to peoples names when a person might have a multi part name which was joined in ldap
-rw-r--r--lib/d2/app/adapters/search.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/d2/app/adapters/search.py b/lib/d2/app/adapters/search.py
index e507bc1..92d0ee5 100644
--- a/lib/d2/app/adapters/search.py
+++ b/lib/d2/app/adapters/search.py
@@ -15,6 +15,7 @@ from whoosh.qparser import QueryParser
15from whoosh.spelling import SpellChecker 15from whoosh.spelling import SpellChecker
16import os 16import os
17import stat 17import stat
18import re
18 19
19class SearchAdapter(BaseAdapter): 20class SearchAdapter(BaseAdapter):
20 21
@@ -116,12 +117,20 @@ class SearchAdapter(BaseAdapter):
116 data.append(self._details_to_search_dictionary(details)) 117 data.append(self._details_to_search_dictionary(details))
117 return data 118 return data
118 119
120 def _split_label(self, data):
121 name_pattern = re.compile("([A-Z]\w*)([A-Z].*)")
122 return re.sub(name_pattern, r"\1" + " " + r"\2", data)
123
119 def _details_to_search_dictionary(self, details): 124 def _details_to_search_dictionary(self, details):
120 if details: 125 if details:
121 out = {} 126 out = {}
122 label = self._detail_adapter._label_from_details(details) 127 label = self._detail_adapter._label_from_details(details)
123 out['label'] = label 128 out['label'] = label
129 alt_label = self._split_label(label)
124 hold = [label] 130 hold = [label]
131 if alt_label != label:
132 hold.append(alt_label)
133
125 if details[0].plot_id: 134 if details[0].plot_id:
126 out['id'] = details[0].plot_id 135 out['id'] = details[0].plot_id
127 out['id_type'] = u'plot' 136 out['id_type'] = u'plot'