diff --git a/babybuddy/templates/babybuddy/welcome.html b/babybuddy/templates/babybuddy/welcome.html
new file mode 100644
index 00000000..3f45aa95
--- /dev/null
+++ b/babybuddy/templates/babybuddy/welcome.html
@@ -0,0 +1,69 @@
+{% extends 'babybuddy/page.html' %}
+{% load widget_tweaks %}
+
+{% block title %}Welcome!{% endblock %}
+
+{% block breadcrumbs %}
+
Welcome!
+{% endblock %}
+
+{% block content %}
+
+
Welcome to Baby Buddy!
+
+ Learn about and predict baby's needs without (as much)
+ guess work by using Baby Buddy to track —
+
+
+
+
+
+ As the amount of entries grows, Baby Buddy will help
+ parents and caregivers to identify small patterns in baby's habits
+ using the dashboard and graphs. Baby Buddy is mobile-friendly and
+ uses a dark theme to help weary moms and dads with 2AM feedings and
+ changings. To get started, just click the button below to add your
+ first (or second, third, etc.) child!
+
+
+ {% if perms.core.add_child %}
+
+ Add a Child
+
+ {% endif %}
+
+
+{% endblock %}
\ No newline at end of file
diff --git a/babybuddy/tests/__init__.py b/babybuddy/tests/__init__.py
new file mode 100644
index 00000000..e69de29b
diff --git a/babybuddy/tests/tests_views.py b/babybuddy/tests/tests_views.py
new file mode 100644
index 00000000..bf048202
--- /dev/null
+++ b/babybuddy/tests/tests_views.py
@@ -0,0 +1,49 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.test import TestCase
+from django.test import Client as HttpClient
+from django.contrib.auth.models import User
+from django.core.management import call_command
+
+from faker import Factory
+
+from core.models import Child
+
+
+class ViewsTestCase(TestCase):
+ @classmethod
+ def setUpClass(cls):
+ super(ViewsTestCase, cls).setUpClass()
+ fake = Factory.create()
+ call_command('migrate', verbosity=0)
+
+ cls.c = HttpClient()
+
+ fake_user = fake.simple_profile()
+ cls.credentials = {
+ 'username': fake_user['username'],
+ 'password': fake.password()
+ }
+ cls.user = User.objects.create_user(
+ is_superuser=True, **cls.credentials)
+
+ 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/urls.py b/babybuddy/urls.py
index 66d01cca..8297db65 100644
--- a/babybuddy/urls.py
+++ b/babybuddy/urls.py
@@ -3,16 +3,21 @@ from __future__ import unicode_literals
from django.conf.urls import url, include
from django.contrib import admin
-from django.contrib.auth import views
+from django.contrib.auth import views as auth_views
+
+from . import views
urlpatterns = [
url(r'^admin/', admin.site.urls),
- url(r'^login/$', views.LoginView.as_view(), name='login'),
- url(r'^logout/$', views.LogoutView.as_view(), name='logout'),
- url('^password_reset/$', views.PasswordResetView.as_view(),
+ url(r'^login/$', auth_views.LoginView.as_view(), name='login'),
+ url(r'^logout/$', auth_views.LogoutView.as_view(), name='logout'),
+ url('^password_reset/$', auth_views.PasswordResetView.as_view(),
name='password_reset',),
+ url(r'^$', views.RootRouter.as_view(), name='root-router'),
+ url(r'^welcome/$', views.Welcome.as_view(), name='welcome'),
+
url(r'', include('api.urls', namespace='api')),
url(r'', include('core.urls')),
url(r'', include('dashboard.urls')),
diff --git a/babybuddy/views.py b/babybuddy/views.py
new file mode 100644
index 00000000..0bab8eff
--- /dev/null
+++ b/babybuddy/views.py
@@ -0,0 +1,25 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.contrib.auth.mixins import LoginRequiredMixin
+from django.urls import reverse
+from django.views.generic.base import TemplateView, RedirectView
+
+from core.models import Child
+
+
+class RootRouter(LoginRequiredMixin, RedirectView):
+ def get_redirect_url(self, *args, **kwargs):
+ children = Child.objects.count()
+ if children == 0:
+ self.url = reverse('welcome')
+ elif children == 1:
+ self.url = reverse(
+ 'dashboard-child', args={Child.objects.first().slug})
+ else:
+ self.url = reverse('dashboard')
+ return super(RootRouter, self).get_redirect_url(self, *args, **kwargs)
+
+
+class Welcome(LoginRequiredMixin, TemplateView):
+ template_name = 'babybuddy/welcome.html'
diff --git a/dashboard/tests/tests_views.py b/dashboard/tests/tests_views.py
index 99547c35..5e30e5ef 100644
--- a/dashboard/tests/tests_views.py
+++ b/dashboard/tests/tests_views.py
@@ -31,12 +31,8 @@ class ViewsTestCase(TestCase):
cls.c.login(**cls.credentials)
def test_dashboard_views(self):
- """Dashboard handles the root URL and redirects based on zero, one, or
- more than one child is in the database."""
- page = self.c.get('/')
- self.assertEqual(page.url, '/dashboard/')
page = self.c.get('/dashboard/')
- self.assertEqual(page.url, '/children/add/')
+ self.assertEqual(page.url, '/welcome/')
call_command('fake', verbosity=0, children=1, days=1)
child = Child.objects.first()
diff --git a/dashboard/urls.py b/dashboard/urls.py
index 08170143..f9337683 100644
--- a/dashboard/urls.py
+++ b/dashboard/urls.py
@@ -6,7 +6,6 @@ from django.conf.urls import url
from . import views
urlpatterns = [
- url(r'^$', views.DashboardRedirect.as_view(), name='dashboard-redirect'),
url(r'^dashboard/$', views.Dashboard.as_view(), name='dashboard'),
url(r'^children/(?P[^/.]+)/dashboard/$',
views.ChildDashboard.as_view(), name='dashboard-child'),
diff --git a/dashboard/views.py b/dashboard/views.py
index 9eee8a70..6a331cd5 100644
--- a/dashboard/views.py
+++ b/dashboard/views.py
@@ -5,16 +5,12 @@ from django.contrib.auth.mixins import (LoginRequiredMixin,
PermissionRequiredMixin)
from django.http import HttpResponseRedirect
from django.urls import reverse
-from django.views.generic.base import TemplateView, RedirectView
+from django.views.generic.base import TemplateView
from django.views.generic.detail import DetailView
from core.models import Child
-class DashboardRedirect(LoginRequiredMixin, RedirectView):
- url = '/dashboard/'
-
-
class Dashboard(LoginRequiredMixin, TemplateView):
# TODO: Use .card-deck in this template once BS4 is finalized.
template_name = 'dashboard/dashboard.html'
@@ -23,8 +19,7 @@ class Dashboard(LoginRequiredMixin, TemplateView):
def get(self, request, *args, **kwargs):
children = Child.objects.count()
if children == 0:
- # TODO: Create some sort of welcome page.
- return HttpResponseRedirect(reverse('child-add'))
+ return HttpResponseRedirect(reverse('welcome'))
elif children == 1:
return HttpResponseRedirect(
reverse('dashboard-child', args={Child.objects.first().slug}))