def filter_queryset(self, request, queryset, view): if view.action != 'list': return queryset query_params = request.query_params qs = query_params.get('query') published_start_date = query_params.get('published_after') published_end_date = query_params.get('published_before') peer_review_status = query_params.get('peer_review_status') # platform = query_params.get('platform') # programming_language = query_params.get('programming_language') tags = query_params.getlist('tags') criteria = {} if published_start_date and published_end_date: if published_start_date < published_end_date: criteria.update(first_published_at__range=[ published_start_date, published_end_date ]) else: logger.warning("invalid date range: %s, %s", published_start_date, published_end_date) elif published_start_date: criteria.update(first_published_at__gte=published_start_date) elif published_end_date: criteria.update(first_published_at__lte=published_end_date) if peer_review_status: # reviewed_releases = CodebaseRelease.objects.filter(review__isnull=False, codebase=OuterRef('pk')) if peer_review_status == 'reviewed': criteria.update(peer_reviewed=True) elif peer_review_status == 'not_reviewed': criteria.update(peer_reviewed=False) return get_search_queryset(qs, queryset, tags=tags, criteria=criteria)
def filter_queryset(self, request, queryset, view): if view.action != 'list': return queryset query_params = request.query_params qs = query_params.get('query') tags = query_params.getlist('tags') return get_search_queryset(qs, queryset, tags=tags)
def filter_queryset(self, request, queryset, view): if view.action != 'list': return queryset qs = request.query_params.get('query') date_created = parse_datetime(request.query_params.get('date_created__gte')) application_deadline = parse_datetime(request.query_params.get('application_deadline__gte')) tags = request.query_params.getlist('tags') criteria = {} if date_created: criteria.update(date_created__gte=date_created) if application_deadline: criteria.update(application_deadline__gte=application_deadline) return get_search_queryset(qs, queryset, tags=tags, criteria=criteria)
def filter_queryset(self, request, queryset, view): if view.action != 'list': return queryset query_string = request.query_params.get('query') query_params = request.query_params submission_deadline__gte = parse_datetime(query_params.get('submission_deadline__gte')) start_date__gte = parse_datetime(query_params.get('start_date__gte') or query_params.get('start_date')) tags = request.query_params.getlist('tags') criteria = {} if submission_deadline__gte: criteria.update(submission_deadline__gte=submission_deadline__gte) if start_date__gte: criteria.update(start_date__gte=start_date__gte) return get_search_queryset(query_string, queryset, tags=tags, criteria=criteria)
def filter_queryset(self, request, queryset, view): if view.action != 'list': return queryset query_params = request.query_params qs = query_params.get('query') published_start_date = query_params.get('published_after') published_end_date = query_params.get('published_before') # platform = query_params.get('platform') # programming_language = query_params.get('programming_language') tags = query_params.getlist('tags') criteria = {} if published_start_date and published_end_date: if published_start_date < published_end_date: criteria.update(first_published_at__range=[published_start_date, published_end_date]) else: logger.warning("invalid date range: %s, %s", published_start_date, published_end_date) elif published_start_date: criteria.update(first_published_at__gte=published_start_date) elif published_end_date: criteria.update(first_published_at__lte=published_end_date) return get_search_queryset(qs, queryset, tags=tags, criteria=criteria)
def filter_queryset(self, request, queryset, view): qs = request.query_params.get('query') return get_search_queryset(qs, queryset)