search multiple words highlight + double result when object_id is in url

This commit is contained in:
Sanj 2011-11-01 00:19:02 +00:00
parent 3dc5fae64f
commit 6df7d00d11
2 changed files with 15 additions and 11 deletions

View File

@ -274,6 +274,18 @@ class ItfModel(models.Model):
operator = '' operator = ''
sort = operator + s['key'] sort = operator + s['key']
qset = qset.order_by(sort) qset = qset.order_by(sort)
#FIXME: object_id needs to do something more graceful, this breaks sort.
if options['object_id'] != False and options['object_id'] != '':
object_id = options['object_id']
qset = qset.exclude(pk=object_id)
try:
obj = kls.objects.get(pk=object_id)
ret.append(obj.list_dict())
except:
pass
''' '''
r0 = options['range'][0] r0 = options['range'][0]
r1 = options['range'][1] r1 = options['range'][1]
@ -290,16 +302,6 @@ class ItfModel(models.Model):
for r in results.object_list: for r in results.object_list:
ret.append(r.list_dict()) ret.append(r.list_dict())
#FIXME: object_id needs to do something more graceful, this breaks sort.
if options['object_id'] != False and options['object_id'] != '':
object_id = options['object_id']
qset = qset.exclude(pk=object_id)
try:
obj = kls.objects.get(pk=object_id)
ret.append(obj.list_dict())
except:
pass
return { return {
'page_no': page_no, 'page_no': page_no,

View File

@ -25,7 +25,9 @@ $('#listLeft ul li a').live("click", function() {
var searchTerm = $('.searchListField').val(); var searchTerm = $('.searchListField').val();
var html = data.html; var html = data.html;
if (searchTerm != '') { if (searchTerm != '') {
html = highlightWordsNoCase(html, searchTerm); for (var i=0; i<searchTerm.split(" ").length; i++) {
html = highlightWordsNoCase(html, searchTerm.split(" ")[i]);
}
// html = html.replace(searchTerm, "<span class='highlight'>" + searchTerm + "</span>"); // html = html.replace(searchTerm, "<span class='highlight'>" + searchTerm + "</span>");
} }
$('#bottomRight').html(html); $('#bottomRight').html(html);