Commit 87c3547d by Rene Sorel

mobile api user course enrollments allow filter by org

parent 0438878a
...@@ -270,14 +270,18 @@ class UserCourseEnrollmentsList(generics.ListAPIView): ...@@ -270,14 +270,18 @@ class UserCourseEnrollmentsList(generics.ListAPIView):
# the default behavior by setting the pagination_class to None. # the default behavior by setting the pagination_class to None.
pagination_class = None pagination_class = None
def is_org(self, check_org, course_org):
return check_org == None or (check_org.lower() == course_org.lower())
def get_queryset(self): def get_queryset(self):
enrollments = self.queryset.filter( enrollments = self.queryset.filter(
user__username=self.kwargs['username'], user__username=self.kwargs['username'],
is_active=True is_active=True
).order_by('created').reverse() ).order_by('created').reverse()
org = self.request.query_params.get('org', None)
return [ return [
enrollment for enrollment in enrollments enrollment for enrollment in enrollments
if enrollment.course_overview and if enrollment.course_overview and self.is_org(org, enrollment.course_overview.org) and
is_mobile_available_for_user(self.request.user, enrollment.course_overview) is_mobile_available_for_user(self.request.user, enrollment.course_overview)
] ]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment