Пример #1
0
def programme_search(request):
    """ Programme finder search function. """
    q = request.GET.get('q')

    if q:
        pqs = PageQuerySet()

        query = Q(
            Q(title__icontains=q) | Q(programme_finder_keywords__name__icontains=q),
            ~Q(programme_finder_exclude=True),
            pqs.live_q(),
            pqs.public_q(),
        )

        courses = map_programme_search_fields(
            ProgrammePage.objects.filter(query).order_by('title').distinct('title'),
            request.site.root_url
        )

        courses.extend(map_programme_search_fields(
            ShortCoursePage.objects.filter(query).order_by('title').distinct('title'),
            request.site.root_url
        ))

        courses.sort(key=lambda c: c['title'])
    else:
        courses = []

    return JsonResponse(courses, safe=False)
Пример #2
0
 def get_query_set(self):
     return PageQuerySet(self.model).order_by('path')