Skip to content

Commit

Permalink
Remove re_path URL dispatcher from urls
Browse files Browse the repository at this point in the history
  • Loading branch information
Dhwaniartefact authored Apr 5, 2024
1 parent b3a3643 commit 622d6e2
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 62 deletions.
13 changes: 5 additions & 8 deletions storage_service/administration/urls.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from administration import views
from django.urls import path
from django.urls import re_path

app_name = "administration"
urlpatterns = [
Expand All @@ -10,17 +9,15 @@
path("version/", views.version_view, name="version"),
path("users/", views.user_list, name="user_list"),
path("users/create/", views.user_create, name="user_create"),
re_path(r"^users/(?P<id>[-\w]+)/edit/$", views.user_edit, name="user_edit"),
re_path(r"^users/(?P<id>[-\w]+)/$", views.user_detail, name="user_detail"),
path("users/<int:id>/edit/", views.user_edit, name="user_edit"),
path("users/<int:id>/", views.user_detail, name="user_detail"),
path("language/", views.change_language, name="change_language"),
path("keys/", views.key_list, name="key_list"),
re_path(
r"^keys/(?P<key_fingerprint>[\w]+)/detail$", views.key_detail, name="key_detail"
),
path("keys/<str:key_fingerprint>/detail", views.key_detail, name="key_detail"),
path("keys/create/", views.key_create, name="key_create"),
path("keys/import/", views.key_import, name="key_import"),
re_path(
r"^keys/(?P<key_fingerprint>[\w]+)/delete/$",
path(
"keys/<str:key_fingerprint>/delete/",
views.key_delete,
name="key_delete",
),
Expand Down
4 changes: 2 additions & 2 deletions storage_service/administration/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def user_list(request):

def user_edit(request, id):
edit_allowed = settings.ALLOW_USER_EDITS and (
request.user.has_perm("auth.change_user") or str(request.user.id) == id
request.user.has_perm("auth.change_user") or request.user.id == id
)
if not edit_allowed:
return redirect("administration:user_list")
Expand Down Expand Up @@ -137,7 +137,7 @@ def user_create(request):

def user_detail(request, id):
# Only a superuser or the user themselves can view their full details
view_allowed = request.user.is_superuser or str(request.user.id) == id
view_allowed = request.user.is_superuser or request.user.id == id
if not view_allowed:
return redirect("administration:user_list")

Expand Down
87 changes: 38 additions & 49 deletions storage_service/locations/urls.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,23 @@
from django.urls import path
from django.urls import re_path
from locations import views

UUID = r"\w{8}-\w{4}-\w{4}-\w{4}-\w{12}"

app_name = "locations"
urlpatterns = [
# Sorted by alphabetized categories
# Locations
path("locations/", views.location_list, name="location_list"),
re_path(
r"^locations/(?P<location_uuid>" + UUID + ")/$",
path(
"locations/<uuid:location_uuid>/",
views.location_detail,
name="location_detail",
),
re_path(
r"^locations/(?P<location_uuid>" + UUID + ")/delete/$",
path(
"locations/<uuid:location_uuid>/delete/",
views.location_delete,
name="location_delete",
),
re_path(
r"^locations/(?P<location_uuid>" + UUID + ")/switch_enabled/$",
path(
"locations/<uuid:location_uuid>/switch_enabled/",
views.location_switch_enabled,
name="location_switch_enabled",
),
Expand All @@ -32,13 +29,13 @@
views.package_delete_request,
name="package_delete_request",
),
re_path(
r"^packages/(?P<uuid>" + UUID + ")/delete/$",
path(
"packages/<uuid:uuid>/delete/",
views.package_delete,
name="package_delete",
),
re_path(
r"^packages/(?P<uuid>" + UUID + ")/update_status/$",
path(
"packages/<uuid:uuid>/update_status/",
views.package_update_status,
name="package_update_status",
),
Expand All @@ -47,65 +44,57 @@
views.aip_recover_request,
name="aip_recover_request",
),
re_path(
r"^packages/(?P<package_uuid>" + UUID + ")/reingest/$",
path(
"packages/<uuid:package_uuid>/reingest/",
views.aip_reingest,
name="aip_reingest",
),
# Fixity check results
re_path(
r"^fixity/(?P<package_uuid>" + UUID + ")/$",
path(
"fixity/<uuid:package_uuid>/",
views.package_fixity,
name="package_fixity",
),
path("fixity_ajax/", views.fixity_logs_ajax, name="fixity_logs_ajax"),
# Pipelines
path("pipelines/", views.pipeline_list, name="pipeline_list"),
path("pipelines/create/", views.pipeline_edit, name="pipeline_create"),
re_path(
r"^pipeline/(?P<uuid>" + UUID + ")/edit/$",
path(
"pipeline/<uuid:uuid>/edit/",
views.pipeline_edit,
name="pipeline_edit",
),
re_path(
r"^pipeline/(?P<uuid>" + UUID + ")/detail/$",
path(
"pipeline/<uuid:uuid>/detail/",
views.pipeline_detail,
name="pipeline_detail",
),
re_path(
r"^pipeline/(?P<uuid>" + UUID + ")/delete/$",
path(
"pipeline/<uuid:uuid>/delete/",
views.pipeline_delete,
name="pipeline_delete",
),
re_path(
r"^pipeline/(?P<uuid>" + UUID + ")/switch_enabled/$",
path(
"pipeline/<uuid:uuid>/switch_enabled/",
views.pipeline_switch_enabled,
name="pipeline_switch_enabled",
),
# Spaces
path("spaces/", views.space_list, name="space_list"),
re_path(
r"^spaces/(?P<uuid>" + UUID + ")/$", views.space_detail, name="space_detail"
),
re_path(
r"^spaces/(?P<uuid>" + UUID + ")/edit/$", views.space_edit, name="space_edit"
),
re_path(
r"^spaces/(?P<uuid>" + UUID + ")/delete/$",
path("spaces/<uuid:uuid>/", views.space_detail, name="space_detail"),
path("spaces/<uuid:uuid>/edit/", views.space_edit, name="space_edit"),
path(
"spaces/<uuid:uuid>/delete/",
views.space_delete,
name="space_delete",
),
re_path(
r"^spaces/(?P<space_uuid>" + UUID + ")/location_create/$",
path(
"spaces/<uuid:space_uuid>/location_create/",
views.location_edit,
name="location_create",
),
re_path(
r"^spaces/(?P<space_uuid>"
+ UUID
+ ")/location/(?P<location_uuid>"
+ UUID
+ ")/edit/$",
path(
"spaces/<uuid:space_uuid>/location/<uuid:location_uuid>/edit/",
views.location_edit,
name="location_edit",
),
Expand All @@ -118,24 +107,24 @@
),
# Callbacks
path("callbacks/", views.callback_list, name="callback_list"),
re_path(
r"^callbacks/(?P<uuid>" + UUID + ")/$",
path(
"callbacks/<uuid:uuid>/",
views.callback_detail,
name="callback_detail",
),
path("callbacks/create/", views.callback_edit, name="callback_create"),
re_path(
r"^callbacks/(?P<uuid>" + UUID + ")/edit/$",
path(
"callbacks/<uuid:uuid>/edit/",
views.callback_edit,
name="callback_edit",
),
re_path(
r"^callbacks/(?P<uuid>" + UUID + ")/delete/$",
path(
"callbacks/<uuid:uuid>/delete/",
views.callback_delete,
name="callback_delete",
),
re_path(
r"^callbacks/(?P<uuid>" + UUID + ")/switch_enabled/$",
path(
"callbacks/<uuid:uuid>/switch_enabled/",
views.callback_switch_enabled,
name="callback_switch_enabled",
),
Expand Down
4 changes: 1 addition & 3 deletions storage_service/storage_service/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,14 @@
from django.contrib import admin
from django.urls import include
from django.urls import path
from django.urls import re_path
from django.views.generic import TemplateView

from storage_service import views


urlpatterns = [
path("", TemplateView.as_view(template_name="index.html")),
# Uncomment the next line to enable the admin:
re_path(r"^admin/", admin.site.urls),
path("admin/", admin.site.urls),
path("", include(locations.urls)),
path("administration/", include(administration.urls)),
path("api/", include(locations.api.urls)),
Expand Down

0 comments on commit 622d6e2

Please sign in to comment.