Do not deal with child count during root redirect.

This commit is contained in:
Christopher Charbonneau Wells 2018-05-20 08:54:28 -07:00
parent 0a5ffed012
commit ab2717ed56
2 changed files with 1 additions and 26 deletions

View File

@ -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/')

View File

@ -26,15 +26,6 @@ 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')
return super(RootRouter, self).get_redirect_url(self, *args, **kwargs)