Update URL definitions to Django 2.0 style.

This commit is contained in:
Christopher Charbonneau Wells 2017-12-13 18:12:32 -05:00
parent 183a30b0a3
commit f2a8cdec2d
7 changed files with 197 additions and 114 deletions

View File

@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.conf.urls import url, include
from django.urls import include, path
from rest_framework import routers
from . import views
@ -19,7 +19,9 @@ router.register(r'weight', views.WeightViewSet)
app_name = 'api'
urlpatterns = [
url(r'^api/', include(router.urls)),
url(r'^api/auth/', include('rest_framework.urls',
namespace='rest_framework'))
path('api/', include(router.urls)),
path('api/auth/', include(
'rest_framework.urls',
namespace='rest_framework'
))
]

View File

@ -75,7 +75,7 @@ class FormsTestCase(TestCase):
self.assertIsInstance(new_user, User)
params['first_name'] = 'Changed'
page = self.c.post('/users/{}/edit'.format(new_user.id), params)
page = self.c.post('/users/{}/edit/'.format(new_user.id), params)
self.assertEqual(page.status_code, 302)
new_user.refresh_from_db()
self.assertEqual(new_user.first_name, params['first_name'])

View File

@ -74,7 +74,7 @@ class ViewsTestCase(TestCase):
self.assertEqual(page.status_code, 200)
entry = User.objects.first()
page = self.c.get('/users/{}/edit'.format(entry.id))
page = self.c.get('/users/{}/edit/'.format(entry.id))
self.assertEqual(page.status_code, 200)
page = self.c.get('/users/{}/delete/'.format(entry.id))
self.assertEqual(page.status_code, 200)

View File

