forked from 0x2620/pandora
findusers
This commit is contained in:
parent
5812ed0964
commit
34c2314df4
2 changed files with 7 additions and 7 deletions
|
@ -7,10 +7,10 @@ from django.db.models import Q
|
|||
def parseCondition(condition, user):
|
||||
k = condition.get('key', 'name')
|
||||
k = {
|
||||
'email': 'user__email',
|
||||
'firstseen': 'user__created',
|
||||
'lastseen': 'user__last_login',
|
||||
'user': 'user__username',
|
||||
'firstseen': 'created',
|
||||
'lastseen': 'last_login',
|
||||
'user': 'username',
|
||||
'name': 'username',
|
||||
}.get(k, k)
|
||||
v = condition['value']
|
||||
op = condition.get('operator')
|
||||
|
@ -30,9 +30,9 @@ def parseCondition(condition, user):
|
|||
|
||||
key = str(key)
|
||||
if exclude:
|
||||
q = ~Q(**{k: v})
|
||||
q = ~Q(**{key: v})
|
||||
else:
|
||||
q = Q(**{k: v})
|
||||
q = Q(**{key: v})
|
||||
return q
|
||||
|
||||
def parseConditions(conditions, operator, user):
|
||||
|
|
|
@ -417,6 +417,7 @@ def order_query(qs, sort):
|
|||
'firstseen': 'date_joined',
|
||||
'lastseen': 'last_login',
|
||||
'username': 'username',
|
||||
'name': 'username',
|
||||
}.get(e['key'], 'profile__%s'%e['key'])
|
||||
if key == 'profile__numberoflists':
|
||||
qs = qs.annotate(numberoflists=Sum('lists'))
|
||||
|
@ -424,7 +425,6 @@ def order_query(qs, sort):
|
|||
order = '%s%s' % (operator, key)
|
||||
order_by.append(order)
|
||||
if order_by:
|
||||
print order_by
|
||||
#user table does not support this
|
||||
#qs = qs.order_by(*order_by, nulls_last=True)
|
||||
qs = qs.order_by(*order_by)
|
||||
|
|
Loading…
Reference in a new issue