diff --git a/pandora/annotation/managers.py b/pandora/annotation/managers.py index 89600584..bffd71ac 100644 --- a/pandora/annotation/managers.py +++ b/pandora/annotation/managers.py @@ -2,7 +2,9 @@ # vi:si:et:sw=4:sts=4:ts=4 from django.db.models import Q, Manager from ox.django.query import QuerySet -import ox + +from item.utils import decode_id + def parseCondition(condition, user): ''' @@ -44,7 +46,7 @@ def parseCondition(condition, user): else: return q if k in ('places__id', 'events__id'): - v = ox.from26(v) + v = decode_id(v) if isinstance(v, bool): #featured and public flag key = k elif k in ('lat', 'lng', 'area', 'south', 'west', 'north', 'east', 'matches', diff --git a/pandora/clip/managers.py b/pandora/clip/managers.py index 60319f1b..eae7e1f2 100644 --- a/pandora/clip/managers.py +++ b/pandora/clip/managers.py @@ -4,7 +4,9 @@ from django.db.models import Q, Manager from django.conf import settings from ox.django.query import QuerySet -import ox + +from item.utils import decode_id + def parseCondition(condition, user): ''' @@ -58,7 +60,7 @@ def parseCondition(condition, user): else: return q if k.endswith('__id'): - v = ox.from26(v) + v = decode_id(v) if isinstance(v, bool): #featured and public flag key = k elif k in ('lat', 'lng', 'area', 'south', 'west', 'north', 'east', 'matches', diff --git a/pandora/event/managers.py b/pandora/event/managers.py index 883fcfe2..5d93a1d5 100644 --- a/pandora/event/managers.py +++ b/pandora/event/managers.py @@ -4,6 +4,8 @@ from django.db.models import Q, Manager from ox.django.query import QuerySet +from item.utils import decode_id + def parseCondition(condition, user): k = condition.get('key', 'name') @@ -19,6 +21,8 @@ def parseCondition(condition, user): exclude = True else: exclude = False + if k == 'id': + v = decode_id(v) key = '%s%s' % (k, { '==': '__iexact', diff --git a/pandora/item/utils.py b/pandora/item/utils.py index fd7ae32c..360bd539 100644 --- a/pandora/item/utils.py +++ b/pandora/item/utils.py @@ -4,7 +4,14 @@ from decimal import Decimal import re import unicodedata +import ox +def decode_id(id): + try: + id = ox.from26(id) + except: + id = 0 + return id def parse_decimal(string): string = string.replace(':', '/') diff --git a/pandora/log/managers.py b/pandora/log/managers.py index 19ed1d55..1775fe27 100644 --- a/pandora/log/managers.py +++ b/pandora/log/managers.py @@ -2,7 +2,9 @@ # vi:si:et:sw=4:sts=4:ts=4 from django.db.models import Q, Manager from ox.django.query import QuerySet -import ox + +from item.utils import decode_id + def parseCondition(condition, user): ''' @@ -40,7 +42,7 @@ def parseCondition(condition, user): else: return q if k == 'id': - v = ox.from26(v) + v = decode_id(v) if isinstance(v, bool): #featured and public flag key = k elif k in ('id', ): diff --git a/pandora/news/managers.py b/pandora/news/managers.py index e98a1b97..89bb82cd 100644 --- a/pandora/news/managers.py +++ b/pandora/news/managers.py @@ -2,7 +2,9 @@ # vi:si:et:sw=4:sts=4:ts=4 from django.db.models import Q, Manager from ox.django.query import QuerySet -import ox + +from item.utils import decode_id + def parseCondition(condition, user): k = condition.get('key', 'name') @@ -28,7 +30,7 @@ def parseCondition(condition, user): else: return q if k == 'id': - v = ox.from26(v) + v = decode_id(v) if isinstance(v, bool): #featured and public flag key = k elif k in ('id',): diff --git a/pandora/person/managers.py b/pandora/person/managers.py index 827cd0b8..f22f3fc3 100644 --- a/pandora/person/managers.py +++ b/pandora/person/managers.py @@ -2,7 +2,9 @@ # vi:si:et:sw=4:sts=4:ts=4 from django.db.models import Q, Manager from ox.django.query import QuerySet -import ox + +from item.utils import decode_id + def parseCondition(condition, user): ''' @@ -40,7 +42,7 @@ def parseCondition(condition, user): else: return q if k == 'id': - v = ox.from26(v) + v = decode_id(v) if isinstance(v, bool): #featured and public flag key = k elif k in ('lat', 'lng', 'area', 'south', 'west', 'north', 'east', 'matches', 'id'): diff --git a/pandora/place/managers.py b/pandora/place/managers.py index 48bb8280..34ce2c26 100644 --- a/pandora/place/managers.py +++ b/pandora/place/managers.py @@ -2,7 +2,9 @@ # vi:si:et:sw=4:sts=4:ts=4 from django.db.models import Q, Manager from ox.django.query import QuerySet -import ox + +from item.utils import decode_id + def parseCondition(condition, user): ''' @@ -40,7 +42,7 @@ def parseCondition(condition, user): else: return q if k == 'id': - v = ox.from26(v) + v = decode_id(v) if isinstance(v, bool): #featured and public flag key = k elif k in ('lat', 'lng', 'area', 'south', 'west', 'north', 'east', 'matches', 'id'): diff --git a/pandora/title/managers.py b/pandora/title/managers.py index b9e4480d..911783cf 100644 --- a/pandora/title/managers.py +++ b/pandora/title/managers.py @@ -3,7 +3,9 @@ import unicodedata from django.db.models import Q, Manager from ox.django.query import QuerySet -import ox + +from item.utils import decode_id + def parseCondition(condition, user): ''' @@ -41,7 +43,7 @@ def parseCondition(condition, user): else: return q if k == 'id': - v = ox.from26(v) + v = decode_id(v) elif isinstance(v, unicode): v = unicodedata.normalize('NFKD', v) if isinstance(v, bool): #featured and public flag