From c947deb25b8f6312dc607e6ec8ec781e7d5df720 Mon Sep 17 00:00:00 2001
From: Erin Mullaney <erin.mullaney@torchbox.com>
Date: Tue, 22 Jan 2019 10:44:51 -0500
Subject: [PATCH] 810 test update

---
 .../templates/dashboard/dashboard.html        |  6 ++++
 opentech/apply/dashboard/views.py             | 14 +++++++-
 .../templates/funds/includes/round-block.html |  2 +-
 .../funds/templates/funds/submissions.html    |  2 +-
 .../funds/tests/models/test_roundsandlabs.py  |  1 +
 opentech/apply/funds/views.py                 | 33 +++++++++----------
 6 files changed, 37 insertions(+), 21 deletions(-)

diff --git a/opentech/apply/dashboard/templates/dashboard/dashboard.html b/opentech/apply/dashboard/templates/dashboard/dashboard.html
index de14c3cae..d0a54dca9 100644
--- a/opentech/apply/dashboard/templates/dashboard/dashboard.html
+++ b/opentech/apply/dashboard/templates/dashboard/dashboard.html
@@ -18,6 +18,11 @@
 </div>
 <div class="wrapper wrapper--large wrapper--inner-space-medium">
         <div class="wrapper wrapper--large wrapper--inner-space-medium">
+
+            {% if closed_rounds or open_rounds %}
+                {% include "funds/includes/round-block.html" with closed_rounds=closed_rounds open_rounds=open_rounds title=rounds_title %}
+            {% endif %}
+
             <h3>Applications to review</h3>
             {% if in_review.data %}
                 {% render_table in_review %}
@@ -30,4 +35,5 @@
 
 {% block extra_js %}
     <script src="{% static 'js/apply/submission-tooltips.js' %}"></script>
+    <script src="{% static 'js/apply/tabs.js' %}"></script>
 {% endblock %}
diff --git a/opentech/apply/dashboard/views.py b/opentech/apply/dashboard/views.py
index b8703e77d..22cba795c 100644
--- a/opentech/apply/dashboard/views.py
+++ b/opentech/apply/dashboard/views.py
@@ -3,7 +3,7 @@ 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.models import ApplicationSubmission, RoundsAndLabs
 from opentech.apply.funds.tables import SubmissionsTable, AdminSubmissionsTable
 from opentech.apply.utils.views import ViewDispatcher
 
@@ -15,9 +15,21 @@ class AdminDashboardView(TemplateView):
 
         in_review = SubmissionsTable(qs.in_review_for(request.user), prefix='in-review-')
         RequestConfig(request, paginate={'per_page': 10}).configure(in_review)
+        base_query = RoundsAndLabs.objects.with_progress().active().order_by('-end_date')
+        base_query = base_query.by_lead(request.user)
+        open_rounds = base_query.open()[:6]
+        open_query = '?round_state=open'
+        closed_rounds = base_query.closed()[:6]
+        closed_query = '?round_state=closed'
+        rounds_title = 'Your rounds and labs'
 
         return render(request, 'dashboard/dashboard.html', {
             'in_review': in_review,
+            'open_rounds': open_rounds,
+            'open_query': open_query,
+            'closed_rounds': closed_rounds,
+            'closed_query': closed_query,
+            'rounds_title': rounds_title,
         })
 
 
diff --git a/opentech/apply/funds/templates/funds/includes/round-block.html b/opentech/apply/funds/templates/funds/includes/round-block.html
index 56614a4a9..98efb329f 100644
--- a/opentech/apply/funds/templates/funds/includes/round-block.html
+++ b/opentech/apply/funds/templates/funds/includes/round-block.html
@@ -1,6 +1,6 @@
 <div class="wrapper wrapper--bottom-space">
     <section class="section section--with-options">
-        <h4 class="heading heading--normal heading--no-margin">Your Rounds and Labs</h4>
+        <h4 class="heading heading--normal heading--no-margin">{{ title }}</h4>
         <div class="js-tabs">
             <a class="tab__item tab__item--alt" href="#closed-rounds" data-tab="tab-1">Closed</a>
             <a class="tab__item tab__item--alt" href="#open-rounds" data-tab="tab-2">Open</a>
diff --git a/opentech/apply/funds/templates/funds/submissions.html b/opentech/apply/funds/templates/funds/submissions.html
index 6c938d529..ca7088047 100644
--- a/opentech/apply/funds/templates/funds/submissions.html
+++ b/opentech/apply/funds/templates/funds/submissions.html
@@ -16,7 +16,7 @@
 <div class="wrapper wrapper--large wrapper--inner-space-medium">
 
     {% if closed_rounds or open_rounds %}
-        {% include "funds/includes/round-block.html" with closed_rounds=closed_rounds open_rounds=open_rounds %}
+        {% include "funds/includes/round-block.html" with closed_rounds=closed_rounds open_rounds=open_rounds title=rounds_title %}
     {% endif %}
 
     {% block table %}
diff --git a/opentech/apply/funds/tests/models/test_roundsandlabs.py b/opentech/apply/funds/tests/models/test_roundsandlabs.py
index 4d78ed346..a41aa0456 100644
--- a/opentech/apply/funds/tests/models/test_roundsandlabs.py
+++ b/opentech/apply/funds/tests/models/test_roundsandlabs.py
@@ -77,6 +77,7 @@ class BaseRoundsAndLabTestCase:
         self.assertEqual(qs_all.count(), 2)
         self.assertEqual(qs_by_lead.count(), 1)
         self.assertEqual(fetched_obj.lead, obj.lead.full_name)
+        self.assertNotEqual(round_other_lead.title, fetched_obj.title)
 
 
 class TestForLab(BaseRoundsAndLabTestCase, TestCase):
diff --git a/opentech/apply/funds/views.py b/opentech/apply/funds/views.py
index b7c786c28..b3928ac67 100644
--- a/opentech/apply/funds/views.py
+++ b/opentech/apply/funds/views.py
@@ -89,24 +89,21 @@ class SubmissionOverviewView(AllActivityContextMixin, BaseAdminSubmissionsTable)
         return super().get_table_data().order_by(F('last_update').desc(nulls_last=True))[:5]
 
     def get_context_data(self, **kwargs):
-        # For OTF staff, display rounds/labs where user is the lead
-        if self.request.user.is_staff:
-            base_query = RoundsAndLabs.objects.with_progress().active().order_by('-end_date')
-            base_query = base_query.by_lead(self.request.user)
-            open_rounds = base_query.open()[:6]
-            open_query = '?round_state=open'
-            closed_rounds = base_query.closed()[:6]
-            closed_query = '?round_state=closed'
-
-            return super().get_context_data(
-                open_rounds=open_rounds,
-                open_query=open_query,
-                closed_rounds=closed_rounds,
-                closed_query=closed_query,
-                **kwargs,
-            )
-        else:
-            return super().get_context_data(**kwargs)
+        base_query = RoundsAndLabs.objects.with_progress().active().order_by('-end_date')
+        open_rounds = base_query.open()[:6]
+        open_query = '?round_state=open'
+        closed_rounds = base_query.closed()[:6]
+        closed_query = '?round_state=closed'
+        rounds_title = 'All Rounds and Labs'
+
+        return super().get_context_data(
+            open_rounds=open_rounds,
+            open_query=open_query,
+            closed_rounds=closed_rounds,
+            closed_query=closed_query,
+            rounds_title=rounds_title,
+            **kwargs,
+        )
 
 
 class SubmissionListView(AllActivityContextMixin, BaseAdminSubmissionsTable):
-- 
GitLab