From ab2717ed56ee5631486884ae1a8393504d79e279 Mon Sep 17 00:00:00 2001 From: Christopher Charbonneau Wells Date: Sun, 20 May 2018 08:54:28 -0700 Subject: [PATCH] Do not deal with child count during root redirect. --- babybuddy/tests/tests_views.py | 16 ---------------- babybuddy/views.py | 11 +---------- 2 files changed, 1 insertion(+), 26 deletions(-) diff --git a/babybuddy/tests/tests_views.py b/babybuddy/tests/tests_views.py index 9381bae7..1063eda6 100644 --- a/babybuddy/tests/tests_views.py +++ b/babybuddy/tests/tests_views.py @@ -6,8 +6,6 @@ from django.core.management import call_command from faker import Factory -from core.models import Child - class ViewsTestCase(TestCase): @classmethod @@ -29,20 +27,6 @@ class ViewsTestCase(TestCase): cls.c.login(**cls.credentials) def test_root_router(self): - page = self.c.get('/') - self.assertEqual(page.url, '/welcome/') - - call_command('fake', verbosity=0, children=1, days=1) - child = Child.objects.first() - page = self.c.get('/') - self.assertEqual( - page.url, '/children/{}/dashboard/'.format(child.slug)) - - Child.objects.create( - first_name='Second', - last_name='Child', - birth_date='2000-01-01' - ) page = self.c.get('/') self.assertEqual(page.url, '/dashboard/') diff --git a/babybuddy/views.py b/babybuddy/views.py index 64f9f9b9..e138db64 100644 --- a/babybuddy/views.py +++ b/babybuddy/views.py @@ -26,16 +26,7 @@ class RootRouter(LoginRequiredMixin, RedirectView): more than one child is in the database. """ def get_redirect_url(self, *args, **kwargs): - children = models.Child.objects.count() - if children == 0: - self.url = reverse('babybuddy:welcome') - elif children == 1: - self.url = reverse( - 'dashboard:dashboard-child', - args={models.Child.objects.first().slug} - ) - else: - self.url = reverse('dashboard:dashboard') + self.url = reverse('dashboard:dashboard') return super(RootRouter, self).get_redirect_url(self, *args, **kwargs)