From 1cc3156c7dc7ca60dc6f94cb82f1a5ee72d29264 Mon Sep 17 00:00:00 2001 From: Bryan Wilson Date: Fri, 7 Jul 2023 16:25:35 -0700 Subject: [PATCH] Fix allowed_org Filter method --- openedx/core/djangoapps/appsembler/openedx_api/filters.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/openedx/core/djangoapps/appsembler/openedx_api/filters.py b/openedx/core/djangoapps/appsembler/openedx_api/filters.py index 8407f543f4cf..7b4d31bec8dc 100644 --- a/openedx/core/djangoapps/appsembler/openedx_api/filters.py +++ b/openedx/core/djangoapps/appsembler/openedx_api/filters.py @@ -92,13 +92,13 @@ def filter_allowed_org(self, queryset, name, value): raise # TODO: do something else try: - lookup = MODEL_COURSE_ORG_LOOKUPS[self.queryset.model] + lookup = self.MODEL_COURSE_ORG_LOOKUPS[self.queryset.model] except KeyError: raise # TODO: do something else - if model in OPAQUE_KEY_FIELD_LOOKUP_MODELS: + if model in self.OPAQUE_KEY_FIELD_LOOKUP_MODELS: return queryset.filter(**{lookup: "{}{}+".format(COURSE_PREFIX, user_allowed_org)}) - elif model in STRING_ORG_NAME_LOOKUP_MODELS: + elif model in self.STRING_ORG_NAME_LOOKUP_MODELS: return queryset.filter(**{lookup: user_allowed_org.short_name}) else: return queryset.filter(**{lookup: user_allowed_org}) @@ -136,7 +136,7 @@ def get_filterset_class(self, view, queryset=None): def get_filterset_kwargs(self, request, queryset, view): try: - user_allowed_org = request.user.organizations.first() + user_allowed_org = request.user.organizations.first() except Organization.DoesNotExist: raise # TODO: do something else q_params = copy.deepcopy(request.query_params)