From 06d138343ec68ea12d12b5d262134af8ae5dfd56 Mon Sep 17 00:00:00 2001 From: Anna Sidwell Date: Tue, 20 Aug 2019 00:51:44 +0200 Subject: [PATCH] Modernise urlconf --- apps/map/urls.py | 48 ++++++++++++++++++------------------------------ 1 file changed, 18 insertions(+), 30 deletions(-) diff --git a/apps/map/urls.py b/apps/map/urls.py index f7d18a3..b4e1953 100644 --- a/apps/map/urls.py +++ b/apps/map/urls.py @@ -1,4 +1,4 @@ -from django.conf.urls import url +from django.urls import path from django.urls import reverse_lazy from django.views.generic import RedirectView from django.views.i18n import JavaScriptCatalog @@ -6,47 +6,35 @@ from django.views.i18n import JavaScriptCatalog from . import views urlpatterns = [ - url(r"^$", RedirectView.as_view(url=reverse_lazy("map")), name="index"), - url( - r"^case-study/create/?$", views.CreateCaseStudySelector.as_view(), name="create" - ), - url( - r"^case-study/create/short/?$", + path("", RedirectView.as_view(url=reverse_lazy("map")), name="index"), + path("map", views.Map.as_view(), name="map"), + path("case-study/create", views.CreateCaseStudySelector.as_view(), name="create"), + path( + "case-study/create/short", views.CreateShortCaseStudy.as_view(), name="short-form", ), - url( - r"^case-study/create/long/?$", - views.CreateLongCaseStudy.as_view(), - name="long-form", + path( + "case-study/create/long", views.CreateLongCaseStudy.as_view(), name="long-form" ), - url( - r"^case-study/create/poi/?$", + path( + "case-study/create/poi", views.CreatePointOfInterest.as_view(), name="point-of-interest-form", ), - url( - r"^case-study/create/success/?$", + path( + "case-study/create/success", views.CreateCaseStudySuccess.as_view(), name="form-success", ), - url( - r"^case-study/edit/(?P[\d]+)/?$", views.EditCaseStudy.as_view(), name="edit" - ), - # Case study drafts - url(r"^case-study/draft/?$", views.DraftsAPI.as_view(), name="drafts"), - # View case studies + path("case-study/edit/", views.EditCaseStudy.as_view(), name="edit"), + path("case-study/draft", views.DraftsAPI.as_view(), name="drafts"), # This should be last so that the above options will be tried first! - url( - r"^case-study/(?P[-\w]+)/?$", - views.ViewCaseStudyDetail.as_view(), - name="detail", - ), - url(r"^map/?$", views.Map.as_view(), name="map"), + path("case-study/", views.ViewCaseStudyDetail.as_view(), name="detail"), # API - url(r"^jsi18n/$", JavaScriptCatalog.as_view(), name="javascript-catalogue"), - url( - r"^srs-autocomplete/$", + path("jsi18n", JavaScriptCatalog.as_view(), name="javascript-catalogue"), + path( + "srs-autocomplete", views.SpatialRefSysAutocomplete.as_view(), name="srs-autocomplete", ),