Skip to content

Commit 5f61f18

Browse files
committed
OpenConceptLab/ocl_issues#2273 | Collection References filters for include/exclude
1 parent f6f50cf commit 5f61f18

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

core/collections/views.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ def get_queryset(self):
383383

384384

385385
class CollectionReferencesMixin:
386-
def apply_filters(self, queryset):
386+
def apply_filters(self, queryset): # pylint: disable=too-many-branches
387387
criterion = []
388388
for key, value in self.request.query_params.dict().items():
389389
is_boolean = value.lower() in ['true', 'false']
@@ -405,6 +405,10 @@ def apply_filters(self, queryset):
405405
criterion.append(Q(transform=TRANSFORM_TO_RESOURCE_VERSIONS))
406406
elif key == TRANSFORM_TO_EXTENSIONAL and is_true:
407407
criterion.append(Q(transform=TRANSFORM_TO_EXTENSIONAL))
408+
elif key == 'include' and is_boolean:
409+
criterion.append(Q(include=is_true))
410+
elif key == 'exclude' and is_boolean:
411+
criterion.append(Q(include=not is_true))
408412

409413
if criterion:
410414
for criteria in criterion:

0 commit comments

Comments
 (0)