diff --git a/hypha/apply/funds/tables.py b/hypha/apply/funds/tables.py index 90c88a2ea4cdfd6bc2cc4b694c774211215d4e23..b5b8fc08467dcc1124a28d949542d95c23cda2d4 100644 --- a/hypha/apply/funds/tables.py +++ b/hypha/apply/funds/tables.py @@ -1,4 +1,5 @@ import json +import re import textwrap import django_filters as filters @@ -365,9 +366,15 @@ class SubmissionFilter(filters.FilterSet): class SubmissionFilterAndSearch(SubmissionFilter): - query = filters.CharFilter(field_name='search_data', lookup_expr="icontains", widget=forms.HiddenInput) + query = filters.CharFilter(method='search_data_and_id', widget=forms.HiddenInput) archived = filters.BooleanFilter(field_name='is_archive', widget=forms.HiddenInput, method='filter_archived') + def search_data_and_id(self, queryset, name, value): + possible_id = re.search("^#(\\d+)$", value.strip()) + if possible_id: + return queryset.filter(id=possible_id.groups()[0]) + return queryset.filter(search_data__icontains=value) + def filter_archived(self, queryset, name, value): if not value: # if value is 0 or None