From 6f6debad28fa3ca33842bea554175519afd27507 Mon Sep 17 00:00:00 2001 From: Parbhat Puri <parbhatpuri17@gmail.com> Date: Tue, 25 Jun 2019 09:32:57 +0000 Subject: [PATCH] filter by fund - Filters submissions by specified fund and lab, allows multiple --- opentech/apply/funds/api_views.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/opentech/apply/funds/api_views.py b/opentech/apply/funds/api_views.py index f520973d7..1c2c1f3dd 100644 --- a/opentech/apply/funds/api_views.py +++ b/opentech/apply/funds/api_views.py @@ -2,6 +2,9 @@ from django.core.exceptions import PermissionDenied as DjangoPermissionDenied from django.db import transaction from django.db.models import Q, Prefetch from django.utils import timezone + +from wagtail.core.models import Page + from rest_framework import generics, mixins, permissions from rest_framework.response import Response from rest_framework.exceptions import (NotFound, PermissionDenied, @@ -13,6 +16,7 @@ from opentech.apply.activity.models import Activity, COMMENT from opentech.apply.activity.messaging import messenger, MESSAGES from opentech.apply.determinations.views import DeterminationCreateOrUpdateView from opentech.apply.review.models import Review +from opentech.apply.funds.models import FundType, LabType from .models import ApplicationSubmission, RoundsAndLabs from .serializers import ( @@ -42,10 +46,14 @@ class SubmissionsFilter(filters.FilterSet): status = filters.MultipleChoiceFilter(choices=PHASES) active = filters.BooleanFilter(method='filter_active', label='Active') submit_date = filters.DateFromToRangeFilter(name='submit_time', label='Submit date') + fund = filters.ModelMultipleChoiceFilter( + name='page', label='fund', + queryset=Page.objects.type(FundType) | Page.objects.type(LabType) + ) class Meta: model = ApplicationSubmission - fields = ('status', 'round', 'active', 'submit_date', ) + fields = ('status', 'round', 'active', 'submit_date', 'fund', ) def filter_active(self, qs, name, value): if value is None: -- GitLab