Пример #1
0
    def get_queryset(self):
        q = self.request.query_params.get('q')

        if q:
            queryset = Course.search(q)
            queryset = self.get_serializer_class().prefetch_queryset(
                queryset=queryset)
        else:
            course_runs = CourseRun.objects.exclude(hidden=True)

            if get_query_param(self.request, 'marketable_course_runs_only'):
                course_runs = course_runs.marketable().active()

            if get_query_param(
                    self.request,
                    'marketable_enrollable_course_runs_with_archived'):
                course_runs = course_runs.marketable().enrollable()

            if get_query_param(self.request, 'published_course_runs_only'):
                course_runs = course_runs.filter(
                    status=CourseRunStatus.Published)

            queryset = self.get_serializer_class().prefetch_queryset(
                queryset=self.queryset, course_runs=course_runs)

        return queryset.order_by(Lower('key'))
Пример #2
0
    def get_serializer_context(self, *args, **kwargs):
        context = super().get_serializer_context(*args, **kwargs)
        context.update({
            'exclude_utm': get_query_param(self.request, 'exclude_utm'),
            'include_deleted_programs': get_query_param(self.request, 'include_deleted_programs'),
        })

        return context
Пример #3
0
    def get_serializer_context(self, *args, **kwargs):
        context = super().get_serializer_context(*args, **kwargs)
        context.update({
            'published_course_runs_only': get_query_param(self.request, 'published_course_runs_only'),
            'exclude_utm': get_query_param(self.request, 'exclude_utm'),
        })

        return context
Пример #4
0
    def get_serializer_context(self, *args, **kwargs):
        context = super().get_serializer_context(*args, **kwargs)
        context.update(
            {
                "exclude_utm": get_query_param(self.request, "exclude_utm"),
                "include_deleted_programs": get_query_param(self.request, "include_deleted_programs"),
                "include_unpublished_programs": get_query_param(self.request, "include_unpublished_programs"),
            }
        )

        return context
Пример #5
0
    def get_serializer_context(self, *args, **kwargs):
        context = super().get_serializer_context(*args, **kwargs)
        context.update({
            'published_course_runs_only':
            get_query_param(self.request, 'published_course_runs_only'),
            'exclude_utm':
            get_query_param(self.request, 'exclude_utm'),
            'use_full_course_serializer':
            get_query_param(self.request, 'use_full_course_serializer'),
        })

        return context
Пример #6
0
    def get_serializer_context(self, *args, **kwargs):
        context = super().get_serializer_context(*args, **kwargs)
        context.update({
            'exclude_utm':
            get_query_param(self.request, 'exclude_utm'),
            'include_deleted_programs':
            get_query_param(self.request, 'include_deleted_programs'),
            'include_unpublished_programs':
            get_query_param(self.request, 'include_unpublished_programs'),
        })

        return context
Пример #7
0
    def get_serializer_context(self, *args, **kwargs):
        context = super().get_serializer_context(*args, **kwargs)
        query_params = ['exclude_utm', 'include_deleted_programs']

        for query_param in query_params:
            context[query_param] = get_query_param(self.request, query_param)

        return context
Пример #8
0
    def get_serializer_context(self, *args, **kwargs):
        context = super().get_serializer_context(*args, **kwargs)
        query_params = [
            'exclude_utm', 'use_full_course_serializer',
            'published_course_runs_only',
            'marketable_enrollable_course_runs_with_archived'
        ]
        for query_param in query_params:
            context[query_param] = get_query_param(self.request, query_param)

        return context