Misc. Django 2.0 update changes.

This commit is contained in:
Christopher Charbonneau Wells 2017-12-03 16:52:27 -05:00
parent 44d8cd6db3
commit e92d3f361e
45 changed files with 152 additions and 127 deletions

View File

@ -6,7 +6,6 @@ from rest_framework import routers
from . import views
router = routers.DefaultRouter()
router.register(r'children', views.ChildViewSet)
router.register(r'changes', views.DiaperChangeViewSet)
@ -17,6 +16,8 @@ router.register(r'timers', views.TimerViewSet)
router.register(r'tummy-times', views.TummyTimeViewSet)
router.register(r'weight', views.WeightViewSet)
app_name = 'api'
urlpatterns = [
url(r'^api/', include(router.urls)),
url(r'^api/auth/', include('rest_framework.urls',

View File

@ -9,7 +9,7 @@ from django.utils.timezone import timedelta
class Settings(models.Model):
user = models.OneToOneField(User)
user = models.OneToOneField(User, on_delete=models.CASCADE)
dashboard_refresh_rate = models.DurationField(
verbose_name='Refresh rate',
blank=True,

View File

@ -6,7 +6,7 @@
<a class="navbar-brand" href="/"><span class="text-info">Baby</span> Buddy</a>
<div class="d-lg-none d-md-none ml-auto p-0 mr-2">
<a class="text-success mr-2" href="{% url 'timer-add-quick' %}"><i class="icon icon-2x icon-timer" aria-hidden="true"></i></a>
<a class="text-success mr-2" href="{% url 'core:timer-add-quick' %}"><i class="icon icon-2x icon-timer" aria-hidden="true"></i></a>
<div class="dropdown show d-inline">
<a class="text-success"
href="#"
@ -19,32 +19,32 @@
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="nav-quick-add-link">
{% if perms.core.add_diaperchange %}
<a class="dropdown-item p-2" href="{% url 'diaperchange-add' %}">
<a class="dropdown-item p-2" href="{% url 'core:diaperchange-add' %}">
<i class="icon icon-diaperchange" aria-hidden="true"></i> Diaper Change
</a>
{% endif %}
{% if perms.core.add_feeding %}
<a class="dropdown-item p-2" href="{% url 'feeding-add' %}">
<a class="dropdown-item p-2" href="{% url 'core:feeding-add' %}">
<i class="icon icon-feeding" aria-hidden="true"></i> Feeding
</a>
{% endif %}
{% if perms.core.add_note %}
<a class="dropdown-item p-2" href="{% url 'note-add' %}">
<a class="dropdown-item p-2" href="{% url 'core:note-add' %}">
<i class="icon icon-note" aria-hidden="true"></i> Note
</a>
{% endif %}
{% if perms.core.add_sleep %}
<a class="dropdown-item p-2" href="{% url 'sleep-add' %}">
<a class="dropdown-item p-2" href="{% url 'core:sleep-add' %}">
<i class="icon icon-sleep" aria-hidden="true"></i> Sleep
</a>
{% endif %}
{% if perms.core.add_tummytime %}
<a class="dropdown-item p-2" href="{% url 'tummytime-add' %}">
<a class="dropdown-item p-2" href="{% url 'core:tummytime-add' %}">
<i class="icon icon-tummytime" aria-hidden="true"></i> Tummy Time
</a>
{% endif %}
{% if perms.core.add_weight %}
<a class="dropdown-item p-2" href="{% url 'weight-add' %}">
<a class="dropdown-item p-2" href="{% url 'core:weight-add' %}">
<i class="icon icon-weight" aria-hidden="true"></i> Weight
</a>
{% endif %}
@ -62,7 +62,7 @@
<div class="collapse navbar-collapse" id="navbar-app">
<ul class="navbar-nav mr-auto">
<li class="nav-item{% if request.path == '/' %} active{% endif %}">
<a class="nav-link" href="{% url 'dashboard' %}">
<a class="nav-link" href="{% url 'dashboard:dashboard' %}">
<i class="icon icon-dashboard" aria-hidden="true"></i> Dashboard
</a>
</li>
@ -77,33 +77,36 @@
<div class="dropdown-menu" aria-labelledby="nav-children-menu-link">
{% if perms.core.view_child %}
<a class="dropdown-item{% if request.path == '/children/' %} active{% endif %}" href="{% url 'child-list' %}">
<a class="dropdown-item{% if request.path == '/children/' %} active{% endif %}"
href="{% url 'core:child-list' %}">
<i class="icon icon-child" aria-hidden="true"></i> Children
</a>
{% endif %}
{% if perms.core.add_child %}
<a class="dropdown-item pl-5{% if request.path == '/children/add/' %} active{% endif %}"
href="{% url 'child-add' %}"><i class="icon icon-add" aria-hidden="true"></i> Child</a>
href="{% url 'core:child-add' %}"><i class="icon icon-add" aria-hidden="true"></i> Child</a>
{% endif %}
{% if perms.core.view_note %}
<a class="dropdown-item{% if request.path == '/notes/' %} active{% endif %}" href="{% url 'note-list' %}">
<a class="dropdown-item{% if request.path == '/notes/' %} active{% endif %}"
href="{% url 'core:note-list' %}">
<i class="icon icon-note" aria-hidden="true"></i> Notes
</a>
{% endif %}
{% if perms.core.add_note %}
<a class="dropdown-item pl-5{% if request.path == '/notes/add/' %} active{% endif %}"
href="{% url 'note-add' %}"><i class="icon icon-add" aria-hidden="true"></i> Note</a>
href="{% url 'core:note-add' %}"><i class="icon icon-add" aria-hidden="true"></i> Note</a>
{% endif %}
{% if perms.core.view_weight %}
<a class="dropdown-item{% if request.path == '/weight/' %} active{% endif %}" href="{% url 'weight-list' %}">
<a class="dropdown-item{% if request.path == '/weight/' %} active{% endif %}"
href="{% url 'core:weight-list' %}">
<i class="icon icon-weight" aria-hidden="true"></i> Weight
</a>
{% endif %}
{% if perms.core.add_weight %}
<a class="dropdown-item pl-5{% if request.path == '/weight/add/' %} active{% endif %}"
href="{% url 'weight-add' %}"><i class="icon icon-add" aria-hidden="true"></i> Weight entry</a>
href="{% url 'core:weight-add' %}"><i class="icon icon-add" aria-hidden="true"></i> Weight entry</a>
{% endif %}
</div>
@ -120,38 +123,38 @@
{% if perms.core.view_diaperchange %}
<a class="dropdown-item{% if request.path == '/changes/' %} active{% endif %}"
href="{% url 'diaperchange-list' %}"><i class="icon icon-diaperchange" aria-hidden="true"></i> Changes</a>
href="{% url 'core:diaperchange-list' %}"><i class="icon icon-diaperchange" aria-hidden="true"></i> Changes</a>
{% endif %}
{% if perms.core.add_diaperchange %}
<a class="dropdown-item pl-5{% if request.path == '/changes/add/' %} active{% endif %}"
href="{% url 'diaperchange-add' %}"><i class="icon icon-add" aria-hidden="true"></i> Change</a>
href="{% url 'core:diaperchange-add' %}"><i class="icon icon-add" aria-hidden="true"></i> Change</a>
{% endif %}
{% if perms.core.view_feeding %}
<a class="dropdown-item{% if request.path == '/feedings/' %} active{% endif %}"
href="{% url 'feeding-list' %}"><i class="icon icon-feeding" aria-hidden="true"></i> Feedings</a>
href="{% url 'core:feeding-list' %}"><i class="icon icon-feeding" aria-hidden="true"></i> Feedings</a>
{% endif %}
{% if perms.core.add_diaperchange %}
<a class="dropdown-item pl-5{% if request.path == '/feedings/add/' %} active{% endif %}"
href="{% url 'feeding-add' %}"><i class="icon icon-add" aria-hidden="true"></i> Feeding</a>
href="{% url 'core:feeding-add' %}"><i class="icon icon-add" aria-hidden="true"></i> Feeding</a>
{% endif %}
{% if perms.core.view_sleep %}
<a class="dropdown-item{% if request.path == '/sleep/' %} active{% endif %}"
href="{% url 'sleep-list' %}"><i class="icon icon-sleep" aria-hidden="true"></i> Sleep</a>
href="{% url 'core:sleep-list' %}"><i class="icon icon-sleep" aria-hidden="true"></i> Sleep</a>
{% endif %}
{% if perms.core.add_sleep %}
<a class="dropdown-item pl-5{% if request.path == '/sleep/add/' %} active{% endif %}"
href="{% url 'sleep-add' %}"><i class="icon icon-add" aria-hidden="true"></i> Sleep entry</a>
href="{% url 'core:sleep-add' %}"><i class="icon icon-add" aria-hidden="true"></i> Sleep entry</a>
{% endif %}
{% if perms.core.view_tummytime %}
<a class="dropdown-item{% if request.path == '/tummy-time/' %} active{% endif %}"
href="{% url 'tummytime-list' %}"><i class="icon icon-tummytime" aria-hidden="true"></i> Tummy Time</a>
href="{% url 'core:tummytime-list' %}"><i class="icon icon-tummytime" aria-hidden="true"></i> Tummy Time</a>
{% endif %}
{% if perms.core.add_tummytime %}
<a class="dropdown-item pl-5{% if request.path == '/tummy-time/add/' %} active{% endif %}"
href="{% url 'tummytime-add' %}"><i class="icon icon-add" aria-hidden="true"></i> Tummy Time entry</a>
href="{% url 'core:tummytime-add' %}"><i class="icon icon-add" aria-hidden="true"></i> Tummy Time entry</a>
{% endif %}
</div>
@ -174,9 +177,9 @@
</a>
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="nav-user-menu-link">
<h6 class="dropdown-header">User</h6>
<a href="{% url 'user-settings' %}" class="dropdown-item">Settings</a>
<a href="{% url 'user-password' %}" class="dropdown-item">Password</a>
<a href="{% url 'logout' %}" class="dropdown-item">Logout</a>
<a href="{% url 'babybuddy:user-settings' %}" class="dropdown-item">Settings</a>
<a href="{% url 'babybuddy:user-password' %}" class="dropdown-item">Password</a>
<a href="{% url 'babybuddy:logout' %}" class="dropdown-item">Logout</a>
<h6 class="dropdown-header">Site</h6>
<a href="{% url 'api:api-root' %}"
class="dropdown-item"

View File

@ -60,7 +60,7 @@
</p>
<p class="text-center">
{% if perms.core.add_child %}
<a href="{% url 'child-add' %}" class="btn btn-lg btn-success">
<a href="{% url 'core:child-add' %}" class="btn btn-lg btn-success">
<i class="icon icon-child" aria-hidden="true"></i> Add a Child
</a>
{% endif %}

View File

@ -3,7 +3,7 @@
{% block title %}Login{% endblock %}
{% block content %}
<form class="login-form" method="post" action="{% url 'login' %}">
<form class="login-form" method="post" action="{% url 'babybuddy:login' %}">
{% csrf_token %}
<input type="hidden" name="next" value="{{ next }}">
@ -34,6 +34,7 @@
</form>
<div class="bg-faded text-center px-4 py-3 rounded-bottom">
<a href="{% url 'password_reset' %}" name="reset">Forgot your password?</a>
<a href="{% url 'babybuddy:password_reset' %}" name="reset">
Forgot your password?</a>
</div>
{% endblock %}

View File

@ -9,9 +9,7 @@ from django.contrib.auth import views as auth_views
from . import views
urlpatterns = [
url(r'^admin/', admin.site.urls),
babybuddy_patterns = [
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(),
@ -23,10 +21,14 @@ urlpatterns = [
name='user-settings'),
url(r'^user/password/$', views.UserPassword.as_view(),
name='user-password'),
]
urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'', include('api.urls', namespace='api')),
url(r'', include('core.urls')),
url(r'', include('dashboard.urls')),
url(r'', include((babybuddy_patterns, 'babybuddy'), namespace='babybuddy')),
url(r'', include('core.urls', namespace='core')),
url(r'', include('dashboard.urls', namespace='dashboard')),
url(r'', include('reports.urls', namespace='reports')),
]

View File

@ -23,12 +23,12 @@ class RootRouter(LoginRequiredMixin, RedirectView):
def get_redirect_url(self, *args, **kwargs):
children = Child.objects.count()
if children == 0:
self.url = reverse('welcome')
self.url = reverse('babybuddy:welcome')
elif children == 1:
self.url = reverse(
'dashboard-child', args={Child.objects.first().slug})
'dashboard:dashboard-child', args={Child.objects.first().slug})
else:
self.url = reverse('dashboard')
self.url = reverse('dashboard:dashboard')
return super(RootRouter, self).get_redirect_url(self, *args, **kwargs)
@ -81,7 +81,7 @@ class UserSettings(LoginRequiredMixin, View):
user_settings = form_settings.save(commit=False)
user.settings = user_settings
user.save()
return redirect('user-settings')
return redirect('babybuddy:user-settings')
return render(request, self.template_name, {
'user_form': form_user,
'settings_form': form_settings

View File

@ -104,7 +104,8 @@ class Child(models.Model):
class DiaperChange(models.Model):
model_name = 'diaperchange'
child = models.ForeignKey('Child', related_name='diaper_change')
child = models.ForeignKey(
'Child', related_name='diaper_change', on_delete=models.CASCADE)
time = models.DateTimeField(blank=False, null=False)
wet = models.BooleanField()
solid = models.BooleanField()
@ -151,7 +152,8 @@ class DiaperChange(models.Model):
class Feeding(models.Model):
model_name = 'feeding'
child = models.ForeignKey('Child', related_name='feeding')
child = models.ForeignKey(
'Child', related_name='feeding', on_delete=models.CASCADE)
start = models.DateTimeField(blank=False, null=False)
end = models.DateTimeField(blank=False, null=False)
duration = models.DurationField(null=True, editable=False)
@ -196,7 +198,8 @@ class Feeding(models.Model):
class Note(models.Model):
model_name = 'note'
child = models.ForeignKey('Child', related_name='note')
child = models.ForeignKey(
'Child', related_name='note', on_delete=models.CASCADE)
note = models.TextField()
time = models.DateTimeField(auto_now=True)
@ -218,7 +221,8 @@ class NapsManager(models.Manager):
class Sleep(models.Model):
model_name = 'sleep'
child = models.ForeignKey('Child', related_name='sleep')
child = models.ForeignKey(
'Child', related_name='sleep', on_delete=models.CASCADE)
start = models.DateTimeField(blank=False, null=False)
end = models.DateTimeField(blank=False, null=False)
duration = models.DurationField(null=True, editable=False)
@ -266,7 +270,8 @@ class Timer(models.Model):
end = models.DateTimeField(blank=True, null=True, editable=False)
duration = models.DurationField(null=True, editable=False)
active = models.BooleanField(default=True, editable=False)
user = models.ForeignKey('auth.User', related_name='timers')
user = models.ForeignKey(
'auth.User', related_name='timers', on_delete=models.CASCADE)
objects = models.Manager()
@ -317,7 +322,8 @@ class Timer(models.Model):
class TummyTime(models.Model):
model_name = 'tummytime'
child = models.ForeignKey('Child', related_name='tummy_time')
child = models.ForeignKey(
'Child', related_name='tummy_time', on_delete=models.CASCADE)
start = models.DateTimeField(blank=False, null=False)
end = models.DateTimeField(blank=False, null=False)
duration = models.DurationField(null=True, editable=False)
@ -347,7 +353,8 @@ class TummyTime(models.Model):
class Weight(models.Model):
model_name = 'weight'
child = models.ForeignKey('Child', related_name='weight')
child = models.ForeignKey(
'Child', related_name='weight', on_delete=models.CASCADE)
weight = models.FloatField(blank=False, null=False)
date = models.DateField(blank=False, null=False)

View File

@ -4,8 +4,8 @@
{% block title %}Delete a Child{% endblock %}
{% block breadcrumbs %}
<li class="breadcrumb-item"><a href="{% url 'child-list' %}">Children</a></li>
<li class="breadcrumb-item font-weight-bold"><a href="{% url 'child' object.slug %}">{{ object }}</a></li>
<li class="breadcrumb-item"><a href="{% url 'core:child-list' %}">Children</a></li>
<li class="breadcrumb-item font-weight-bold"><a href="{% url 'core:child' object.slug %}">{{ object }}</a></li>
<li class="breadcrumb-item active" aria-current="page">Delete</li>
{% endblock %}
@ -25,6 +25,6 @@
{% endif %}
</div>
<input type="submit" value="Delete" class="btn btn-danger" />
<a href="{% url 'child-list' %}" class="btn btn-default">Cancel</a>
<a href="{% url 'core:child-list' %}" class="btn btn-default">Cancel</a>
</form>
{% endblock %}

View File

@ -4,7 +4,7 @@
{% block title %}{{ object }}{% endblock %}
{% block breadcrumbs %}
<li class="breadcrumb-item"><a href="{% url 'child-list' %}">Children</a></li>
<li class="breadcrumb-item"><a href="{% url 'core:child-list' %}">Children</a></li>
<li class="breadcrumb-item font-weight-bold">{{ object }}</li>
{% endblock %}

View File

@ -9,9 +9,9 @@
{% endblock %}
{% block breadcrumbs %}
<li class="breadcrumb-item"><a href="{% url 'child-list' %}">Children</a></li>
<li class="breadcrumb-item"><a href="{% url 'core:child-list' %}">Children</a></li>
{% if object %}
<li class="breadcrumb-item font-weight-bold"><a href="{% url 'child' object.slug %}">{{ object }}</a></li>
<li class="breadcrumb-item font-weight-bold"><a href="{% url 'core:child' object.slug %}">{{ object }}</a></li>
<li class="breadcrumb-item active" aria-current="page">Update</li>
{% else %}
<li class="breadcrumb-item active" aria-current="page">Add a Child</li>

View File

@ -33,7 +33,7 @@
{% endif %}
</td>
<th scope="row">
<a href="{% url 'child' child.slug %}">{{ child.first_name }}</a>
<a href="{% url 'core:child' child.slug %}">{{ child.first_name }}</a>
</th>
<td>{{ child.last_name }}</td>
<td>{{ child.birth_date }}</td>
@ -41,13 +41,13 @@
<div class="btn-group btn-group-sm" role="group" aria-label="Actions">
{% if perms.core.change_child %}
<a href="{% url 'child-update' child.slug %}" class="btn btn-warning">
<a href="{% url 'core:child-update' child.slug %}" class="btn btn-warning">
<i class="icon icon-update" aria-hidden="true"></i>
</a>
{% endif %}
{% if perms.core.delete_child %}
<a href="{% url 'child-delete' child.slug %}" class="btn btn-danger">
<a href="{% url 'core:child-delete' child.slug %}" class="btn btn-danger">
<i class="icon icon-delete" aria-hidden="true"></i>
</a>
{% endif %}
@ -66,7 +66,7 @@
{% include 'babybuddy/paginator.html' %}
{% if perms.core.add_child %}
<a href="{% url 'child-add' %}" class="btn btn-sm btn-success">
<a href="{% url 'core:child-add' %}" class="btn btn-sm btn-success">
<i class="icon icon-child" aria-hidden="true"></i> Add a Child
</a>
{% endif %}

View File

@ -4,7 +4,7 @@
{% block title %}Delete a Diaper Change{% endblock %}
{% block breadcrumbs %}
<li class="breadcrumb-item"><a href="{% url 'diaperchange-list' %}">Diaper Changes</a></li>
<li class="breadcrumb-item"><a href="{% url 'core:diaperchange-list' %}">Diaper Changes</a></li>
<li class="breadcrumb-item active" aria-current="page">Delete</li>
{% endblock %}
@ -13,6 +13,6 @@
{% csrf_token %}
<h1>Are you sure you want to delete <span class="text-info">{{ object }}</span>?</h1>
<input type="submit" value="Delete" class="btn btn-danger" />
<a href="{% url 'diaperchange-list' %}" class="btn btn-default">Cancel</a>
<a href="{% url 'core:diaperchange-list' %}" class="btn btn-default">Cancel</a>
</form>
{% endblock %}

View File

@ -9,7 +9,7 @@
{% endblock %}
{% block breadcrumbs %}
<li class="breadcrumb-item"><a href="{% url 'diaperchange-list' %}">Diaper Changes</a></li>
<li class="breadcrumb-item"><a href="{% url 'core:diaperchange-list' %}">Diaper Changes</a></li>
{% if object %}
<li class="breadcrumb-item active" aria-current="page">Update</li>
{% else %}

View File

@ -26,7 +26,7 @@
<tbody>
{% for change in object_list %}
<tr>
<th scope="row"><a href="{% url 'child' change.child.slug %}">{{ change.child }}</a></th>
<th scope="row"><a href="{% url 'core:child' change.child.slug %}">{{ change.child }}</a></th>
<td class="text-center">{{ change.wet|bool_icon }}</td>
<td class="text-center">{{ change.solid|bool_icon }}</td>
<td>{{ change.color }}</td>
@ -35,13 +35,13 @@
<div class="btn-group btn-group-sm" role="group" aria-label="Actions">
{% if perms.core.change_diaperchange %}
<a href="{% url 'diaperchange-update' change.id %}" class="btn btn-primary">
<a href="{% url 'core:diaperchange-update' change.id %}" class="btn btn-primary">
<i class="icon icon-update" aria-hidden="true"></i>
</a>
{% endif %}
{% if perms.core.delete_diaperchange %}
<a href="{% url 'diaperchange-delete' change.id %}" class="btn btn-danger">
<a href="{% url 'core:diaperchange-delete' change.id %}" class="btn btn-danger">
<i class="icon icon-delete" aria-hidden="true"></i>
</a>
{% endif %}
@ -60,7 +60,7 @@
{% include 'babybuddy/paginator.html' %}
{% if perms.core.add_diaperchange %}
<a href="{% url 'diaperchange-add' %}" class="btn btn-sm btn-success">
<a href="{% url 'core:diaperchange-add' %}" class="btn btn-sm btn-success">
<i class="icon icon-diaperchange" aria-hidden="true"></i> Add a Change
</a>
{% endif %}

View File

@ -4,7 +4,7 @@
{% block title %}Delete a Feeding{% endblock %}
{% block breadcrumbs %}
<li class="breadcrumb-item"><a href="{% url 'feeding-list' %}">Feedings</a></li>
<li class="breadcrumb-item"><a href="{% url 'core:feeding-list' %}">Feedings</a></li>
<li class="breadcrumb-item active" aria-current="page">Delete</li>
{% endblock %}
@ -13,6 +13,6 @@
{% csrf_token %}
<h1>Are you sure you want to delete <span class="text-info">{{ object }}</span>?</h1>
<input type="submit" value="Delete" class="btn btn-danger" />
<a href="{% url 'feeding-list' %}" class="btn btn-default">Cancel</a>
<a href="{% url 'core:feeding-list' %}" class="btn btn-default">Cancel</a>
</form>
{% endblock %}

View File

@ -9,7 +9,7 @@
{% endblock %}
{% block breadcrumbs %}
<li class="breadcrumb-item"><a href="{% url 'feeding-list' %}">Feedings</a></li>
<li class="breadcrumb-item"><a href="{% url 'core:feeding-list' %}">Feedings</a></li>
{% if object %}
<li class="breadcrumb-item active" aria-current="page">Update</li>
{% else %}

View File

@ -27,7 +27,7 @@
<tbody>
{% for feeding in object_list %}
<tr>
<th scope="row"><a href="{% url 'child' feeding.child.slug %}">{{ feeding.child }}</a></th>
<th scope="row"><a href="{% url 'core:child' feeding.child.slug %}">{{ feeding.child }}</a></th>
<td>{{ feeding.method }}</td>
<td>{{ feeding.type }}</td>
<td>
@ -41,13 +41,13 @@
<div class="btn-group btn-group-sm" role="group" aria-label="Actions">
{% if perms.core.change_feeding %}
<a href="{% url 'feeding-update' feeding.id %}" class="btn btn-primary">
<a href="{% url 'core:feeding-update' feeding.id %}" class="btn btn-primary">
<i class="icon icon-update" aria-hidden="true"></i>
</a>
{% endif %}
{% if perms.core.delete_feeding %}
<a href="{% url 'feeding-delete' feeding.id %}" class="btn btn-danger">
<a href="{% url 'core:feeding-delete' feeding.id %}" class="btn btn-danger">
<i class="icon icon-delete" aria-hidden="true"></i>
</a>
{% endif %}
@ -66,7 +66,7 @@
{% include 'babybuddy/paginator.html' %}
{% if perms.core.add_feeding %}
<a href="{% url 'feeding-add' %}" class="btn btn-sm btn-success">
<a href="{% url 'core:feeding-add' %}" class="btn btn-sm btn-success">
<i class="icon icon-feeding" aria-hidden="true"></i> Add a Feeding
</a>
{% endif %}

View File

@ -4,7 +4,7 @@
{% block title %}Delete a Note{% endblock %}
{% block breadcrumbs %}
<li class="breadcrumb-item"><a href="{% url 'note-list' %}">Notes</a></li>
<li class="breadcrumb-item"><a href="{% url 'core:note-list' %}">Notes</a></li>
<li class="breadcrumb-item active" aria-current="page">Delete</li>
{% endblock %}
@ -13,6 +13,6 @@
{% csrf_token %}
<h1>Are you sure you want to delete <span class="text-info">{{ object }}</span>?</h1>
<input type="submit" value="Delete" class="btn btn-danger" />
<a href="{% url 'note-list' %}" class="btn btn-default">Cancel</a>
<a href="{% url 'core:note-list' %}" class="btn btn-default">Cancel</a>
</form>
{% endblock %}

View File

@ -9,7 +9,7 @@
{% endblock %}
{% block breadcrumbs %}
<li class="breadcrumb-item"><a href="{% url 'note-list' %}">Notes</a></li>
<li class="breadcrumb-item"><a href="{% url 'core:note-list' %}">Notes</a></li>
{% if object %}
<li class="breadcrumb-item active" aria-current="page">Update</li>
{% else %}

View File

@ -23,20 +23,20 @@
<tbody>
{% for note in object_list %}
<tr>
<th scope="row"><a href="{% url 'child' note.child.slug %}">{{ note.child }}</a></th>
<th scope="row"><a href="{% url 'core:child' note.child.slug %}">{{ note.child }}</a></th>
<td>{{ note.note }}</td>
<td>{{ note.time }}</td>
<td class="text-center">
<div class="btn-group btn-group-sm" role="group" aria-label="Actions">
{% if perms.core.change_note %}
<a href="{% url 'note-update' note.id %}" class="btn btn-primary">
<a href="{% url 'core:note-update' note.id %}" class="btn btn-primary">
<i class="icon icon-update" aria-hidden="true"></i>
</a>
{% endif %}
{% if perms.core.delete_note %}
<a href="{% url 'note-delete' note.id %}" class="btn btn-danger">
<a href="{% url 'core:note-delete' note.id %}" class="btn btn-danger">
<i class="icon icon-delete" aria-hidden="true"></i>
</a>
{% endif %}
@ -55,7 +55,7 @@
{% include 'babybuddy/paginator.html' %}
{% if perms.core.add_note %}
<a href="{% url 'note-add' %}" class="btn btn-sm btn-success">
<a href="{% url 'core:note-add' %}" class="btn btn-sm btn-success">
<i class="icon icon-note" aria-hidden="true"></i> Add a Note
</a>
{% endif %}

View File

@ -4,7 +4,7 @@
{% block title %}Delete a Sleep Entry{% endblock %}
{% block breadcrumbs %}
<li class="breadcrumb-item"><a href="{% url 'sleep-list' %}">Sleep</a></li>
<li class="breadcrumb-item"><a href="{% url 'core:sleep-list' %}">Sleep</a></li>
<li class="breadcrumb-item active" aria-current="page">Delete</li>
{% endblock %}
@ -13,6 +13,6 @@
{% csrf_token %}
<h1>Are you sure you want to delete <span class="text-info">{{ object }}</span>?</h1>
<input type="submit" value="Delete" class="btn btn-danger" />
<a href="{% url 'sleep-list' %}" class="btn btn-default">Cancel</a>
<a href="{% url 'core:sleep-list' %}" class="btn btn-default">Cancel</a>
</form>
{% endblock %}

View File

@ -9,7 +9,7 @@
{% endblock %}
{% block breadcrumbs %}
<li class="breadcrumb-item"><a href="{% url 'sleep-list' %}">Sleep</a></li>
<li class="breadcrumb-item"><a href="{% url 'core:sleep-list' %}">Sleep</a></li>
{% if object %}
<li class="breadcrumb-item active" aria-current="page">Update</li>
{% else %}

View File

@ -25,7 +25,7 @@
<tbody>
{% for sleep in object_list %}
<tr>
<th scope="row"><a href="{% url 'child' sleep.child.slug %}">{{ sleep.child }}</a></th>
<th scope="row"><a href="{% url 'core:child' sleep.child.slug %}">{{ sleep.child }}</a></th>
<td>{{ sleep.duration|duration_string }}</td>
<td>{{ sleep.start|date:'n/j/y G:i' }}</td>
<td>{{ sleep.end|date:'n/j/y G:i' }}</td>
@ -34,13 +34,13 @@
<div class="btn-group btn-group-sm" role="group" aria-label="Actions">
{% if perms.core.change_sleep %}
<a href="{% url 'sleep-update' sleep.id %}" class="btn btn-primary">
<a href="{% url 'core:sleep-update' sleep.id %}" class="btn btn-primary">
<i class="icon icon-update" aria-hidden="true"></i>
</a>
{% endif %}
{% if perms.core.delete_sleep %}
<a href="{% url 'sleep-delete' sleep.id %}" class="btn btn-danger">
<a href="{% url 'core:sleep-delete' sleep.id %}" class="btn btn-danger">
<i class="icon icon-delete" aria-hidden="true"></i>
</a>
{% endif %}
@ -59,7 +59,7 @@
{% include 'babybuddy/paginator.html' %}
{% if perms.core.add_sleep %}
<a href="{% url 'sleep-add' %}" class="btn btn-sm btn-success">
<a href="{% url 'core:sleep-add' %}" class="btn btn-sm btn-success">
<i class="icon icon-sleep" aria-hidden="true"></i> Add a Sleep Entry
</a>
{% endif %}

View File

@ -4,8 +4,8 @@
{% block title %}Delete {{ object }}{% endblock %}
{% block breadcrumbs %}
<li class="breadcrumb-item"><a href="{% url 'timer-list' %}">Timers</a></li>
<li class="breadcrumb-item font-weight-bold"><a href="{% url 'timer-detail' object.id %}">{{ object }}</a></li>
<li class="breadcrumb-item"><a href="{% url 'core:timer-list' %}">Timers</a></li>
<li class="breadcrumb-item font-weight-bold"><a href="{% url 'core:timer-detail' object.id %}">{{ object }}</a></li>
<li class="breadcrumb-item active" aria-current="page">Delete</li>
{% endblock %}

View File

@ -4,7 +4,7 @@
{% block title %}{{ object }}{% endblock %}
{% block breadcrumbs %}
<li class="breadcrumb-item"><a href="{% url 'timer-list' %}">Timers</a></li>
<li class="breadcrumb-item"><a href="{% url 'core:timer-list' %}">Timers</a></li>
<li class="breadcrumb-item font-weight-bold">{{ object }}</li>
{% endblock %}
@ -28,19 +28,19 @@
{% if perms.core.add_feeding %}
<a class="btn btn-success btn-lg btn-block mb-3"
href="{% url 'feeding-add' %}?timer={{ timer.id }}"
href="{% url 'core:feeding-add' %}?timer={{ timer.id }}"
role="button"><i class="icon icon-feeding" aria-hidden="true"></i> Feeding</a>
{% endif %}
{% if perms.core.add_sleep %}
<a class="btn btn-success btn-lg btn-block mb-3"
href="{% url 'sleep-add' %}?timer={{ timer.id }}"
href="{% url 'core:sleep-add' %}?timer={{ timer.id }}"
role="button"><i class="icon icon-sleep" aria-hidden="true"></i> Sleep</a>
{% endif %}
{% if perms.core.add_tummytime %}
<a class="btn btn-success btn-lg btn-block mb-3"
href="{% url 'tummytime-add' %}?timer={{ timer.id }}"
href="{% url 'core:tummytime-add' %}?timer={{ timer.id }}"
role="button"><i class="icon icon-tummytime" aria-hidden="true"></i> Tummy Time</a>
{% endif %}
@ -48,22 +48,22 @@
{% if perms.core.delete_timer %}
<a class="btn btn-danger"
href="{% url 'timer-delete' timer.id %}"
href="{% url 'core:timer-delete' timer.id %}"
role="button"><i class="icon icon-delete" aria-hidden="true"></i></a>
{% endif %}
{% if perms.core.change_timer %}
<a class="btn btn-primary"
href="{% url 'timer-update' timer.id %}"
href="{% url 'core:timer-update' timer.id %}"
role="button"><i class="icon icon-update" aria-hidden="true"></i></a>
<a class="btn btn-secondary"
href="{% url 'timer-restart' timer.id %}"
href="{% url 'core:timer-restart' timer.id %}"
role="button"><i class="icon icon-refresh" aria-hidden="true"></i></a>
{% if object.active %}
<a class="btn btn-warning"
href="{% url 'timer-stop' timer.id %}"
href="{% url 'core:timer-stop' timer.id %}"
role="button"><i class="icon icon-stop" aria-hidden="true"></i></a>
{% endif %}
{% endif %}

View File

@ -4,9 +4,9 @@
{% block title %}Timer{% endblock %}
{% block breadcrumbs %}
<li class="breadcrumb-item"><a href="{% url 'timer-list' %}">Timers</a></li>
<li class="breadcrumb-item"><a href="{% url 'core:timer-list' %}">Timers</a></li>
{% if object %}
<li class="breadcrumb-item font-weight-bold"><a href="{% url 'timer-detail' object.id %}">{{ object }}</a></li>
<li class="breadcrumb-item font-weight-bold"><a href="{% url 'core:timer-detail' object.id %}">{{ object }}</a></li>
<li class="breadcrumb-item active" aria-current="page">Update</li>
{% else %}
<li class="breadcrumb-item active" aria-current="page">Start</li>

View File

@ -25,7 +25,7 @@
<tbody>
{% for timer in object_list %}
<tr>
<th scope="row"><a href="{% url 'timer-detail' timer.id %}">{{ timer }}</a></th>
<th scope="row"><a href="{% url 'core:timer-detail' timer.id %}">{{ timer }}</a></th>
<td>{{ timer.start|date:'n/j/y G:i' }}</td>
<td>{{ timer.duration|duration_string }}</td>
<td>{{ timer.end|date:'n/j/y G:i' }}</td>

View File

@ -7,22 +7,22 @@
aria-expanded="false"><i class="icon icon-timer" aria-hidden="true"></i> Timers</a>
<div class="dropdown-menu" aria-labelledby="nav-timer-menu-link">
{% if perms.core.add_timer %}
<a class="dropdown-item" href="{% url 'timer-add-quick' %}">
<a class="dropdown-item" href="{% url 'core:timer-add-quick' %}">
<i class="icon icon-timer" aria-hidden="true"></i> Quick Start Timer
</a>
<a class="dropdown-item" href="{% url 'timer-add' %}">
<a class="dropdown-item" href="{% url 'core:timer-add' %}">
<i class="icon icon-add" aria-hidden="true"></i> Start Timer
</a>
{% endif %}
{% if perms.core.view_timer %}
<a class="dropdown-item" href="{% url 'timer-list' %}">
<a class="dropdown-item" href="{% url 'core:timer-list' %}">
<i class="icon icon-list" aria-hidden="true"></i> View Timers
</a>
{% endif %}
{% if timers %}
<h6 class="dropdown-header">Active Timers</h6>
{% for timer in timers %}
<a class="dropdown-item" href="{% url 'timer-detail' timer.id %}">{{ timer }} ({{ timer.user }})</a>
<a class="dropdown-item" href="{% url 'core:timer-detail' timer.id %}">{{ timer }} ({{ timer.user }})</a>
{% empty %}
<a class="dropdown-item disabled" href="#">None</a>
{% endfor %}

View File

@ -4,7 +4,7 @@
{% block title %}Delete a Tummy Time Entry{% endblock %}
{% block breadcrumbs %}
<li class="breadcrumb-item"><a href="{% url 'tummytime-list' %}">Tummy Time</a></li>
<li class="breadcrumb-item"><a href="{% url 'core:tummytime-list' %}">Tummy Time</a></li>
<li class="breadcrumb-item active" aria-current="page">Delete</li>
{% endblock %}
@ -13,6 +13,6 @@
{% csrf_token %}
<h1>Are you sure you want to delete <span class="text-info">{{ object }}</span>?</h1>
<input type="submit" value="Delete" class="btn btn-danger" />
<a href="{% url 'tummytime-list' %}" class="btn btn-default">Cancel</a>
<a href="{% url 'core:tummytime-list' %}" class="btn btn-default">Cancel</a>
</form>
{% endblock %}

View File

@ -9,7 +9,7 @@
{% endblock %}
{% block breadcrumbs %}
<li class="breadcrumb-item"><a href="{% url 'tummytime-list' %}">Tummy Time</a></li>
<li class="breadcrumb-item"><a href="{% url 'core:tummytime-list' %}">Tummy Time</a></li>
{% if object %}
<li class="breadcrumb-item active" aria-current="page">Update</li>
{% else %}

View File

@ -26,7 +26,7 @@
<tbody>
{% for tummytime in object_list %}
<tr>
<th scope="row"><a href="{% url 'child' tummytime.child.slug %}">{{ tummytime.child }}</a></th>
<th scope="row"><a href="{% url 'core:child' tummytime.child.slug %}">{{ tummytime.child }}</a></th>
<td>{{ tummytime.duration|duration_string }}</td>
<td>{{ tummytime.start|date:'n/j/y G:i' }}</td>
<td>{{ tummytime.end|date:'n/j/y G:i' }}</td>
@ -35,13 +35,13 @@
<div class="btn-group btn-group-sm" role="group" aria-label="Actions">
{% if perms.core.change_tummytime %}
<a href="{% url 'tummytime-update' tummytime.id %}" class="btn btn-primary">
<a href="{% url 'core:tummytime-update' tummytime.id %}" class="btn btn-primary">
<i class="icon icon-update" aria-hidden="true"></i>
</a>
{% endif %}
{% if perms.core.delete_tummytime %}
<a href="{% url 'tummytime-delete' tummytime.id %}" class="btn btn-danger">
<a href="{% url 'core:tummytime-delete' tummytime.id %}" class="btn btn-danger">
<i class="icon icon-delete" aria-hidden="true"></i>
</a>
{% endif %}
@ -60,7 +60,7 @@
{% include 'babybuddy/paginator.html' %}
{% if perms.core.add_tummytime %}
<a href="{% url 'tummytime-add' %}" class="btn btn-sm btn-success">
<a href="{% url 'core:tummytime-add' %}" class="btn btn-sm btn-success">
<i class="icon icon-tummytime" aria-hidden="true"></i> Add a Tummy Time Entry</a>
{% endif %}

View File

@ -4,7 +4,7 @@
{% block title %}Delete a Weight Entry{% endblock %}
{% block breadcrumbs %}
<li class="breadcrumb-item"><a href="{% url 'weight-list' %}">Weight</a></li>
<li class="breadcrumb-item"><a href="{% url 'core:weight-list' %}">Weight</a></li>
<li class="breadcrumb-item active" aria-current="page">Delete</li>
{% endblock %}
@ -13,6 +13,6 @@
{% csrf_token %}
<h1>Are you sure you want to delete <span class="text-info">{{ object }}</span>?</h1>
<input type="submit" value="Delete" class="btn btn-danger" />
<a href="{% url 'weight-list' %}" class="btn btn-default">Cancel</a>
<a href="{% url 'core:weight-list' %}" class="btn btn-default">Cancel</a>
</form>
{% endblock %}

View File

@ -9,7 +9,7 @@
{% endblock %}
{% block breadcrumbs %}
<li class="breadcrumb-item"><a href="{% url 'weight-list' %}">Weight</a></li>
<li class="breadcrumb-item"><a href="{% url 'core:weight-list' %}">Weight</a></li>
{% if object %}
<li class="breadcrumb-item active" aria-current="page">Update</li>
{% else %}

View File

@ -23,20 +23,20 @@
<tbody>
{% for object in object_list %}
<tr>
<th scope="row"><a href="{% url 'child' object.child.slug %}">{{ object.child }}</a></th>
<th scope="row"><a href="{% url 'core:child' object.child.slug %}">{{ object.child }}</a></th>
<td>{{ object.weight }}</td>
<td>{{ object.date }}</td>
<td class="text-center">
<div class="btn-group btn-group-sm" role="group" aria-label="Actions">
{% if perms.core.change_weight %}
<a href="{% url 'weight-update' object.id %}" class="btn btn-primary">
<a href="{% url 'core:weight-update' object.id %}" class="btn btn-primary">
<i class="icon icon-update" aria-hidden="true"></i>
</a>
{% endif %}
{% if perms.core.delete_weight %}
<a href="{% url 'weight-delete' object.id %}" class="btn btn-danger">
<a href="{% url 'core:weight-delete' object.id %}" class="btn btn-danger">
<i class="icon icon-delete" aria-hidden="true"></i>
</a>
{% endif %}
@ -55,7 +55,7 @@
{% include 'babybuddy/paginator.html' %}
{% if perms.core.add_weight %}
<a href="{% url 'weight-add' %}" class="btn btn-sm btn-success">
<a href="{% url 'core:weight-add' %}" class="btn btn-sm btn-success">
<i class="icon icon-weight" aria-hidden="true"></i> Add a Weight Entry
</a>
{% endif %}

View File

@ -5,6 +5,8 @@ from django.conf.urls import url
from . import views
app_name = 'core'
urlpatterns = [
url(r'^children/$', views.ChildList.as_view(), name='child-list'),
url(r'^children/add/$', views.ChildAdd.as_view(), name='child-add'),

View File

@ -232,7 +232,7 @@ class TimerAddQuick(PermissionRequiredMixin, RedirectView):
instance = models.Timer.objects.create(user=request.user)
instance.save()
self.url = request.GET.get(
'next', reverse('timer-detail', args={instance.id}))
'next', reverse('core:timer-detail', args={instance.id}))
return super(TimerAddQuick, self).get(request, *args, **kwargs)

View File

@ -11,7 +11,8 @@
{% block listgroup %}
<ul class="list-group list-group-flush">
{% for instance in instances %}
<a href="{% url 'timer-detail' instance.id %}" class="list-group-item list-group-item-action">
<a href="{% url 'core:timer-detail' instance.id %}"
class="list-group-item list-group-item-action">
<strong>{{ instance }}</strong> <p class="text-muted small m-0">Started by {{ instance.user }} at {{ instance.start|time }}</p>
</a>
{% endfor %}

View File

@ -4,8 +4,8 @@
{% block title %}Dashboard - {{ object }}{% endblock %}
{% block breadcrumbs %}
<li class="breadcrumb-item"><a href="{% url 'child-list' %}">Children</a></li>
<li class="breadcrumb-item font-weight-bold"><a href="{% url 'child' object.slug %}">{{ object }}</a></li>
<li class="breadcrumb-item"><a href="{% url 'core:child-list' %}">Children</a></li>
<li class="breadcrumb-item font-weight-bold"><a href="{% url 'core:child' object.slug %}">{{ object }}</a></li>
<li class="breadcrumb-item active" aria-current="page">Dashboard</li>
{% endblock %}

View File

@ -1,7 +1,7 @@
<div class="child-actions btn-group btn-group-lg center-block" role="group" aria-label="Child actions">
{% if perms.core.view_child %}
<a href="{% url 'dashboard-child' object.slug %}" class="btn btn-success">
<a href="{% url 'core:dashboard-child' object.slug %}" class="btn btn-success">
<i class="icon icon-dashboard" aria-hidden="true"></i>
</a>
{% endif %}
@ -25,13 +25,13 @@
{% if perms.core.change_child %}
<a class="btn btn-warning"
href="{% url 'child-update' object.slug %}"
href="{% url 'core:child-update' object.slug %}"
role="button"><i class="icon icon-update" aria-hidden="true"></i></a>
{% endif %}
{% if perms.core.delete_child %}
<a class="btn btn-danger"
href="{% url 'child-delete' object.slug %}"
href="{% url 'core:child-delete' object.slug %}"
role="button"><i class="icon icon-delete" aria-hidden="true"></i></a>
{% endif %}

View File

@ -12,7 +12,7 @@
{% for object in objects %}
<div class="col-lg-3 col-md-4 col-sm-6 col-xs-2 mb-4">
<div class="card">
<a href="{% url 'child' object.slug %}">
<a href="{% url 'core:child' object.slug %}">
{% if object.picture %}
{% thumbnail object.picture 300x300 upscale crop as thumb %}
<img src="{{ thumb.url }}" class="child-photo img-fluid" />

View File

@ -5,6 +5,8 @@ from django.conf.urls import url
from . import views
app_name = 'dashboard'
urlpatterns = [
url(r'^dashboard/$', views.Dashboard.as_view(), name='dashboard'),
url(r'^children/(?P<slug>[^/.]+)/dashboard/$',

View File

@ -19,10 +19,14 @@ class Dashboard(LoginRequiredMixin, TemplateView):
def get(self, request, *args, **kwargs):
children = Child.objects.count()
if children == 0:
return HttpResponseRedirect(reverse('welcome'))
return HttpResponseRedirect(reverse('babybuddy:welcome'))
elif children == 1:
return HttpResponseRedirect(
reverse('dashboard-child', args={Child.objects.first().slug}))
reverse(
'dashboard:dashboard-child',
args={Child.objects.first().slug}
)
)
return super(Dashboard, self).get(request, *args, **kwargs)
def get_context_data(self, **kwargs):

View File

@ -4,8 +4,8 @@
{% block title %}{% endblock %}
{% block breadcrumbs %}
<li class="breadcrumb-item"><a href="{% url 'child-list' %}">Children</a></li>
<li class="breadcrumb-item font-weight-bold"><a href="{% url 'child' object.slug %}">{{ object }}</a></li>
<li class="breadcrumb-item"><a href="{% url 'core:child-list' %}">Children</a></li>
<li class="breadcrumb-item font-weight-bold"><a href="{% url 'core:child' object.slug %}">{{ object }}</a></li>
<li class="breadcrumb-item">Reports</li>
{% endblock %}

View File

@ -5,6 +5,8 @@ from django.conf.urls import url
from . import views
app_name = 'reports'
urlpatterns = [
url(r'^children/(?P<slug>[^/.]+)/reports/changes/lifetimes/$',
views.DiaperChangeLifetimesChildReport.as_view(),