mirror of https://github.com/snachodog/mybuddy.git
Do not deal with child count during root redirect.
This commit is contained in:
parent
0a5ffed012
commit
ab2717ed56
|
@ -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/')
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue