From f85345bd9a64ca6e6e8942f49a9dd43a0982d898 Mon Sep 17 00:00:00 2001 From: Todd Dembrey <todd.dembrey@torchbox.com> Date: Tue, 29 Jan 2019 09:54:30 +0000 Subject: [PATCH] Create status view for submissions --- .../funds/submissions_by_status.html | 25 ++++++++++ opentech/apply/funds/urls.py | 2 + opentech/apply/funds/views.py | 25 +++++++++- opentech/apply/funds/workflow.py | 47 +++++++++++++++++++ 4 files changed, 98 insertions(+), 1 deletion(-) create mode 100644 opentech/apply/funds/templates/funds/submissions_by_status.html diff --git a/opentech/apply/funds/templates/funds/submissions_by_status.html b/opentech/apply/funds/templates/funds/submissions_by_status.html new file mode 100644 index 000000000..7d2780fd1 --- /dev/null +++ b/opentech/apply/funds/templates/funds/submissions_by_status.html @@ -0,0 +1,25 @@ +{% extends "funds/base_submissions_table.html" %} +{% load render_bundle from webpack_loader %} + +{% block title %}{{ status }}{% endblock %} + +{% block content %} + <div class="admin-bar"> + <div class="admin-bar__inner admin-bar__inner--with-button"> + <div> + <h1 class="gamma heading heading--no-margin heading--bold">{{ status }}</h1> + </div> + <div id="submissions-by-status-app-react-switcher"></div> + </div> + </div> + + <div id="submissions-by-status-react-app" data-statuses="{{ statuses }}"> + <div class="wrapper wrapper--large wrapper--inner-space-medium"> + {% block table %} + {{ block.super }} + {% endblock %} + </div> + </div> +{% render_bundle 'main' %} + +{% endblock %} diff --git a/opentech/apply/funds/urls.py b/opentech/apply/funds/urls.py index 81201c449..1339981cb 100644 --- a/opentech/apply/funds/urls.py +++ b/opentech/apply/funds/urls.py @@ -5,6 +5,7 @@ from .views import ( RevisionListView, RoundListView, SubmissionsByRound, + SubmissionsByStatus, SubmissionDetailView, SubmissionEditView, SubmissionListView, @@ -42,6 +43,7 @@ submission_urls = ([ path('', include('opentech.apply.determinations.urls', namespace="determinations")), path('revisions/', include(revision_urls, namespace="revisions")), ])), + path('<slug:status>/', SubmissionsByStatus.as_view(), name='status'), ], 'submissions') api_urls = ([ diff --git a/opentech/apply/funds/views.py b/opentech/apply/funds/views.py index b3928ac67..6ae3dce92 100644 --- a/opentech/apply/funds/views.py +++ b/opentech/apply/funds/views.py @@ -39,7 +39,7 @@ from .tables import ( SubmissionFilterAndSearch, SummarySubmissionsTable, ) -from .workflow import STAGE_CHANGE_ACTIONS +from .workflow import STAGE_CHANGE_ACTIONS, PHASES_MAPPING @method_decorator(staff_required, name='dispatch') @@ -130,6 +130,29 @@ class SubmissionsByRound(BaseAdminSubmissionsTable): return super().get_context_data(object=self.obj, **kwargs) +class SubmissionsByStatus(BaseAdminSubmissionsTable): + template_name = 'funds/submissions_by_status.html' + status_mapping = PHASES_MAPPING + + def get(self, request, *args, **kwargs): + self.status = kwargs.get('status') + if self.status not in self.status_mapping: + raise Http404(_("No statuses match the requested value")) + + return super().get(request, *args, **kwargs) + + def get_queryset(self): + return super().get_queryset().filter(status__in=self.status_mapping[self.status]['statuses']) + + def get_context_data(self, **kwargs): + status_data = self.status_mapping[self.status] + return super().get_context_data( + status=status_data['name'], + statuses=status_data['statuses'], + **kwargs, + ) + + @method_decorator(staff_required, name='dispatch') class ProgressSubmissionView(DelegatedViewMixin, UpdateView): model = ApplicationSubmission diff --git a/opentech/apply/funds/workflow.py b/opentech/apply/funds/workflow.py index 39cb99ecd..53148659f 100644 --- a/opentech/apply/funds/workflow.py +++ b/opentech/apply/funds/workflow.py @@ -733,3 +733,50 @@ def get_determination_transitions(): DETERMINATION_OUTCOMES = get_determination_transitions() + + +def phases_matching(phrase, exclude=list()): + return [ + status for status, _ in PHASES + if status.endswith(phrase) and status not in exclude + ] + + +PHASES_MAPPING = { + 'received': { + 'name': 'Received', + 'statuses': [INITIAL_STATE, 'proposal_discussion'], + }, + 'internal-review': { + 'name': 'Internal Review', + 'statuses': phases_matching('internal_review'), + }, + 'in-discussion': { + 'name': 'In Discussion', + 'statuses': phases_matching('discussion', exclude=[INITIAL_STATE, 'proposal_discussion']), + }, + 'more-information': { + 'name': 'More Information Requested', + 'statuses': phases_matching('more_info'), + }, + 'invited-for-proposal': { + 'name': 'Invited for proposal', + 'statuses': ['draft_proposal'], + }, + 'external-review': { + 'name': 'AC Review', + 'statuses': phases_matching('external_review'), + }, + 'ready-for-determination': { + 'name': 'Ready for determination', + 'statuses': phases_matching('determination'), + }, + 'accepted': { + 'name': 'Accepted', + 'statuses': phases_matching('accepted'), + }, + 'dismissed': { + 'name': 'Dismissed', + 'statuses': phases_matching('rejected'), + }, +} -- GitLab