chore: use path rather than re_path in urls.py

This commit is contained in:
Alexis Métaireau 2024-02-22 15:08:13 +01:00
parent 1415f96c6f
commit d18a32b5d3

View file

@ -21,8 +21,6 @@ from .utils import decorated_patterns
admin.autodiscover() admin.autodiscover()
uuid = r"[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}"
urlpatterns = [ urlpatterns = [
re_path(r"^admin/", admin.site.urls), re_path(r"^admin/", admin.site.urls),
re_path("", include("social_django.urls", namespace="social")), re_path("", include("social_django.urls", namespace="social")),
@ -74,18 +72,18 @@ i18n_urls = [
] ]
i18n_urls += decorated_patterns( i18n_urls += decorated_patterns(
[can_view_map, cache_control(must_revalidate=True)], [can_view_map, cache_control(must_revalidate=True)],
re_path( path(
r"^datalayer/(?P<map_id>\d+)/(?P<pk>" + uuid + ")/$", "datalayer/<int:map_id>/<uuid:pk>/",
views.DataLayerView.as_view(), views.DataLayerView.as_view(),
name="datalayer_view", name="datalayer_view",
), ),
re_path( path(
r"^datalayer/(?P<map_id>\d+)/(?P<pk>" + uuid + r")/versions/$", "datalayer/<int:map_id>/<uuid:pk>/versions/",
views.DataLayerVersions.as_view(), views.DataLayerVersions.as_view(),
name="datalayer_versions", name="datalayer_versions",
), ),
re_path( path(
r"^datalayer/(?P<map_id>\d+)/(?P<pk>" + uuid + r")/(?P<name>" + uuid + r"[_\w]+.geojson)$", "datalayer/<int:map_id>/<uuid:pk>/<str:name>",
views.DataLayerVersion.as_view(), views.DataLayerVersion.as_view(),
name="datalayer_version", name="datalayer_version",
), ),
@ -147,13 +145,13 @@ map_urls = [
views.DataLayerCreate.as_view(), views.DataLayerCreate.as_view(),
name="datalayer_create", name="datalayer_create",
), ),
re_path( path(
r"^map/(?P<map_id>[\d]+)/datalayer/delete/(?P<pk>" + uuid + r")/$", "map/<int:map_id>/datalayer/delete/<uuid:pk>/",
views.DataLayerDelete.as_view(), views.DataLayerDelete.as_view(),
name="datalayer_delete", name="datalayer_delete",
), ),
re_path( path(
r"^map/(?P<map_id>[\d]+)/datalayer/permissions/(?P<pk>" + uuid + r"\d+)/$", "map/<int:map_id>/datalayer/permissions/<uuid:pk>/",
views.UpdateDataLayerPermissions.as_view(), views.UpdateDataLayerPermissions.as_view(),
name="datalayer_permissions", name="datalayer_permissions",
), ),
@ -167,8 +165,7 @@ if settings.DEFAULT_FROM_EMAIL:
) )
) )
datalayer_urls = [ datalayer_urls = [
re_path( path("map/<int:map_id>/datalayer/update/<uuid:pk>/",
r"^map/(?P<map_id>[\d]+)/datalayer/update/(?P<pk>" + uuid + r")/$",
views.DataLayerUpdate.as_view(), views.DataLayerUpdate.as_view(),
name="datalayer_update", name="datalayer_update",
), ),