forked from 0x2620/pandora
normalize find values and make lower case, also normalize and lowercase quieries
This commit is contained in:
parent
1bc21588a6
commit
ec5158c03a
7 changed files with 32 additions and 10 deletions
|
@ -1,5 +1,7 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# vi:si:et:sw=4:sts=4:ts=4
|
||||
import unicodedata
|
||||
|
||||
from django.db.models import Q, Manager
|
||||
from ox.django.query import QuerySet
|
||||
|
||||
|
@ -71,6 +73,8 @@ def parseCondition(condition, user):
|
|||
}.get(op, '__icontains'))
|
||||
|
||||
key = str(key)
|
||||
if isinstance(v, unicode):
|
||||
v = unicodedata.normalize('NFKD', v).lower()
|
||||
if exclude:
|
||||
q = ~Q(**{key: v})
|
||||
else:
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
# vi:si:et:sw=4:sts=4:ts=4
|
||||
from __future__ import division, with_statement
|
||||
import re
|
||||
import unicodedata
|
||||
|
||||
from django.db import models
|
||||
from django.db.models import Q
|
||||
|
@ -136,6 +137,7 @@ class Annotation(models.Model):
|
|||
if self.value:
|
||||
self.value = utils.cleanup_value(self.value, layer['type'])
|
||||
self.findvalue = ox.decode_html(ox.strip_tags(re.sub('<br */?>\n?', ' ', self.value))).replace('\n', ' ')
|
||||
self.findvalue = unicodedata.normalize('NFKD', self.findvalue).lower()
|
||||
sortvalue = sort_string(self.findvalue)
|
||||
if sortvalue:
|
||||
self.sortvalue = sortvalue[:900]
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# vi:si:et:sw=4:sts=4:ts=4
|
||||
import unicodedata
|
||||
|
||||
from django.db.models import Q, Manager
|
||||
from ox.django.query import QuerySet
|
||||
|
@ -31,6 +32,8 @@ def parseCondition(condition, user):
|
|||
}.get(op,'__icontains'))
|
||||
|
||||
key = str(key)
|
||||
if isinstance(v, unicode):
|
||||
v = unicodedata.normalize('NFKD', v).lower()
|
||||
if exclude:
|
||||
q = ~Q(**{k: v})
|
||||
else:
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# vi:si:et:sw=4:sts=4:ts=4
|
||||
from datetime import datetime
|
||||
import unicodedata
|
||||
|
||||
from django.db.models import Q, Manager
|
||||
from django.conf import settings
|
||||
|
@ -130,6 +131,8 @@ def parseCondition(condition, user):
|
|||
|
||||
k = str(k)
|
||||
value_key = str(value_key)
|
||||
if isinstance(v, unicode):
|
||||
v = unicodedata.normalize('NFKD', v).lower()
|
||||
if k == '*':
|
||||
q = Q(**{value_key: v})
|
||||
elif in_find:
|
||||
|
|
|
@ -600,6 +600,7 @@ class Item(models.Model):
|
|||
value = value and 'true' or 'false'
|
||||
if isinstance(value, basestring):
|
||||
value = ox.decode_html(ox.strip_tags(value.strip()))
|
||||
value = unicodedata.normalize('NFKD', value).lower()
|
||||
f.value = value
|
||||
f.save()
|
||||
else:
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# vi:si:et:sw=4:sts=4:ts=4
|
||||
import unicodedata
|
||||
|
||||
from django.db.models import Q, Manager
|
||||
from ox.django.query import QuerySet
|
||||
|
||||
|
@ -60,6 +62,8 @@ def parseCondition(condition, user):
|
|||
}.get(op,'__icontains'))
|
||||
|
||||
key = str(key)
|
||||
if isinstance(v, unicode):
|
||||
v = unicodedata.normalize('NFKD', v).lower()
|
||||
if exclude:
|
||||
q = ~Q(**{key: v})
|
||||
else:
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# vi:si:et:sw=4:sts=4:ts=4
|
||||
import unicodedata
|
||||
|
||||
from django.db.models import Q, Manager
|
||||
from ox.django.query import QuerySet
|
||||
|
||||
|
@ -59,6 +61,9 @@ def parseCondition(condition, user):
|
|||
}.get(op,'__icontains'))
|
||||
|
||||
key = str(key)
|
||||
if isinstance(v, unicode):
|
||||
v = unicodedata.normalize('NFKD', v).lower()
|
||||
|
||||
if exclude:
|
||||
q = ~Q(**{key: v})
|
||||
else:
|
||||
|
|
Loading…
Reference in a new issue