diff --git a/opentech/apply/dashboard/templates/dashboard/dashboard.html b/opentech/apply/dashboard/templates/dashboard/dashboard.html index 88a0556f54c928eae53feabe6684976f35caba2f..c6692bab57796cace47eb2fb3b2574510b0d410a 100644 --- a/opentech/apply/dashboard/templates/dashboard/dashboard.html +++ b/opentech/apply/dashboard/templates/dashboard/dashboard.html @@ -1,45 +1,3 @@ {% extends "base-apply.html" %} -{% load render_table from django_tables2 %} -{% block title %}OTF Dashboard{% endblock %} -{% block content %} -<div class="wrapper wrapper--breakout wrapper--admin"> - <div class="wrapper wrapper--large wrapper--search"> - {% block page_header %} - <div> - <h3 class="heading heading--no-margin">Received Submissions</h3> - <h5>Track and explore recent submissions</h5> - </div> - {% endblock %} - {% include "dashboard/includes/search.html" %} - </div> -</div> - -<div class="wrapper wrapper--large wrapper--top-bottom-inner-space"> - - {% if object_list|length > 0 or active_filters %} - <div class="button button--filters button--contains-icons js-open-filters">Filter By</div> - - <div class="wrapper wrapper--filters js-filter-wrapper"> - <div class="wrapper wrapper--filters-header"> - <div class="js-clear-filters">Clear</div> - <div>Filter by</div> - <div class="js-close-filters">Close</div> - </div> - <form action="" method="get" class="form form--filters"> - <ul class="form__filters select2 js-filter-list"> - {{ filter.form.as_ul }} - <button class="button button--primary" type="submit" value="Filter">Filter</button> - </ul> - </form> - </div> - {% endif %} - - {% render_table table %} -</div> - -{% endblock %} - -{% block extra_js %} - {{ filter.form.media }} -{% endblock %} +{% block title %}OTF Dashboard{% endblock %} diff --git a/opentech/apply/dashboard/urls.py b/opentech/apply/dashboard/urls.py index 07b7da83c765958c13cf34d29fa614abdfe84ab5..26944a19f4947f652bb4bd7c9c191c796eb1f7fe 100644 --- a/opentech/apply/dashboard/urls.py +++ b/opentech/apply/dashboard/urls.py @@ -1,9 +1,8 @@ from django.conf.urls import url -from .views import DashboardView, SearchView +from .views import DashboardView urlpatterns = [ url(r'^$', DashboardView.as_view(), name="dashboard"), - url(r'^search$', SearchView.as_view(), name="search"), ] diff --git a/opentech/apply/dashboard/views.py b/opentech/apply/dashboard/views.py index fa8e6168c7f12455a4563e4fdaa592dd269b4753..83d4bb09918d3ff92e04af45f6b102bf251a8525 100644 --- a/opentech/apply/dashboard/views.py +++ b/opentech/apply/dashboard/views.py @@ -1,34 +1,5 @@ -from django_filters.views import FilterView -from django_tables2.views import SingleTableMixin +from django.views.generic import TemplateView -from .tables import DashboardTable, SubmissionFilter, SubmissionFilterAndSearch - -class DashboardView(SingleTableMixin, FilterView): +class DashboardView(TemplateView): template_name = 'dashboard/dashboard.html' - table_class = DashboardTable - - filterset_class = SubmissionFilter - - def get_context_data(self, **kwargs): - active_filters = self.filterset.data - return super().get_context_data(active_filters=active_filters, **kwargs) - - -class SearchView(SingleTableMixin, FilterView): - template_name = 'dashboard/search.html' - table_class = DashboardTable - - filterset_class = SubmissionFilterAndSearch - - def get_context_data(self, **kwargs): - search_term = self.request.GET.get('query') - - # We have more data than just 'query' - active_filters = len(self.filterset.data) > 1 - - return super().get_context_data( - search_term=search_term, - active_filters=active_filters, - **kwargs, - ) diff --git a/opentech/apply/dashboard/tables.py b/opentech/apply/funds/tables.py similarity index 97% rename from opentech/apply/dashboard/tables.py rename to opentech/apply/funds/tables.py index 4e85da55a0e1612b90c0e19d342ae3dd93724e15..a7b288d3cd5b58ac42bc1b2b5802d30683b60bc2 100644 --- a/opentech/apply/dashboard/tables.py +++ b/opentech/apply/funds/tables.py @@ -13,7 +13,7 @@ from opentech.apply.funds.workflow import status_options from .widgets import Select2MultiCheckboxesWidget -class DashboardTable(tables.Table): +class SubmissionsTable(tables.Table): title = tables.LinkColumn('funds:submission', args=[A('pk')], orderable=True) submit_time = tables.DateColumn(verbose_name="Submitted") status_name = tables.Column(verbose_name="Status") @@ -25,7 +25,7 @@ class DashboardTable(tables.Table): model = ApplicationSubmission fields = ('title', 'status_name', 'stage', 'page', 'round', 'submit_time') sequence = ('title', 'status_name', 'stage', 'page', 'round', 'lead', 'submit_time') - template = "dashboard/tables/table.html" + template = 'funds/tables/table.html' def render_user(self, value): return value.get_full_name() diff --git a/opentech/apply/dashboard/templates/dashboard/includes/search.html b/opentech/apply/funds/templates/funds/includes/search.html similarity index 77% rename from opentech/apply/dashboard/templates/dashboard/includes/search.html rename to opentech/apply/funds/templates/funds/includes/search.html index 8ed5b49090b7bb27f2b9f4aa0dbd43949bb911af..5e3afc9d9c48017d2c59cf5baa5acc832010b672 100644 --- a/opentech/apply/dashboard/templates/dashboard/includes/search.html +++ b/opentech/apply/funds/templates/funds/includes/search.html @@ -1,4 +1,4 @@ -<form action="{% url 'dashboard:search' %}" method="get" role="search" class="form form--header-search-desktop"> +<form action="{% url 'funds:search' %}" method="get" role="search" class="form form--header-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> diff --git a/opentech/apply/funds/templates/funds/submissions.html b/opentech/apply/funds/templates/funds/submissions.html new file mode 100644 index 0000000000000000000000000000000000000000..9c111201580e72ebf6ee25aadbdbd74883647fa7 --- /dev/null +++ b/opentech/apply/funds/templates/funds/submissions.html @@ -0,0 +1,46 @@ +{% extends "base-apply.html" %} +{% load render_table from django_tables2 %} +{% block title %}Submissions{% endblock %} + +{% block content %} +<div class="wrapper wrapper--breakout wrapper--admin"> + <div class="wrapper wrapper--large wrapper--search"> + {% block page_header %} + <div> + <h3 class="heading heading--no-margin">Received Submissions</h3> + <h5>Track and explore recent submissions</h5> + </div> + {% endblock %} + {% include "funds/includes/search.html" %} + </div> +</div> + +<div class="wrapper wrapper--large wrapper--top-bottom-inner-space"> + + {% if object_list|length > 0 or active_filters %} + <div class="button button--filters button--contains-icons js-open-filters">Filter By</div> + + <div class="wrapper wrapper--filters js-filter-wrapper"> + <div class="wrapper wrapper--filters-header"> + <div class="js-clear-filters">Clear</div> + <div>Filter by</div> + <div class="js-close-filters">Close</div> + </div> + + <form action="" method="get" class="form form--filters"> + <ul class="form__filters select2 js-filter-list"> + {{ filter.form.as_ul }} + <button class="button button--primary" type="submit" value="Filter">Filter</button> + </ul> + </form> + </div> + {% endif %} + + {% render_table table %} +</div> + +{% endblock %} + +{% block extra_js %} + {{ filter.form.media }} +{% endblock %} diff --git a/opentech/apply/dashboard/templates/dashboard/search.html b/opentech/apply/funds/templates/funds/submissions_search.html similarity index 86% rename from opentech/apply/dashboard/templates/dashboard/search.html rename to opentech/apply/funds/templates/funds/submissions_search.html index bbf644442b04139ff5de5b02756e62d2c3a7915c..50b2e33b681f556a6372f8469ed63fbe3fdd7eb8 100644 --- a/opentech/apply/dashboard/templates/dashboard/search.html +++ b/opentech/apply/funds/templates/funds/submissions_search.html @@ -1,4 +1,4 @@ -{% extends "dashboard/dashboard.html" %} +{% extends "funds/submissions.html" %} {% block page_header %} <div class="wrapper wrapper--medium"> diff --git a/opentech/apply/dashboard/templates/dashboard/tables/table.html b/opentech/apply/funds/templates/funds/tables/table.html similarity index 100% rename from opentech/apply/dashboard/templates/dashboard/tables/table.html rename to opentech/apply/funds/templates/funds/tables/table.html diff --git a/opentech/apply/funds/urls.py b/opentech/apply/funds/urls.py index 8df134af8e039de324dab47e08f81b181d61e905..c4cbf608615ac34dcde79326ee39c68fa7be80ed 100644 --- a/opentech/apply/funds/urls.py +++ b/opentech/apply/funds/urls.py @@ -1,9 +1,11 @@ from django.conf.urls import url -from .views import SubmissionDetailView, demo_workflow +from .views import SubmissionSearchView, SubmissionDetailView, SubmissionListView, demo_workflow urlpatterns = [ url(r'^demo/(?P<wf_id>[1-2])/$', demo_workflow, name="workflow_demo"), - url(r'^submission/(?P<pk>\d+)/$', SubmissionDetailView.as_view(), name="submission"), + url(r'^submissions/$', SubmissionListView.as_view(), name="submissions"), + url(r'^submissions/(?P<pk>\d+)/$', SubmissionDetailView.as_view(), name="submission"), + url(r'^search$', SubmissionSearchView.as_view(), name="search"), ] diff --git a/opentech/apply/funds/views.py b/opentech/apply/funds/views.py index 9dbb30a19f7c0a8b5027e09ba3a7431f3a3a8e31..b8ab639f47678cc75732792ba2ffc9b2963eaa8a 100644 --- a/opentech/apply/funds/views.py +++ b/opentech/apply/funds/views.py @@ -2,9 +2,43 @@ from django import forms from django.template.response import TemplateResponse from django.views.generic import DetailView -from .models import ApplicationSubmission from .workflow import SingleStage, DoubleStage +from django_filters.views import FilterView +from django_tables2.views import SingleTableMixin + +from .tables import SubmissionsTable, SubmissionFilter, SubmissionFilterAndSearch + + +class SubmissionListView(SingleTableMixin, FilterView): + template_name = 'funds/submissions.html' + table_class = SubmissionsTable + + filterset_class = SubmissionFilter + + def get_context_data(self, **kwargs): + active_filters = self.filterset.data + return super().get_context_data(active_filters=active_filters, **kwargs) + + +class SubmissionSearchView(SingleTableMixin, FilterView): + template_name = 'funds/submissions_search.html' + table_class = SubmissionsTable + + filterset_class = SubmissionFilterAndSearch + + def get_context_data(self, **kwargs): + search_term = self.request.GET.get('query') + + # We have more data than just 'query' + active_filters = len(self.filterset.data) > 1 + + return super().get_context_data( + search_term=search_term, + active_filters=active_filters, + **kwargs, + ) + class SubmissionDetailView(DetailView): model = ApplicationSubmission @@ -19,6 +53,8 @@ class SubmissionDetailView(DetailView): workflows = [SingleStage, DoubleStage] +# Workflow Demo Views + class BasicSubmissionForm(forms.Form): who_are_you = forms.CharField() diff --git a/opentech/apply/dashboard/widgets.py b/opentech/apply/funds/widgets.py similarity index 100% rename from opentech/apply/dashboard/widgets.py rename to opentech/apply/funds/widgets.py