diff --git a/opentech/apply/dashboard/templates/dashboard/dashboard.html b/opentech/apply/dashboard/templates/dashboard/dashboard.html index 4d740bb5a2913c88d2d29f25fccb3e41e39614ae..317b0414f0f385b65b58a2fa0cf4122f335ded34 100644 --- a/opentech/apply/dashboard/templates/dashboard/dashboard.html +++ b/opentech/apply/dashboard/templates/dashboard/dashboard.html @@ -23,29 +23,27 @@ <div class="wrapper wrapper--large wrapper--inner-space-medium"> - <!-- Example Stat Block markup - <div class="wrapper wrapper--bottom-space"> - <div class="stat-block"> - <a href="#" class="stat-block__item"> - <p class="stat-block__number">3</p> - <p class="stat-block__text">Submissions waiting for your review</p> - <div class="stat-block__view">View</div> - </a> - <a href="#" class="stat-block__item"> - <p class="stat-block__number">10</p> - <p class="stat-block__text">Live projects under your management</p> - <div class="stat-block__view">View</div> - </a> - <a href="#" class="stat-block__item"> - <p class="stat-block__number">4</p> - <p class="stat-block__text">Requests for payment requiring your attention</p> - <div class="stat-block__view">View</div> - </a> - </div> + <div class="wrapper wrapper--bottom-space"> + <div class="stat-block"> + <a href="#submissions-awaiting-review" class="stat-block__item"> + <p class="stat-block__number">{{ awaiting_reviews.count }}</p> + <p class="stat-block__text">Submissions waiting for your review</p> + <div class="stat-block__view">View</div> + </a> + <a href="#active-projects" class="stat-block__item"> + <p class="stat-block__number">{{ projects.count }}</p> + <p class="stat-block__text">Live projects under your management</p> + <div class="stat-block__view">View</div> + </a> + <a href="#active-payment-requests" class="stat-block__item"> + <p class="stat-block__number">{{ active_payment_requests.count }}</p> + <p class="stat-block__text">Requests for payment requiring your attention</p> + <div class="stat-block__view">View</div> + </a> </div> - --> + </div> - <div class="wrapper wrapper--bottom-space"> + <div id="submissions-awaiting-review" class="wrapper wrapper--bottom-space"> {% include "dashboard/includes/waiting-for-review.html" with in_review_count=awating_reviews.count my_review=awaiting_reviews.table display_more=awaiting_reviews.display_more active_statuses_filter=awaiting_reviews.active_statuses_filter %} </div> @@ -54,7 +52,7 @@ {% endif %} {% if projects.table.data %} - <div class="wrapper wrapper--bottom-space"> + <div id="active-projects" class="wrapper wrapper--bottom-space"> {% include "funds/includes/table_filter_and_search.html" with filter=projects.filterset filter_action=projects.url search_term=search_term search_action=projects.url search_placeholder="projects" use_search=True use_batch_actions=False heading="Your projects" %} {% render_table projects.table %} @@ -68,8 +66,8 @@ {% endif %} {% if active_payment_requests.table.data %} - <div class="wrapper wrapper--bottom-space"> - <h4 class="heading heading--normal heading--no-margin">Active Requests for Payment</h4> + <div id="active-payment-requests" class="wrapper wrapper--bottom-space"> + <h4 class="heading heading--normal">Active requests for payment</h4> {% render_table active_payment_requests.table %} </div> {% endif %} diff --git a/opentech/apply/dashboard/tests/test_views.py b/opentech/apply/dashboard/tests/test_views.py index f3f32b93fa6eafb900077acc3f9fe176bc68478b..c38cf2d86afecae2277303a185c0f41920bd6f6d 100644 --- a/opentech/apply/dashboard/tests/test_views.py +++ b/opentech/apply/dashboard/tests/test_views.py @@ -93,21 +93,21 @@ class TestStaffDashboard(BaseViewTestCase): def test_active_payment_requests_with_no_project(self): response = self.get_page() - self.assertNotContains(response, "Active Requests for Payment") + self.assertNotContains(response, "Active requests for payment") - def test_active_payment_requests_with_no_payment_requests(self): + def test_doesnt_show_active_payment_requests_with_none(self): ProjectFactory(lead=self.user) response = self.get_page() - self.assertNotContains(response, "Active Requests for Payment") + self.assertNotContains(response, "Active requests for payment") - def test_active_payment_requests_with_payment_requests_paid_or_declined(self): + def test_doest_show_active_payment_requests_when_paid_or_declined(self): project = ProjectFactory(lead=self.user) PaymentRequestFactory(project=project, status=PAID) PaymentRequestFactory(project=project, status=DECLINED) response = self.get_page() - self.assertNotContains(response, "Active Requests for Payment") + self.assertNotContains(response, "Active requests for payment") def test_active_payment_requests_with_payment_requests_in_correct_state(self): project = ProjectFactory(lead=self.user) @@ -116,7 +116,16 @@ class TestStaffDashboard(BaseViewTestCase): PaymentRequestFactory(project=project, status=UNDER_REVIEW) response = self.get_page() - self.assertContains(response, "Active Requests for Payment") + self.assertContains(response, "Active requests for payment") + + def test_doesnt_show_active_payment_requests_when_not_mine(self): + project = ProjectFactory() + PaymentRequestFactory(project=project, status=SUBMITTED) + PaymentRequestFactory(project=project, status=CHANGES_REQUESTED) + PaymentRequestFactory(project=project, status=UNDER_REVIEW) + + response = self.get_page() + self.assertNotContains(response, "Active requests for payment") class TestReviewerDashboard(BaseViewTestCase): diff --git a/opentech/apply/dashboard/views.py b/opentech/apply/dashboard/views.py index b7f7cd2dc19c17e043f2dd65bb24471d60a41e4a..58a959dd5cc43b4880c303a9296a00b1d168f3ff 100644 --- a/opentech/apply/dashboard/views.py +++ b/opentech/apply/dashboard/views.py @@ -48,6 +48,7 @@ class AdminDashboardView(TemplateView): ).in_progress() return { + 'count': payment_requests.count(), 'table': PaymentRequestsDashboardTable(payment_requests), } @@ -58,6 +59,7 @@ class AdminDashboardView(TemplateView): limit = 10 return { + 'count': projects.count(), 'filterset': filterset, 'table': ProjectsDashboardTable(projects[:limit]), 'display_more': projects.count() > limit,