Skip to content

Commit

Permalink
AppsemblerMultitenantFilterBackend return custom Filterset class
Browse files Browse the repository at this point in the history
unless view explicitly defines filterset_class or filterset_fields
  • Loading branch information
bryanlandia committed Jul 6, 2023
1 parent f58a23d commit 84ecd74
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion openedx/core/djangoapps/appsembler/openedx_api/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 84ecd74

Please sign in to comment.