From 84ecd74213b3745bc7b156285e4284e75f7a0f86 Mon Sep 17 00:00:00 2001 From: Bryan Wilson Date: Thu, 6 Jul 2023 14:18:54 -0700 Subject: [PATCH] AppsemblerMultitenantFilterBackend return custom Filterset class unless view explicitly defines filterset_class or filterset_fields --- .../djangoapps/appsembler/openedx_api/filters.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/openedx/core/djangoapps/appsembler/openedx_api/filters.py b/openedx/core/djangoapps/appsembler/openedx_api/filters.py index 3f744ed17369..345d200207ec 100644 --- a/openedx/core/djangoapps/appsembler/openedx_api/filters.py +++ b/openedx/core/djangoapps/appsembler/openedx_api/filters.py @@ -107,4 +107,15 @@ def filter_allowed_org(self, queryset, name, value): class AppsemblerMultiTenantFilterBackend(filters.DjangoFilterBackend): - filterset_base = AllowedCourseOrgFilterSet + def get_filterset_class(self, view, queryset=None): + """ + If view has explicitly set a FilterSet class or FilterSet fields, use those. + These should be features we don't use, or the Tahoe API itself. + Otherwise, use our default FilterSet class. + """ + filterset_class = getattr(view, "filterset_class", None) + filterset_fields = getattr(view, "filterset_fields", None) + if filterset_class or filterset_fields: + return super(AppsemblerMultiTenantFilterBackend, self).get_filterset_class(view, queryset) + else: + return AllowedCourseOrgFilterSet