Skip to content
Snippets Groups Projects
Commit 38d78e4b authored by Todd Dembrey's avatar Todd Dembrey
Browse files

Add Filters to the dashboard and add round filter

parent 3e7aba84
No related branches found
No related tags found
No related merge requests found
import django_filters as filters
import django_tables2 as tables import django_tables2 as tables
from opentech.apply.funds.models import ApplicationSubmission from opentech.apply.funds.models import ApplicationSubmission
...@@ -15,3 +17,9 @@ class DashboardTable(tables.Table): ...@@ -15,3 +17,9 @@ class DashboardTable(tables.Table):
def render_user(self, value): def render_user(self, value):
return value.get_full_name() return value.get_full_name()
class SubmissionFilter(filters.FilterSet):
class Meta:
model = ApplicationSubmission
fields = ('round',)
...@@ -15,6 +15,12 @@ ...@@ -15,6 +15,12 @@
</div> </div>
<div class="wrapper wrapper--medium wrapper--top-bottom-inner-space"> <div class="wrapper wrapper--medium wrapper--top-bottom-inner-space">
{% render_table object_list %} {% if filter %}
<form action="" method="get" class="form form-inline">
{{ filter.form.as_p }}
<button>Filter</button>
</form>
{% endif %}
{% render_table table %}
</div> </div>
{% endblock %} {% endblock %}
from django.views.generic import ListView from django_filters.views import FilterView
from django_tables2 import RequestConfig from django_tables2.views import SingleTableMixin
from opentech.apply.funds.models import ApplicationSubmission from opentech.apply.funds.models import ApplicationSubmission
from .tables import DashboardTable from .tables import DashboardTable, SubmissionFilter
class DashboardView(ListView): class DashboardView(SingleTableMixin, FilterView):
model = ApplicationSubmission model = ApplicationSubmission
template_name = 'dashboard/dashboard.html' template_name = 'dashboard/dashboard.html'
table_class = DashboardTable
def get_context_data(self, **kwargs): filterset_class = SubmissionFilter
context = super().get_context_data(**kwargs)
context['object_list'] = DashboardTable(context['object_list'])
RequestConfig(self.request).configure(context['object_list'])
return context
...@@ -57,6 +57,7 @@ INSTALLED_APPS = [ ...@@ -57,6 +57,7 @@ INSTALLED_APPS = [
'tinymce', 'tinymce',
'wagtailcaptcha', 'wagtailcaptcha',
'django_tables2', 'django_tables2',
'django_filters',
'addressfield', 'addressfield',
'django.contrib.admin', 'django.contrib.admin',
......
...@@ -19,6 +19,7 @@ flake8 ...@@ -19,6 +19,7 @@ flake8
social_auth_app_django==2.1.0 social_auth_app_django==2.1.0
django-tables2==1.17.1 django-tables2==1.17.1
django-filter==1.1.0
# Production dependencies # Production dependencies
dj-database-url==0.4.1 dj-database-url==0.4.1
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment