From a554a0ceae74e37574a13640c61e5ea1b56d0676 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laura=20Kl=C3=BCnder?= Date: Tue, 10 Dec 2019 18:55:32 +0100 Subject: [PATCH] only query relevant groups --- src/c3nav/editor/api.py | 6 +++--- src/c3nav/editor/wrappers.py | 4 ++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/c3nav/editor/api.py b/src/c3nav/editor/api.py index 44a6a786..48a1204c 100644 --- a/src/c3nav/editor/api.py +++ b/src/c3nav/editor/api.py @@ -227,7 +227,7 @@ class EditorViewSet(EditorViewSetMixin, ViewSet): ).prefetch_related( Prefetch('groups', LocationGroup.objects.only( 'color', 'category', 'priority', 'category__priority', 'category__allow_spaces' - )) + ).filter(color__isnull=False)) ) space = next(s for s in other_spaces if s.pk == space.pk) @@ -287,7 +287,7 @@ class EditorViewSet(EditorViewSetMixin, ViewSet): ).prefetch_related( Prefetch('groups', LocationGroup.objects.only( 'color', 'category', 'priority', 'category__priority', 'category__allow_areas' - )) + ).filter(color__isnull=False)) ) for area in areas: area.opacity = 0.5 @@ -311,7 +311,7 @@ class EditorViewSet(EditorViewSetMixin, ViewSet): space.pois.filter(POI.q_for_request(request)).only('geometry', 'space').prefetch_related( Prefetch('groups', LocationGroup.objects.only( 'color', 'category', 'priority', 'category__priority', 'category__allow_pois' - )) + ).filter(color__isnull=False)) ), other_spaces_upper, graphedges, diff --git a/src/c3nav/editor/wrappers.py b/src/c3nav/editor/wrappers.py index 5211551e..a096d85d 100644 --- a/src/c3nav/editor/wrappers.py +++ b/src/c3nav/editor/wrappers.py @@ -686,6 +686,10 @@ class BaseQueryWrapper(BaseWrapper): # field__lt return self._filter_values(q, field_name, lambda val: val < filter_value) + if filter_type == 'isnull': + # field__isnull + return self._filter_values(q, field_name, lambda val: (val is None) is filter_value) + raise NotImplementedError raise NotImplementedError('cannot filter %s by %s (%s)' % (model, filter_name, field))