diff --git a/opentech/apply/funds/templates/funds/base_submissions_table.html b/opentech/apply/funds/templates/funds/base_submissions_table.html index 9804b60e9330e6d2c4a67b5002285121549020f2..5ab3e17962d06e879e66d62cf760cc75d183b5e0 100644 --- a/opentech/apply/funds/templates/funds/base_submissions_table.html +++ b/opentech/apply/funds/templates/funds/base_submissions_table.html @@ -9,10 +9,8 @@ {% block content %} {% block table %} <div class="wrapper wrapper--table-actions"> - {% if table.data or active_filters %} - <button class="button button--filters button--contains-icons js-toggle-filters">Filters</button> - {% include "funds/includes/search.html" %} - {% endif %} + <button class="button button--filters button--contains-icons js-toggle-filters">Filters</button> + {% include "funds/includes/search.html" %} </div> {% if table.data or active_filters %} diff --git a/opentech/apply/funds/templates/funds/includes/search.html b/opentech/apply/funds/templates/funds/includes/search.html index 0c2a62dc26e8274d90d5285c024d89a1d4f67eda..525771944e49c110be75c04ed97003016ff60c78 100644 --- a/opentech/apply/funds/templates/funds/includes/search.html +++ b/opentech/apply/funds/templates/funds/includes/search.html @@ -1,6 +1,6 @@ -<form action="{% url 'funds:search' %}" method="get" role="search" class="form form--search-desktop"> +<form action="" method="get" role="search" class="form form--search-desktop"> <button class="button button--search" type="submit" aria-label="Search"> <svg class="icon icon--magnifying-glass icon--search"><use xlink:href="#magnifying-glass"></use></svg> </button> - <input class="input input--search" type="text" placeholder="Search submissions" name="query"{% if search_query %} value="{{ search_query }}{% endif %}" aria-label="Search input"> + <input class="input input--search" type="text" placeholder="Search submissions" name="query"{% if search_term %} value="{{ search_term }}"{% endif %} aria-label="Search input"> </form> diff --git a/opentech/apply/funds/urls.py b/opentech/apply/funds/urls.py index 3f461c32e778ea6bf608389dcc93b73f1d35fe81..cedf0284fc6fd7a41bd098642e887eab4203e363 100644 --- a/opentech/apply/funds/urls.py +++ b/opentech/apply/funds/urls.py @@ -8,7 +8,6 @@ from .views import ( SubmissionEditView, SubmissionListView, SubmissionSealedView, - SubmissionSearchView, ) from .api_views import SubmissionList, SubmissionDetail @@ -45,5 +44,4 @@ submission_api_urls = ([ urlpatterns = [ path('submissions/', include(submission_urls)), path('api/submissions/', include(submission_api_urls)), - path('search/', SubmissionSearchView.as_view(), name="search"), ] diff --git a/opentech/apply/funds/views.py b/opentech/apply/funds/views.py index 15f46128b7632b1977f458d5df2503722e7650b6..8f18493ccb7f7cd68c3881ac7b0c23e1e7a08815 100644 --- a/opentech/apply/funds/views.py +++ b/opentech/apply/funds/views.py @@ -39,7 +39,7 @@ from .workflow import STAGE_CHANGE_ACTIONS @method_decorator(staff_required, name='dispatch') class BaseAdminSubmissionsTable(SingleTableMixin, FilterView): table_class = AdminSubmissionsTable - filterset_class = SubmissionFilter + filterset_class = SubmissionFilterAndSearch excluded_fields = [] @@ -61,8 +61,17 @@ class BaseAdminSubmissionsTable(SingleTableMixin, FilterView): return self.filterset_class._meta.model.objects.current().for_table(self.request.user) def get_context_data(self, **kwargs): + kwargs = super().get_context_data(**kwargs,) + + search_term = self.request.GET.get('query') active_filters = self.filterset.data - return super().get_context_data(active_filters=active_filters, **kwargs) + active_filters = len(self.filterset.data) > 1 + kwargs.update( + search_term=search_term, + active_filters=active_filters, + ) + + return kwargs class SubmissionListView(AllActivityContextMixin, BaseAdminSubmissionsTable): @@ -89,28 +98,6 @@ class SubmissionsByRound(BaseAdminSubmissionsTable): return super().get_context_data(object=self.obj, **kwargs) -@method_decorator(staff_required, name='dispatch') -class SubmissionSearchView(BaseAdminSubmissionsTable): - template_name = 'funds/submissions_search.html' - - filterset_class = SubmissionFilterAndSearch - - def get_context_data(self, **kwargs): - kwargs = super().get_context_data(**kwargs,) - - search_term = self.request.GET.get('query') - - # We have more data than just 'query' - active_filters = len(self.filterset.data) > 1 - - kwargs.update( - search_term=search_term, - active_filters=active_filters, - ) - - return kwargs - - @method_decorator(staff_required, name='dispatch') class ProgressSubmissionView(DelegatedViewMixin, UpdateView): model = ApplicationSubmission