normalize find values and make lower case, also normalize and lowercase quieries

This commit is contained in:
j 2012-11-18 20:26:13 +01:00
commit ec5158c03a
7 changed files with 32 additions and 10 deletions

View file

@ -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:

View file

@ -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]