From bd0711911d00917898ee99394a543bb09b88721b Mon Sep 17 00:00:00 2001 From: Dirk Uys Date: Tue, 10 Oct 2023 17:03:09 +0200 Subject: [PATCH] Add filtering based on course list --- studygroups/views/api.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/studygroups/views/api.py b/studygroups/views/api.py index e3feb30b..960ef7bf 100644 --- a/studygroups/views/api.py +++ b/studygroups/views/api.py @@ -505,6 +505,7 @@ def get(self, request): "user": schema.boolean(), "include_unlisted": schema.boolean(), "facilitator_guide": schema.boolean(), + "course_list": schema.integer(), } data = schema.django_get_to_dict(request.GET) clean_data, errors = schema.validate(query_schema, data) @@ -601,6 +602,11 @@ def get(self, request): course_ids = StudyGroup.objects.published().exclude(id__in=study_group_ids).values('course') courses = courses.filter(id__in=course_ids) + if clean_data.get('course_list'): + courses = courses.filter(courselist__pk=clean_data.get('course_list')) + # TODO should this parameter only be available for teams? + # TODO should this take the course list id, or be associated with the current users team membership? + data = { 'count': courses.count() }