correctly filter on api /locations/
This commit is contained in:
parent
4d544610e5
commit
c4b3932e9b
1 changed files with 7 additions and 2 deletions
|
@ -157,8 +157,13 @@ class LocationViewSet(RetrieveModelMixin, GenericViewSet):
|
|||
detailed = 'detailed' in request.GET
|
||||
|
||||
queryset = self.get_queryset().order_by('id')
|
||||
queryset = queryset.filter(reduce(operator.or_, (Q(**{model._meta.default_related_name+'__isnull': False})
|
||||
for model in get_submodels(Location))))
|
||||
conditions = []
|
||||
for model in get_submodels(Location):
|
||||
conditions.append(Q(**{model._meta.default_related_name+'__isnull': False}) &
|
||||
(Q(**{model._meta.default_related_name + '__can_search': True}) |
|
||||
Q(**{model._meta.default_related_name + '__can_describe': True})))
|
||||
queryset = queryset.filter(reduce(operator.or_, conditions))
|
||||
|
||||
if detailed:
|
||||
for model in get_submodels(Location):
|
||||
if model == LocationGroup:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue