From 7982ba6b29799c1f1a2734ef4c90e737289c6f4f Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Wed, 28 Sep 2011 18:00:13 +0000 Subject: [PATCH] dont filter empty conditions --- pandora/annotation/managers.py | 4 +--- pandora/event/managers.py | 4 +--- pandora/item/managers.py | 4 +--- pandora/itemlist/managers.py | 8 +++----- pandora/itemlist/views.py | 1 - pandora/place/managers.py | 4 +--- pandora/user/managers.py | 4 +--- 7 files changed, 8 insertions(+), 21 deletions(-) diff --git a/pandora/annotation/managers.py b/pandora/annotation/managers.py index 872bc9b1..1949115d 100644 --- a/pandora/annotation/managers.py +++ b/pandora/annotation/managers.py @@ -96,9 +96,7 @@ def parseConditions(conditions, operator, user): conn.append(q) pass else: - if condition.get('value', '') != '' or \ - condition.get('operator', '') == '=': - conn.append(parseCondition(condition, user)) + conn.append(parseCondition(condition, user)) if conn: q = conn[0] for c in conn[1:]: diff --git a/pandora/event/managers.py b/pandora/event/managers.py index 1bf7c218..e0d83afb 100644 --- a/pandora/event/managers.py +++ b/pandora/event/managers.py @@ -46,9 +46,7 @@ def parseConditions(conditions, operator, user): conn.append(q) pass else: - if condition.get('value', '') != '' or \ - condition.get('operator', '') == '=': - conn.append(parseCondition(condition, user)) + conn.append(parseCondition(condition, user)) if conn: q = conn[0] for c in conn[1:]: diff --git a/pandora/item/managers.py b/pandora/item/managers.py index bfc8cb40..fd2fcaf7 100644 --- a/pandora/item/managers.py +++ b/pandora/item/managers.py @@ -166,9 +166,7 @@ def parseConditions(conditions, operator): conn.append(q) pass else: - if condition.get('value', '') != '' or \ - condition.get('operator', '') == '=': - conn.append(parseCondition(condition)) + conn.append(parseCondition(condition)) if conn: q = conn[0] for c in conn[1:]: diff --git a/pandora/itemlist/managers.py b/pandora/itemlist/managers.py index 44bbfbd1..6eb6f4a1 100644 --- a/pandora/itemlist/managers.py +++ b/pandora/itemlist/managers.py @@ -10,6 +10,7 @@ import models def parseCondition(condition, user): ''' ''' + print condition, user k = condition.get('key', 'name') k = { 'user': 'user__username', @@ -20,7 +21,7 @@ def parseCondition(condition, user): v = condition['value'] op = condition.get('operator') if not op: - op = '' + op = '=' if op.startswith('!'): op = op[1:] exclude = True @@ -45,7 +46,6 @@ def parseCondition(condition, user): '^': '__istartswith', '$': '__iendswith', }.get(op, '__icontains')) - key = str(key) if exclude: q = ~Q(**{key: v}) @@ -81,9 +81,7 @@ def parseConditions(conditions, operator, user): conn.append(q) pass else: - if condition.get('value', '') != '' or \ - condition.get('operator', '') == '=': - conn.append(parseCondition(condition, user)) + conn.append(parseCondition(condition, user)) if conn: q = conn[0] for c in conn[1:]: diff --git a/pandora/itemlist/views.py b/pandora/itemlist/views.py index f039c0fb..563600f7 100644 --- a/pandora/itemlist/views.py +++ b/pandora/itemlist/views.py @@ -96,7 +96,6 @@ def findLists(request): else: qs = _order_query(query['qs'], query['sort']) - qs = qs.distinct() response = json_response() if 'keys' in data: qs = qs[query['range'][0]:query['range'][1]] diff --git a/pandora/place/managers.py b/pandora/place/managers.py index eeb0e7f8..a44defc5 100644 --- a/pandora/place/managers.py +++ b/pandora/place/managers.py @@ -92,9 +92,7 @@ def parseConditions(conditions, operator, user): conn.append(q) pass else: - if condition.get('value', '') != '' or \ - condition.get('operator', '') == '=': - conn.append(parseCondition(condition, user)) + conn.append(parseCondition(condition, user)) if conn: q = conn[0] for c in conn[1:]: diff --git a/pandora/user/managers.py b/pandora/user/managers.py index 3cb9084c..72a99d4d 100644 --- a/pandora/user/managers.py +++ b/pandora/user/managers.py @@ -47,9 +47,7 @@ def parseConditions(conditions, operator, user): conn.append(q) pass else: - if condition.get('value', '') != '' or \ - condition.get('operator', '') == '=': - conn.append(parseCondition(condition, user)) + conn.append(parseCondition(condition, user)) if conn: q = conn[0] for c in conn[1:]: