forked from 0x2620/pandora
{me}
This commit is contained in:
parent
e56faadb95
commit
a19de36f3e
1 changed files with 16 additions and 5 deletions
|
@ -14,7 +14,7 @@ import utils
|
||||||
from ox.django.query import QuerySet
|
from ox.django.query import QuerySet
|
||||||
|
|
||||||
|
|
||||||
def parseCondition(condition, user):
|
def parseCondition(condition, user, owner=None):
|
||||||
'''
|
'''
|
||||||
condition: {
|
condition: {
|
||||||
value: "war"
|
value: "war"
|
||||||
|
@ -60,6 +60,17 @@ def parseCondition(condition, user):
|
||||||
if k == 'list':
|
if k == 'list':
|
||||||
key_type = ''
|
key_type = ''
|
||||||
|
|
||||||
|
if v == '{me}' and op == '==':
|
||||||
|
if not owner:
|
||||||
|
owner = user
|
||||||
|
if k == 'user':
|
||||||
|
v = ownder.username
|
||||||
|
elif k == 'groups':
|
||||||
|
q = Q(groups__in=owner.groups.all())
|
||||||
|
if exclude:
|
||||||
|
q = ~q
|
||||||
|
return q
|
||||||
|
|
||||||
if (not exclude and op == '=' or op in ('$', '^')) and v == '':
|
if (not exclude and op == '=' or op in ('$', '^')) and v == '':
|
||||||
return Q()
|
return Q()
|
||||||
elif k == 'filename' and (user.is_anonymous() or \
|
elif k == 'filename' and (user.is_anonymous() or \
|
||||||
|
@ -159,7 +170,7 @@ def parseCondition(condition, user):
|
||||||
data = l.query
|
data = l.query
|
||||||
q = parseConditions(data.get('conditions', []),
|
q = parseConditions(data.get('conditions', []),
|
||||||
data.get('operator', '&'),
|
data.get('operator', '&'),
|
||||||
user)
|
user, l.user)
|
||||||
else:
|
else:
|
||||||
q = Q(id__in=l.items.all())
|
q = Q(id__in=l.items.all())
|
||||||
if exclude:
|
if exclude:
|
||||||
|
@ -205,7 +216,7 @@ def parseCondition(condition, user):
|
||||||
q = ~q
|
q = ~q
|
||||||
return q
|
return q
|
||||||
|
|
||||||
def parseConditions(conditions, operator, user):
|
def parseConditions(conditions, operator, user, owner=None):
|
||||||
'''
|
'''
|
||||||
conditions: [
|
conditions: [
|
||||||
{
|
{
|
||||||
|
@ -228,9 +239,9 @@ def parseConditions(conditions, operator, user):
|
||||||
for condition in conditions:
|
for condition in conditions:
|
||||||
if 'conditions' in condition:
|
if 'conditions' in condition:
|
||||||
q = parseConditions(condition['conditions'],
|
q = parseConditions(condition['conditions'],
|
||||||
condition.get('operator', '&'), user)
|
condition.get('operator', '&'), user, owner)
|
||||||
else:
|
else:
|
||||||
q = parseCondition(condition, user)
|
q = parseCondition(condition, user, owner)
|
||||||
if isinstance(q, list):
|
if isinstance(q, list):
|
||||||
conn += q
|
conn += q
|
||||||
elif q:
|
elif q:
|
||||||
|
|
Loading…
Reference in a new issue