Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion hypha/apply/projects/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ def get_project_leads(request):
return User.objects.filter(lead_projects__isnull=False).distinct()


def get_project_contractors(request):
return User.objects.filter(owned_projects__isnull=False).distinct()


class InvoiceListFilter(filters.FilterSet):
fund = ModelMultipleChoiceFilter(
label=_("Funds"),
Expand All @@ -53,6 +57,9 @@ class ProjectListFilter(filters.FilterSet):
project_lead = ModelMultipleChoiceFilter(
field_name="lead", label=_("Lead"), queryset=get_project_leads
)
project_contractor = ModelMultipleChoiceFilter(
field_name="user", label=_("Contractor"), queryset=get_project_contractors
)
project_status = MultipleChoiceFilter(
field_name="status", label=_("Status"), choices=PROJECT_STATUS_CHOICES
)
Expand All @@ -74,10 +81,16 @@ class ProjectListFilter(filters.FilterSet):
"fund": "project_fund",
"lead": "project_lead",
"status": "project_status",
"contractor": "project_contractor",
}

class Meta:
fields = ["project_status", "project_lead", "project_fund"]
fields = [
"project_status",
"project_lead",
"project_contractor",
"project_fund",
]
model = Project

def __init__(self, *args, exclude=None, **kwargs):
Expand Down
1 change: 1 addition & 0 deletions hypha/apply/projects/models/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ def for_table(self):
"report_config",
"submission__page",
"lead",
"user",
)
.defer("form_data", "form_fields")
)
Expand Down
2 changes: 2 additions & 0 deletions hypha/apply/projects/tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ class BaseProjectsTable(tables.Table):
status = tables.Column(
verbose_name=_("Status"), accessor="get_status_display", order_by=("status",)
)
contractor = tables.Column(verbose_name=_("Contractor"), accessor="user")
fund = tables.Column(verbose_name=_("Fund"), accessor="submission__page")
reporting = tables.Column(verbose_name=_("Reporting"), accessor="pk")
last_payment_request = RelativeTimeColumn()
Expand Down Expand Up @@ -314,6 +315,7 @@ class Meta:
"title",
"status",
"lead",
"contractor",
"fund",
"reporting",
"last_payment_request",
Expand Down