diff --git a/opentech/apply/dashboard/templates/dashboard/dashboard.html b/opentech/apply/dashboard/templates/dashboard/dashboard.html index 18f0663643f4af289b6ffe0c5123f117f32c1803..7e223d712bdcd6920008907df8eb51078c950c5c 100644 --- a/opentech/apply/dashboard/templates/dashboard/dashboard.html +++ b/opentech/apply/dashboard/templates/dashboard/dashboard.html @@ -14,11 +14,22 @@ <div class="wrapper wrapper--large wrapper--inner-space-medium"> <div class="wrapper wrapper--large wrapper--inner-space-medium"> <h3>Applications to review</h3> - {% if table.data %} - {% render_table table %} + {% if in_review.data %} + {% render_table in_review %} {% else %} No reviews to complete {% endif %} </div> </div> + +<div class="wrapper wrapper--large wrapper--inner-space-medium"> + <div class="wrapper wrapper--large wrapper--inner-space-medium"> + <h3>Applications awaiting determination</h3> + {% if awaiting_determination.data %} + {% render_table awaiting_determination %} + {% else %} + No applications awaiting determination + {% endif %} + </div> +</div> {% endblock %} diff --git a/opentech/apply/dashboard/tests/test_views.py b/opentech/apply/dashboard/tests/test_views.py index ee4e3089e1525bda0b34d63b1f109311933cfabc..ccef259ff6f0f83a2e242ef2b442061b047d6e61 100644 --- a/opentech/apply/dashboard/tests/test_views.py +++ b/opentech/apply/dashboard/tests/test_views.py @@ -1,5 +1,5 @@ from opentech.apply.funds.tests.factories import ApplicationSubmissionFactory, ApplicationRevisionFactory -from opentech.apply.users.tests.factories import UserFactory +from opentech.apply.users.tests.factories import UserFactory, StaffFactory from opentech.apply.utils.tests import BaseViewTestCase @@ -46,3 +46,20 @@ class TestApplicantDashboard(BaseViewTestCase): response = self.get_page() self.assertNotContains(response, 'Edit') self.assertNotContains(response, 'Submission history') + + +class TestStaffDashboard(BaseViewTestCase): + user_factory = StaffFactory + url_name = 'dashboard:{}' + base_view_name = 'dashboard' + + def test_can_see_need_determinations(self): + ApplicationSubmissionFactory(status='concept_review_discussion', workflow_stages=2, lead=self.user, + form_data__title='Internet of things') + response = self.get_page() + self.assertContains(response, 'Internet of things') + + def test_cannot_see_submission_in_determination_when_not_lead(self): + ApplicationSubmissionFactory(status='concept_review_discussion', workflow_stages=2, form_data__title='Reviewr') + response = self.get_page() + self.assertNotContains(response, 'Reviewr') diff --git a/opentech/apply/dashboard/views.py b/opentech/apply/dashboard/views.py index 00be4cf44d33fdf015e995c7eb2a20284f6903fc..c044e4242d1ff67100060487927fce3c1cc9269b 100644 --- a/opentech/apply/dashboard/views.py +++ b/opentech/apply/dashboard/views.py @@ -1,17 +1,31 @@ +from django.shortcuts import render +from django.views.generic import TemplateView +from django_tables2 import RequestConfig from django_tables2.views import SingleTableView from opentech.apply.funds.models import ApplicationSubmission -from opentech.apply.funds.tables import SubmissionsTable +from opentech.apply.funds.tables import SubmissionsTable, AdminSubmissionsTable from opentech.apply.utils.views import ViewDispatcher -class AdminDashboardView(SingleTableView): - template_name = 'dashboard/dashboard.html' - model = ApplicationSubmission - table_class = SubmissionsTable +class AdminDashboardView(TemplateView): - def get_queryset(self): - return self.model.objects.in_review_for(self.request.user) + def get(self, request, *args, **kwargs): + qs = ApplicationSubmission.objects.all() + + in_review = SubmissionsTable(qs.in_review_for(request.user), prefix='in-review-') + RequestConfig(request, paginate={'per_page': 10}).configure(in_review) + + awaiting_determination = AdminSubmissionsTable( + qs.awaiting_determination_for(request.user), + prefix='pending-determination-' + ) + RequestConfig(request, paginate={'per_page': 10}).configure(awaiting_determination) + + return render(request, 'dashboard/dashboard.html', { + 'in_review': in_review, + 'awaiting_determination': awaiting_determination, + }) class ApplicantDashboardView(SingleTableView): diff --git a/opentech/apply/funds/models.py b/opentech/apply/funds/models.py index 69820493f54b97bde4829bbde1df4f11d0b0f402..0a5c39ec02ad187e1fcc49e2715e5d136fc54af1 100644 --- a/opentech/apply/funds/models.py +++ b/opentech/apply/funds/models.py @@ -48,6 +48,7 @@ from .workflow import ( UserPermissions, WORKFLOWS, DETERMINATION_PHASES, + DETERMINATION_RESPONSE_PHASES, ) LIMIT_TO_STAFF = {'groups__name': STAFF_GROUP_NAME} @@ -495,6 +496,9 @@ class ApplicationSubmissionQueryset(JSONOrderable): user_review_statuses = get_review_statuses(user) return self.filter(status__in=user_review_statuses).filter(reviewers=user).exclude(reviews__author=user) + def awaiting_determination_for(self, user): + return self.filter(status__in=DETERMINATION_RESPONSE_PHASES).filter(lead=user) + def current(self): # Applications which have the current stage active (have not been progressed) return self.exclude(next__isnull=False) diff --git a/opentech/apply/funds/workflow.py b/opentech/apply/funds/workflow.py index 6c49d722da8e0c9e484e332068d7a9684de42822..a82ea315cf032994274221be9654f9ffd625418d 100644 --- a/opentech/apply/funds/workflow.py +++ b/opentech/apply/funds/workflow.py @@ -403,6 +403,11 @@ def get_review_statuses(user=None): review_statuses = get_review_statuses() DETERMINATION_PHASES = list(phase_name for phase_name, _ in PHASES if '_discussion' in phase_name) +DETERMINATION_RESPONSE_PHASES = [ + 'post_review_discussion', + 'concept_review_discussion', + 'post_external_review_discussion', +] def get_determination_transitions():