From 11716fe3ba1fb8c505fd6a0cd01f007d7c2b0dc6 Mon Sep 17 00:00:00 2001 From: Bryan Wilson Date: Thu, 6 Jul 2023 15:05:56 -0700 Subject: [PATCH] wip: try to handle non-QuerySet 'querysets' --- .../appsembler/openedx_api/filters.py | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/openedx/core/djangoapps/appsembler/openedx_api/filters.py b/openedx/core/djangoapps/appsembler/openedx_api/filters.py index 345d200207ec..d569f11be3d6 100644 --- a/openedx/core/djangoapps/appsembler/openedx_api/filters.py +++ b/openedx/core/djangoapps/appsembler/openedx_api/filters.py @@ -105,6 +105,25 @@ def filter_allowed_org(self, queryset, name, value): # don't declare an explicit model via Meta +class CourseKeySequenceMultitenancyFilter(object): + """Filter get_queryset return values that return CourseKey Sequences instead of actual QuerySets.""" + + def __init__(self, data=None, queryset=None, *, request=None, prefix=None): + self.data = data + self.queryset = queryset + self.request = request + + @property + def qs(self): + import pdb; pdb.set_trace() + # yield [] + +class CourseOverviewSequenceMultitenancyFilter(object): + """Filter get_queryset return values that return CourseOverview Sequences instead of actual QuerySets.""" + + + + class AppsemblerMultiTenantFilterBackend(filters.DjangoFilterBackend): def get_filterset_class(self, view, queryset=None): @@ -117,5 +136,11 @@ def get_filterset_class(self, view, queryset=None): filterset_fields = getattr(view, "filterset_fields", None) if filterset_class or filterset_fields: return super(AppsemblerMultiTenantFilterBackend, self).get_filterset_class(view, queryset) + elif not getattr(queryset, "model", None): + try: + # return SEQUENCE_QS_FILTERS[] + return CourseKeySequenceMultitenancyFilter + except KeyError: + raise # TODO: something else else: return AllowedCourseOrgFilterSet