@ -1,45 +1,63 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.conf.urls import url, include
from django.conf.urls.static import static
from django.conf import settings
from django.contrib import admin
from django.contrib.auth import views as auth_views
from django.urls import include, path
from . import views
app_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(),
name='password_reset',),
path('login/', auth_views.LoginView.as_view(), name='login'),
path('logout/', auth_views.LogoutView.as_view(), name='logout'),
path(
'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'),
path('', views.RootRouter.as_view(), name='root-router'),
path('welcome/', views.Welcome.as_view(), name='welcome'),
url(r'^users/$', views.UserList.as_view(), name='user-list'),
url(r'^users/add/$', views.UserAdd.as_view(), name='user-add'),
url(r'^users/(?P<pk>[0-9]+)/edit$', views.UserUpdate.as_view(),
name='user-update'),
url(r'^users/(?P<pk>[0-9]+)/delete/$', views.UserDelete.as_view(),
name='user-delete'),
path('users/', views.UserList.as_view(), name='user-list'),
path('users/add/', views.UserAdd.as_view(), name='user-add'),
path(
'users/<int:pk>/edit/',
views.UserUpdate.as_view(),
name='user-update'
),
path(
'users/<int:pk>/delete/',
views.UserDelete.as_view(),
name='user-delete'
),
url(r'^user/password/$', views.UserPassword.as_view(),
name='user-password'),
url(r'^user/reset-api-key/$', views.UserResetAPIKey.as_view(),
name='user-reset-api-key'),
url(r'^user/settings/$', views.UserSettings.as_view(),
name='user-settings'),
path(
'user/password/',
views.UserPassword.as_view(),
name='user-password'
),
path(
'user/reset-api-key/',
views.UserResetAPIKey.as_view(),
name='user-reset-api-key'
),
path(
'user/settings/',
views.UserSettings.as_view(),
name='user-settings'
),
]
urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'', include('api.urls', namespace='api')),
url(r'', include((app_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')),
path('admin/', admin.site.urls),
path('', include('api.urls', namespace='api')),
path('', include((app_patterns, 'babybuddy'), namespace='babybuddy')),
path('', include('core.urls', namespace='core')),
path('', include('dashboard.urls', namespace='dashboard')),
path('', include('reports.urls', namespace='reports')),
]
if settings.DEBUG: # pragma: no cover

View File

@ -1,80 +1,131 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.conf.urls import url
from django.urls import path
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'),
url(r'^children/(?P<slug>[^/.]+)/$', views.ChildDetail.as_view(),
name='child'),
url(r'^children/(?P<slug>[^/.]+)/edit/$', views.ChildUpdate.as_view(),
name='child-update'),
url(r'^children/(?P<slug>[^/.]+)/delete/$', views.ChildDelete.as_view(),
name='child-delete'),
path('children/', views.ChildList.as_view(), name='child-list'),
path('children/add/', views.ChildAdd.as_view(), name='child-add'),
path('children/<slug:slug>/', views.ChildDetail.as_view(), name='child'),
path(
'children/<slug:slug>/edit/',
views.ChildUpdate.as_view(),
name='child-update'
),
path(
'children/<slug:slug>/delete/',
views.ChildDelete.as_view(),
name='child-delete'
),
url(r'^changes/$', views.DiaperChangeList.as_view(),
name='diaperchange-list'),
url(r'^changes/add/$', views.DiaperChangeAdd.as_view(),
name='diaperchange-add'),
url(r'^changes/(?P<pk>[0-9]+)/$', views.DiaperChangeUpdate.as_view(),
name='diaperchange-update'),
url(r'^changes/(?P<pk>[0-9]+)/delete/$',
views.DiaperChangeDelete.as_view(), name='diaperchange-delete'),
path(
'changes/',
views.DiaperChangeList.as_view(),
name='diaperchange-list'
),
path(
'changes/add/',
views.DiaperChangeAdd.as_view(),
name='diaperchange-add'
),
path(
'changes/<int:pk>/',
views.DiaperChangeUpdate.as_view(),
name='diaperchange-update'
),
path(
'changes/<int:pk>/delete/',
views.DiaperChangeDelete.as_view(),
name='diaperchange-delete'
),
url(r'^feedings/$', views.FeedingList.as_view(), name='feeding-list'),
url(r'^feedings/add/$', views.FeedingAdd.as_view(), name='feeding-add'),
url(r'^feedings/(?P<pk>[0-9]+)/$', views.FeedingUpdate.as_view(),
name='feeding-update'),
url(r'^feedings/(?P<pk>[0-9]+)/delete/$', views.FeedingDelete.as_view(),
name='feeding-delete'),
path('feedings/', views.FeedingList.as_view(), name='feeding-list'),
path('feedings/add/', views.FeedingAdd.as_view(), name='feeding-add'),
path(
'feedings/<int:pk>/',
views.FeedingUpdate.as_view(),
name='feeding-update'
),
path(
'feedings/<int:pk>/delete/',
views.FeedingDelete.as_view(),
name='feeding-delete'
),
url(r'^notes/$', views.NoteList.as_view(), name='note-list'),
url(r'^notes/add/$', views.NoteAdd.as_view(), name='note-add'),
url(r'^notes/(?P<pk>[0-9]+)/$', views.NoteUpdate.as_view(),
name='note-update'),
url(r'^notes/(?P<pk>[0-9]+)/delete/$', views.NoteDelete.as_view(),
name='note-delete'),
path('notes/', views.NoteList.as_view(), name='note-list'),
path('notes/add/', views.NoteAdd.as_view(), name='note-add'),
path('notes/<int:pk>/', views.NoteUpdate.as_view(), name='note-update'),
path(
'notes/<int:pk>/delete/',
views.NoteDelete.as_view(),
name='note-delete'
),
url(r'^sleep/$', views.SleepList.as_view(), name='sleep-list'),
url(r'^sleep/add/$', views.SleepAdd.as_view(), name='sleep-add'),
url(r'^sleep/(?P<pk>[0-9]+)/$', views.SleepUpdate.as_view(),
name='sleep-update'),
url(r'^sleep/(?P<pk>[0-9]+)/delete/$', views.SleepDelete.as_view(),
name='sleep-delete'),
path('sleep/', views.SleepList.as_view(), name='sleep-list'),
path('sleep/add/', views.SleepAdd.as_view(), name='sleep-add'),
path('sleep/<int:pk>/', views.SleepUpdate.as_view(), name='sleep-update'),
path(
'sleep/<int:pk>/delete/',
views.SleepDelete.as_view(),
name='sleep-delete'
),
url(r'^timers/$', views.TimerList.as_view(), name='timer-list'),
url(r'^timer/add/$', views.TimerAdd.as_view(), name='timer-add'),
url(r'^timer/add/quick/$', views.TimerAddQuick.as_view(),
name='timer-add-quick'),
url(r'^timer/(?P<pk>[0-9]+)/$', views.TimerDetail.as_view(),
name='timer-detail'),
url(r'^timer/(?P<pk>[0-9]+)/edit/$', views.TimerUpdate.as_view(),
name='timer-update'),
url(r'^timer/(?P<pk>[0-9]+)/delete/$', views.TimerDelete.as_view(),
name='timer-delete'),
url(r'^timer/(?P<pk>[0-9]+)/stop/$', views.TimerStop.as_view(),
name='timer-stop'),
url(r'^timer/(?P<pk>[0-9]+)/restart/$', views.TimerRestart.as_view(),
name='timer-restart'),
path('timers/', views.TimerList.as_view(), name='timer-list'),
path('timer/add/', views.TimerAdd.as_view(), name='timer-add'),
path(
'timer/add/quick/',
views.TimerAddQuick.as_view(),
name='timer-add-quick'
),
path('timer/<int:pk>/', views.TimerDetail.as_view(), name='timer-detail'),
path(
'timer/<int:pk>/edit/',
views.TimerUpdate.as_view(),
name='timer-update'
),
path(
'timer/<int:pk>/delete/',
views.TimerDelete.as_view(),
name='timer-delete'
),
path('timer/<int:pk>/stop/', views.TimerStop.as_view(), name='timer-stop'),
path(
'timer/<int:pk>/restart/',
views.TimerRestart.as_view(),
name='timer-restart'
),
url(r'^tummy-time/$', views.TummyTimeList.as_view(),
name='tummytime-list'),
url(r'^tummy-time/add/$', views.TummyTimeAdd.as_view(),
name='tummytime-add'),
url(r'^tummy-time/(?P<pk>[0-9]+)/$', views.TummyTimeUpdate.as_view(),
name='tummytime-update'),
url(r'^tummy-time/(?P<pk>[0-9]+)/delete/$',
views.TummyTimeDelete.as_view(), name='tummytime-delete'),
path('tummy-time/', views.TummyTimeList.as_view(), name='tummytime-list'),
path(
'tummy-time/add/',
views.TummyTimeAdd.as_view(),
name='tummytime-add'
),
path(
'tummy-time/<int:pk>/',
views.TummyTimeUpdate.as_view(),
name='tummytime-update'
),
path(
'tummy-time/<int:pk>/delete/',
views.TummyTimeDelete.as_view(),
name='tummytime-delete'
),
url(r'^weight/$', views.WeightList.as_view(), name='weight-list'),
url(r'^weight/add/$', views.WeightAdd.as_view(), name='weight-add'),
url(r'^weight/(?P<pk>[0-9]+)/$', views.WeightUpdate.as_view(),
name='weight-update'),
url(r'^weight/(?P<pk>[0-9]+)/delete/$', views.WeightDelete.as_view(),
name='weight-delete'),
path('weight/', views.WeightList.as_view(), name='weight-list'),
path('weight/add/', views.WeightAdd.as_view(), name='weight-add'),
path(
'weight/<int:pk>/',
views.WeightUpdate.as_view(),
name='weight-update'
),
path(
'weight/<int:pk>/delete/',
views.WeightDelete.as_view(),
name='weight-delete'
),
]

View File

@ -1,14 +1,17 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.conf.urls import url
from django.urls import path
from . import views
app_name = 'dashboard'
urlpatterns = [
url(r'^dashboard/$', views.Dashboard.as_view(), name='dashboard'),
url(r'^children/(?P<slug>[^/.]+)/dashboard/$',
views.ChildDashboard.as_view(), name='dashboard-child'),
path('dashboard/', views.Dashboard.as_view(), name='dashboard'),
path(
'children/<slug:slug>/dashboard/',
views.ChildDashboard.as_view(),
name='dashboard-child'
),
]

View File

@ -1,32 +1,41 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.conf.urls import url
from django.urls import path
from . import views
app_name = 'reports'
urlpatterns = [
url(r'^children/(?P<slug>[^/.]+)/reports/changes/lifetimes/$',
path(
'children/<slug:slug>/reports/changes/lifetimes/',
views.DiaperChangeLifetimesChildReport.as_view(),
name='report-diaperchange-lifetimes-child'),
url(r'^children/(?P<slug>[^/.]+)/reports/changes/types/$',
name='report-diaperchange-lifetimes-child'
),
path(
'children/<slug:slug>/reports/changes/types/',
views.DiaperChangeTypesChildReport.as_view(),
name='report-diaperchange-types-child'),
url(r'^children/(?P<slug>[^/.]+)/reports/feeding/duration/$',
name='report-diaperchange-types-child'
),
path(
'children/<slug:slug>/reports/feeding/duration/',
views.FeedingDurationChildReport.as_view(),
name='report-feeding-duration-child'),
url(r'^children/(?P<slug>[^/.]+)/reports/sleep/pattern/$',
name='report-feeding-duration-child'
),
path(
'children/<slug:slug>/reports/sleep/pattern/',
views.SleepPatternChildReport.as_view(),
name='report-sleep-pattern-child'),
url(r'^children/(?P<slug>[^/.]+)/reports/sleep/totals/$',
name='report-sleep-pattern-child'
),
path(
'children/<slug:slug>/reports/sleep/totals/',
views.SleepTotalsChildReport.as_view(),
name='report-sleep-totals-child'),
url(r'^children/(?P<slug>[^/.]+)/reports/weight/weight/$',
name='report-sleep-totals-child'
),
path(
'children/<slug:slug>/reports/weight/weight/',
views.WeightWeightChildReoport.as_view(),
name='report-weight-weight-child'),
name='report-weight-weight-child'
),
]