always use text index for contact lookup
This commit is contained in:
parent
3dc65a9770
commit
72473c0c48
|
@ -2,38 +2,22 @@
|
|||
xmlns:tal="http://xml.zope.org/namespaces/tal"
|
||||
tal:omit-tag="">
|
||||
<select size="5" tal:attributes="name string:${view/name}-select">
|
||||
<option tal:repeat="item view/get_known_contacts"
|
||||
tal:attributes="value item/token" tal:content="item/title"/>
|
||||
<option tal:repeat="item view/get_known_contacts" tal:content="item/title"/>
|
||||
</select><br/>
|
||||
<input id="" name="" class="" title="" lang="" disabled=""
|
||||
<input id="" name="" class="contact-field" title="" lang="" disabled=""
|
||||
readonly="" alt="" tabindex="" accesskey="" size="" maxlength=""
|
||||
style="" value="" type="text"
|
||||
tal:attributes="id view/id;
|
||||
name view/name;
|
||||
class view/klass;
|
||||
style view/style;
|
||||
title view/title;
|
||||
lang view/lang;
|
||||
onclick view/onclick;
|
||||
ondblclick view/ondblclick;
|
||||
onmousedown view/onmousedown;
|
||||
onmouseup view/onmouseup;
|
||||
onmouseover view/onmouseover;
|
||||
onmousemove view/onmousemove;
|
||||
onmouseout view/onmouseout;
|
||||
onkeypress view/onkeypress;
|
||||
onkeydown view/onkeydown;
|
||||
onkeyup view/onkeyup;
|
||||
value view/value;
|
||||
disabled view/disabled;
|
||||
tabindex view/tabindex;
|
||||
onfocus view/onfocus;
|
||||
onblur view/onblur;
|
||||
onchange view/onchange;
|
||||
readonly view/readonly;
|
||||
alt view/alt;
|
||||
accesskey view/accesskey;
|
||||
onselect view/onselect;
|
||||
size view/size;
|
||||
maxlength view/maxlength" />
|
||||
</html>
|
||||
|
|
|
@ -59,7 +59,6 @@ def mail_dynamic_searchable_text_indexer(obj):
|
|||
|
||||
grok.global_adapter(mail_dynamic_searchable_text_indexer, name='MailSearchableText')
|
||||
|
||||
|
||||
@indexer(plone.dexterity.interfaces.IDexterityItem)
|
||||
def contactIndexer(obj):
|
||||
if obj.portal_type not in ('courrier_entrant', 'courrier_sortant'):
|
||||
|
@ -72,16 +71,7 @@ def contactIndexer(obj):
|
|||
if not v:
|
||||
continue
|
||||
v = v[0]
|
||||
if ':' in v and v.split(':')[0] in ('deputy', 'ministry', 'ministry-collab'):
|
||||
return v
|
||||
elif ':' in v and v.split(':')[0] == 'contact':
|
||||
contact_id = v.split(':')[1]
|
||||
if not hasattr(contacts_dir, contact_id):
|
||||
return contact_id.replace('-', ' ')
|
||||
else:
|
||||
return getattr(contacts_dir, contact_id).title
|
||||
else:
|
||||
return v
|
||||
return v
|
||||
return None
|
||||
|
||||
grok.global_adapter(contactIndexer, name="MailContact")
|
||||
|
@ -99,7 +89,10 @@ def contactFuzzyIndexer(obj):
|
|||
v = v[0]
|
||||
if ':' in v:
|
||||
src = ContactsSource()
|
||||
return src(obj).getTermByToken(v).title
|
||||
r = src.fastGetTitleByToken(obj, v)
|
||||
if not type(r) is unicode:
|
||||
r = unicode(r, 'utf-8')
|
||||
return r
|
||||
else:
|
||||
return v
|
||||
return None
|
||||
|
|
|
@ -61,6 +61,24 @@ td.date {
|
|||
<div metal:use-macro="view/batch_macros/macros/navigation" />
|
||||
</div>
|
||||
|
||||
<script>
|
||||
if(typeof(String.prototype.trim) === "undefined") {
|
||||
String.prototype.trim = function()
|
||||
{
|
||||
return String(this).replace(/^\s+|\s+$/g, '');
|
||||
};
|
||||
}
|
||||
|
||||
(function($) {
|
||||
$().ready(function() {
|
||||
$('input.contact-field').prevAll('select').change(function() {
|
||||
selected_option = $(this).val();
|
||||
$(this).nextAll('input.contact-field').val(selected_option.split('(')[0].trim());
|
||||
});
|
||||
});
|
||||
})(jQuery);
|
||||
</script>
|
||||
|
||||
</tal:block>
|
||||
</tal:main-macro>
|
||||
</metal:main>
|
||||
|
|
|
@ -31,15 +31,9 @@ class ContactWidget(TextWidget):
|
|||
return self.input_template(self)
|
||||
return TextWidget.render(self)
|
||||
|
||||
def extract(self, default=z3c.form.interfaces.NO_VALUE):
|
||||
t = self.request.get(self.name, default)
|
||||
if not t:
|
||||
t = self.request.get(self.name + '-select', default)
|
||||
return t
|
||||
|
||||
def get_known_contacts(self):
|
||||
terms = get_terms_for_persons(self.context, include_deputies=True,
|
||||
include_ministries=True, include_ministries_collaborators=True)
|
||||
include_ministries=True)
|
||||
return terms
|
||||
|
||||
|
||||
|
@ -117,11 +111,7 @@ class SearchView(BrowserView):
|
|||
if data.get('subcategory'):
|
||||
kw['sous_categorie_de_courrier'] = data.get('subcategory')
|
||||
if data.get('contact'):
|
||||
v = data.get('contact')
|
||||
if ':' in v and v.split(':')[0] in ('deputy', 'ministry', 'ministry-collab'):
|
||||
kw['MailContact'] = v
|
||||
else:
|
||||
kw['MailContactFuzzy'] = v
|
||||
kw['MailContactFuzzy'] = data.get('contact')
|
||||
|
||||
if data.get('scope') == 'all':
|
||||
kw['portal_type'] = ['courrier_entrant', 'courrier_sortant']
|
||||
|
|
Reference in New Issue