mirror of
https://github.com/etnguyen03/tjdests.git
synced 2025-04-20 17:50:16 -04:00
feat(destinations): add count attending to college list
This commit is contained in:
parent
52d3276f45
commit
efc7786916
|
@ -222,6 +222,7 @@ class DestinationsTest(TJDestsTestCase):
|
||||||
self.assertEqual(1, response.context["object_list"].count())
|
self.assertEqual(1, response.context["object_list"].count())
|
||||||
self.assertIn(college, response.context["object_list"])
|
self.assertIn(college, response.context["object_list"])
|
||||||
self.assertEqual(1, response.context["object_list"][0].count_decisions)
|
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(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)
|
||||||
self.assertEqual(0, response.context["object_list"][0].count_waitlist_admit)
|
self.assertEqual(0, response.context["object_list"][0].count_waitlist_admit)
|
||||||
|
@ -242,17 +243,40 @@ class DestinationsTest(TJDestsTestCase):
|
||||||
make_senior=True,
|
make_senior=True,
|
||||||
publish_data=True,
|
publish_data=True,
|
||||||
)
|
)
|
||||||
Decision.objects.get_or_create(
|
decision = Decision.objects.get_or_create(
|
||||||
college=college,
|
college=college,
|
||||||
user=user2,
|
user=user2,
|
||||||
decision_type="ED",
|
decision_type="ED",
|
||||||
admission_status="WAITLIST_DENY",
|
admission_status="WAITLIST_DENY",
|
||||||
)
|
)[0]
|
||||||
|
|
||||||
response = self.client.get(reverse("destinations:colleges"))
|
response = self.client.get(reverse("destinations:colleges"))
|
||||||
self.assertEqual(200, response.status_code)
|
self.assertEqual(200, response.status_code)
|
||||||
self.assertEqual(1, response.context["object_list"].count())
|
self.assertEqual(1, response.context["object_list"].count())
|
||||||
self.assertIn(college, response.context["object_list"])
|
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(2, response.context["object_list"][0].count_decisions)
|
||||||
self.assertEqual(1, response.context["object_list"][0].count_admit)
|
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)
|
||||||
|
|
|
@ -91,6 +91,15 @@ class CollegeDestinationListView(
|
||||||
count_decisions=Count(
|
count_decisions=Count(
|
||||||
"decision", filter=Q(decision__user__publish_data=True)
|
"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(
|
count_admit=Count(
|
||||||
"decision",
|
"decision",
|
||||||
filter=Q(
|
filter=Q(
|
||||||
|
|
|
@ -39,6 +39,7 @@
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="col">University Name, Location, CEEB code</th>
|
<th scope="col">University Name, Location, CEEB code</th>
|
||||||
<th scope="col">Total Applications</th>
|
<th scope="col">Total Applications</th>
|
||||||
|
<th scope="col">Attending</th>
|
||||||
<th scope="col">Admitted</th>
|
<th scope="col">Admitted</th>
|
||||||
<th scope="col">Waitlisted</th>
|
<th scope="col">Waitlisted</th>
|
||||||
<th scope="col">Waitlist-Admitted</th>
|
<th scope="col">Waitlist-Admitted</th>
|
||||||
|
@ -57,6 +58,7 @@
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row"><a href="{% url "destinations:students" %}?college={{ college.id }}">{{ college }}</a></th>
|
<th scope="row"><a href="{% url "destinations:students" %}?college={{ college.id }}">{{ college }}</a></th>
|
||||||
<td>{{ college.count_decisions }}</td>
|
<td>{{ college.count_decisions }}</td>
|
||||||
|
<td>{{ college.count_attending }}</td>
|
||||||
<td>{{ college.count_admit }}</td>
|
<td>{{ college.count_admit }}</td>
|
||||||
<td>{{ college.count_waitlist }}</td>
|
<td>{{ college.count_waitlist }}</td>
|
||||||
<td>{{ college.count_waitlist_admit }}</td>
|
<td>{{ college.count_waitlist_admit }}</td>
|
||||||
|
@ -83,6 +85,7 @@
|
||||||
<td></td>
|
<td></td>
|
||||||
<td></td>
|
<td></td>
|
||||||
<td></td>
|
<td></td>
|
||||||
|
<td></td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user