forked from 0x2620/pandora
decode_id
This commit is contained in:
parent
26a8e5be96
commit
0feace7a8b
9 changed files with 39 additions and 14 deletions
|
@ -2,7 +2,9 @@
|
||||||
# vi:si:et:sw=4:sts=4:ts=4
|
# vi:si:et:sw=4:sts=4:ts=4
|
||||||
from django.db.models import Q, Manager
|
from django.db.models import Q, Manager
|
||||||
from ox.django.query import QuerySet
|
from ox.django.query import QuerySet
|
||||||
import ox
|
|
||||||
|
from item.utils import decode_id
|
||||||
|
|
||||||
|
|
||||||
def parseCondition(condition, user):
|
def parseCondition(condition, user):
|
||||||
'''
|
'''
|
||||||
|
@ -44,7 +46,7 @@ def parseCondition(condition, user):
|
||||||
else:
|
else:
|
||||||
return q
|
return q
|
||||||
if k in ('places__id', 'events__id'):
|
if k in ('places__id', 'events__id'):
|
||||||
v = ox.from26(v)
|
v = decode_id(v)
|
||||||
if isinstance(v, bool): #featured and public flag
|
if isinstance(v, bool): #featured and public flag
|
||||||
key = k
|
key = k
|
||||||
elif k in ('lat', 'lng', 'area', 'south', 'west', 'north', 'east', 'matches',
|
elif k in ('lat', 'lng', 'area', 'south', 'west', 'north', 'east', 'matches',
|
||||||
|
|
|
@ -4,7 +4,9 @@ from django.db.models import Q, Manager
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
|
||||||
from ox.django.query import QuerySet
|
from ox.django.query import QuerySet
|
||||||
import ox
|
|
||||||
|
from item.utils import decode_id
|
||||||
|
|
||||||
|
|
||||||
def parseCondition(condition, user):
|
def parseCondition(condition, user):
|
||||||
'''
|
'''
|
||||||
|
@ -58,7 +60,7 @@ def parseCondition(condition, user):
|
||||||
else:
|
else:
|
||||||
return q
|
return q
|
||||||
if k.endswith('__id'):
|
if k.endswith('__id'):
|
||||||
v = ox.from26(v)
|
v = decode_id(v)
|
||||||
if isinstance(v, bool): #featured and public flag
|
if isinstance(v, bool): #featured and public flag
|
||||||
key = k
|
key = k
|
||||||
elif k in ('lat', 'lng', 'area', 'south', 'west', 'north', 'east', 'matches',
|
elif k in ('lat', 'lng', 'area', 'south', 'west', 'north', 'east', 'matches',
|
||||||
|
|
|
@ -4,6 +4,8 @@
|
||||||
from django.db.models import Q, Manager
|
from django.db.models import Q, Manager
|
||||||
from ox.django.query import QuerySet
|
from ox.django.query import QuerySet
|
||||||
|
|
||||||
|
from item.utils import decode_id
|
||||||
|
|
||||||
|
|
||||||
def parseCondition(condition, user):
|
def parseCondition(condition, user):
|
||||||
k = condition.get('key', 'name')
|
k = condition.get('key', 'name')
|
||||||
|
@ -19,6 +21,8 @@ def parseCondition(condition, user):
|
||||||
exclude = True
|
exclude = True
|
||||||
else:
|
else:
|
||||||
exclude = False
|
exclude = False
|
||||||
|
if k == 'id':
|
||||||
|
v = decode_id(v)
|
||||||
|
|
||||||
key = '%s%s' % (k, {
|
key = '%s%s' % (k, {
|
||||||
'==': '__iexact',
|
'==': '__iexact',
|
||||||
|
|
|
@ -4,7 +4,14 @@
|
||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
import re
|
import re
|
||||||
import unicodedata
|
import unicodedata
|
||||||
|
import ox
|
||||||
|
|
||||||
|
def decode_id(id):
|
||||||
|
try:
|
||||||
|
id = ox.from26(id)
|
||||||
|
except:
|
||||||
|
id = 0
|
||||||
|
return id
|
||||||
|
|
||||||
def parse_decimal(string):
|
def parse_decimal(string):
|
||||||
string = string.replace(':', '/')
|
string = string.replace(':', '/')
|
||||||
|
|
|
@ -2,7 +2,9 @@
|
||||||
# vi:si:et:sw=4:sts=4:ts=4
|
# vi:si:et:sw=4:sts=4:ts=4
|
||||||
from django.db.models import Q, Manager
|
from django.db.models import Q, Manager
|
||||||
from ox.django.query import QuerySet
|
from ox.django.query import QuerySet
|
||||||
import ox
|
|
||||||
|
from item.utils import decode_id
|
||||||
|
|
||||||
|
|
||||||
def parseCondition(condition, user):
|
def parseCondition(condition, user):
|
||||||
'''
|
'''
|
||||||
|
@ -40,7 +42,7 @@ def parseCondition(condition, user):
|
||||||
else:
|
else:
|
||||||
return q
|
return q
|
||||||
if k == 'id':
|
if k == 'id':
|
||||||
v = ox.from26(v)
|
v = decode_id(v)
|
||||||
if isinstance(v, bool): #featured and public flag
|
if isinstance(v, bool): #featured and public flag
|
||||||
key = k
|
key = k
|
||||||
elif k in ('id', ):
|
elif k in ('id', ):
|
||||||
|
|
|
@ -2,7 +2,9 @@
|
||||||
# vi:si:et:sw=4:sts=4:ts=4
|
# vi:si:et:sw=4:sts=4:ts=4
|
||||||
from django.db.models import Q, Manager
|
from django.db.models import Q, Manager
|
||||||
from ox.django.query import QuerySet
|
from ox.django.query import QuerySet
|
||||||
import ox
|
|
||||||
|
from item.utils import decode_id
|
||||||
|
|
||||||
|
|
||||||
def parseCondition(condition, user):
|
def parseCondition(condition, user):
|
||||||
k = condition.get('key', 'name')
|
k = condition.get('key', 'name')
|
||||||
|
@ -28,7 +30,7 @@ def parseCondition(condition, user):
|
||||||
else:
|
else:
|
||||||
return q
|
return q
|
||||||
if k == 'id':
|
if k == 'id':
|
||||||
v = ox.from26(v)
|
v = decode_id(v)
|
||||||
if isinstance(v, bool): #featured and public flag
|
if isinstance(v, bool): #featured and public flag
|
||||||
key = k
|
key = k
|
||||||
elif k in ('id',):
|
elif k in ('id',):
|
||||||
|
|
|
@ -2,7 +2,9 @@
|
||||||
# vi:si:et:sw=4:sts=4:ts=4
|
# vi:si:et:sw=4:sts=4:ts=4
|
||||||
from django.db.models import Q, Manager
|
from django.db.models import Q, Manager
|
||||||
from ox.django.query import QuerySet
|
from ox.django.query import QuerySet
|
||||||
import ox
|
|
||||||
|
from item.utils import decode_id
|
||||||
|
|
||||||
|
|
||||||
def parseCondition(condition, user):
|
def parseCondition(condition, user):
|
||||||
'''
|
'''
|
||||||
|
@ -40,7 +42,7 @@ def parseCondition(condition, user):
|
||||||
else:
|
else:
|
||||||
return q
|
return q
|
||||||
if k == 'id':
|
if k == 'id':
|
||||||
v = ox.from26(v)
|
v = decode_id(v)
|
||||||
if isinstance(v, bool): #featured and public flag
|
if isinstance(v, bool): #featured and public flag
|
||||||
key = k
|
key = k
|
||||||
elif k in ('lat', 'lng', 'area', 'south', 'west', 'north', 'east', 'matches', 'id'):
|
elif k in ('lat', 'lng', 'area', 'south', 'west', 'north', 'east', 'matches', 'id'):
|
||||||
|
|
|
@ -2,7 +2,9 @@
|
||||||
# vi:si:et:sw=4:sts=4:ts=4
|
# vi:si:et:sw=4:sts=4:ts=4
|
||||||
from django.db.models import Q, Manager
|
from django.db.models import Q, Manager
|
||||||
from ox.django.query import QuerySet
|
from ox.django.query import QuerySet
|
||||||
import ox
|
|
||||||
|
from item.utils import decode_id
|
||||||
|
|
||||||
|
|
||||||
def parseCondition(condition, user):
|
def parseCondition(condition, user):
|
||||||
'''
|
'''
|
||||||
|
@ -40,7 +42,7 @@ def parseCondition(condition, user):
|
||||||
else:
|
else:
|
||||||
return q
|
return q
|
||||||
if k == 'id':
|
if k == 'id':
|
||||||
v = ox.from26(v)
|
v = decode_id(v)
|
||||||
if isinstance(v, bool): #featured and public flag
|
if isinstance(v, bool): #featured and public flag
|
||||||
key = k
|
key = k
|
||||||
elif k in ('lat', 'lng', 'area', 'south', 'west', 'north', 'east', 'matches', 'id'):
|
elif k in ('lat', 'lng', 'area', 'south', 'west', 'north', 'east', 'matches', 'id'):
|
||||||
|
|
|
@ -3,7 +3,9 @@
|
||||||
import unicodedata
|
import unicodedata
|
||||||
from django.db.models import Q, Manager
|
from django.db.models import Q, Manager
|
||||||
from ox.django.query import QuerySet
|
from ox.django.query import QuerySet
|
||||||
import ox
|
|
||||||
|
from item.utils import decode_id
|
||||||
|
|
||||||
|
|
||||||
def parseCondition(condition, user):
|
def parseCondition(condition, user):
|
||||||
'''
|
'''
|
||||||
|
@ -41,7 +43,7 @@ def parseCondition(condition, user):
|
||||||
else:
|
else:
|
||||||
return q
|
return q
|
||||||
if k == 'id':
|
if k == 'id':
|
||||||
v = ox.from26(v)
|
v = decode_id(v)
|
||||||
elif isinstance(v, unicode):
|
elif isinstance(v, unicode):
|
||||||
v = unicodedata.normalize('NFKD', v)
|
v = unicodedata.normalize('NFKD', v)
|
||||||
if isinstance(v, bool): #featured and public flag
|
if isinstance(v, bool): #featured and public flag
|
||||||
|
|
Loading…
Reference in a new issue