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 0000000000000000000000000000000000000000..7d2780fd1e94afb9c2fb3327d2e6c1d585ac01ea --- /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 81201c44900225ab1669dca0f76800b129a9e6fd..1339981cb6d580370ce1a101dc5e736e244fa04c 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 b3928ac67b89162bdc74a3e49385276cca750266..6ae3dce929dd63075a423bc4d87d037ceb4814f6 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 39cb99ecd230dee979b823c34a8be8502f15e542..53148659fad96bfff4921bd2b3a87b488707a18b 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'), + }, +}