From 536283e3dbbe6b549778d286401e08c6abeadff5 Mon Sep 17 00:00:00 2001 From: Christopher Charbonneau Wells Date: Thu, 24 Aug 2017 08:04:54 -0400 Subject: [PATCH] Handle dashboard redirect when there are no Child objects. --- dashboard/views.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/dashboard/views.py b/dashboard/views.py index 7ac9212b..5c5d5bf2 100644 --- a/dashboard/views.py +++ b/dashboard/views.py @@ -13,7 +13,11 @@ from core.models import Child class DashboardRedirect(LoginRequiredMixin, RedirectView): # Show the overall dashboard or a child dashboard if one Child instance. def get(self, request, *args, **kwargs): - if Child.objects.count() == 1: + children = Child.objects.count() + if children == 0: + # TODO: Create some sort of welcome page. + self.url = reverse('child-add') + elif children == 1: child_instance = Child.objects.first() self.url = reverse('dashboard-child', args={child_instance.slug}) else: