From 30f11a35d79862ddbed567c558e85a312ee02c2a Mon Sep 17 00:00:00 2001 From: Jonas Obrist Date: Thu, 19 May 2011 06:07:25 -0700 Subject: [PATCH] Edited polymorphic/query_translate.py via GitHub --- polymorphic/query_translate.py | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/polymorphic/query_translate.py b/polymorphic/query_translate.py index ea42338..084f7e9 100644 --- a/polymorphic/query_translate.py +++ b/polymorphic/query_translate.py @@ -123,7 +123,8 @@ def translate_polymorphic_field_path(queryset_model, field_path): Returns: translated path (unchanged, if no translation needed) """ classname, sep, pure_field_path = compat_partition(field_path, '___') - if not sep: return field_path + if not sep: + return field_path assert classname, 'PolymorphicModel: %s: bad field specification' % field_path negated = False @@ -173,16 +174,20 @@ def translate_polymorphic_field_path(queryset_model, field_path): if b == baseclass: return myclass.__name__.lower() path = _create_base_path(baseclass, b) - if path: return path + '__' + myclass.__name__.lower() + if path: + return path + '__' + myclass.__name__.lower() return '' basepath = _create_base_path(queryset_model, model) - if negated: newpath = '-' - else: newpath = '' + if negated: + newpath = '-' + else: + newpath = '' newpath += basepath - if basepath: newpath += '__' + if basepath: + newpath += '__' newpath += pure_field_path return newpath @@ -201,7 +206,8 @@ def _create_model_filter_Q(modellist, not_instance_of=False): be needed. """ - if not modellist: return None + if not modellist: + return None from polymorphic_model import PolymorphicModel @@ -220,6 +226,7 @@ def _create_model_filter_Q(modellist, not_instance_of=False): qlist = [ q_class_with_subclasses(m) for m in modellist ] q_ored = reduce(lambda a, b: a | b, qlist) - if not_instance_of: q_ored = ~q_ored + if not_instance_of: + q_ored = ~q_ored return q_ored