diff --git a/tjdests/apps/destinations/tests.py b/tjdests/apps/destinations/tests.py index ddcb323..abede51 100644 --- a/tjdests/apps/destinations/tests.py +++ b/tjdests/apps/destinations/tests.py @@ -222,6 +222,7 @@ class DestinationsTest(TJDestsTestCase): self.assertEqual(1, response.context["object_list"].count()) self.assertIn(college, response.context["object_list"]) self.assertEqual(1, response.context["object_list"][0].count_decisions) + self.assertEqual(0, response.context["object_list"][0].count_attending) self.assertEqual(1, response.context["object_list"][0].count_admit) self.assertEqual(0, response.context["object_list"][0].count_waitlist) self.assertEqual(0, response.context["object_list"][0].count_waitlist_admit) @@ -242,17 +243,40 @@ class DestinationsTest(TJDestsTestCase): make_senior=True, publish_data=True, ) - Decision.objects.get_or_create( + decision = Decision.objects.get_or_create( college=college, user=user2, decision_type="ED", admission_status="WAITLIST_DENY", - ) + )[0] response = self.client.get(reverse("destinations:colleges")) self.assertEqual(200, response.status_code) self.assertEqual(1, response.context["object_list"].count()) self.assertIn(college, response.context["object_list"]) + self.assertEqual(0, response.context["object_list"][0].count_attending) + self.assertEqual(2, response.context["object_list"][0].count_decisions) + self.assertEqual(1, response.context["object_list"][0].count_admit) + self.assertEqual(0, response.context["object_list"][0].count_waitlist) + self.assertEqual(0, response.context["object_list"][0].count_waitlist_admit) + self.assertEqual(1, response.context["object_list"][0].count_waitlist_deny) + self.assertEqual(0, response.context["object_list"][0].count_defer) + self.assertEqual(0, response.context["object_list"][0].count_defer_admit) + self.assertEqual(0, response.context["object_list"][0].count_defer_deny) + self.assertEqual(0, response.context["object_list"][0].count_defer_wl) + self.assertEqual(0, response.context["object_list"][0].count_defer_wl_admit) + self.assertEqual(0, response.context["object_list"][0].count_defer_wl_deny) + self.assertEqual(0, response.context["object_list"][0].count_deny) + + # make user2 attend this college + user2.attending_decision = decision + user2.save() + + response = self.client.get(reverse("destinations:colleges")) + self.assertEqual(200, response.status_code) + self.assertEqual(1, response.context["object_list"].count()) + self.assertIn(college, response.context["object_list"]) + self.assertEqual(1, response.context["object_list"][0].count_attending) self.assertEqual(2, response.context["object_list"][0].count_decisions) self.assertEqual(1, response.context["object_list"][0].count_admit) self.assertEqual(0, response.context["object_list"][0].count_waitlist) diff --git a/tjdests/apps/destinations/views.py b/tjdests/apps/destinations/views.py index d869412..34bcf5e 100644 --- a/tjdests/apps/destinations/views.py +++ b/tjdests/apps/destinations/views.py @@ -91,6 +91,15 @@ class CollegeDestinationListView( count_decisions=Count( "decision", filter=Q(decision__user__publish_data=True) ), + count_attending=Count( + "decision", + filter=Q( + decision__in=Decision.objects.filter( + attending_college__isnull=False + ), + decision__user__publish_data=True, + ), + ), count_admit=Count( "decision", filter=Q( diff --git a/tjdests/templates/destinations/college_list.html b/tjdests/templates/destinations/college_list.html index 27ef343..f6eea86 100644 --- a/tjdests/templates/destinations/college_list.html +++ b/tjdests/templates/destinations/college_list.html @@ -39,6 +39,7 @@ <tr> <th scope="col">University Name, Location, CEEB code</th> <th scope="col">Total Applications</th> + <th scope="col">Attending</th> <th scope="col">Admitted</th> <th scope="col">Waitlisted</th> <th scope="col">Waitlist-Admitted</th> @@ -57,6 +58,7 @@ <tr> <th scope="row"><a href="{% url "destinations:students" %}?college={{ college.id }}">{{ college }}</a></th> <td>{{ college.count_decisions }}</td> + <td>{{ college.count_attending }}</td> <td>{{ college.count_admit }}</td> <td>{{ college.count_waitlist }}</td> <td>{{ college.count_waitlist_admit }}</td> @@ -83,6 +85,7 @@ <td></td> <td></td> <td></td> + <td></td> </tr> {% endfor %} </tbody>