Skip to content

Commit 5500e50

Browse files
refactor: simplify invitation URL routing with DefaultRouter
- Replaced manual URL paths for workspace invitations with a DefaultRouter for cleaner routing. - Updated imports for better organization and clarity.
1 parent 65d8520 commit 5500e50

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

apps/api/plane/api/urls/invite.py

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
1-
from django.urls import path
1+
# Django imports
2+
from django.urls import path, include
23

3-
from plane.api.views import (
4-
WorkspaceInvitationsViewset,
5-
)
4+
# Third party imports
5+
from rest_framework.routers import DefaultRouter
66

7+
# Module imports
8+
from plane.api.views import WorkspaceInvitationsViewset
79

10+
11+
# Create router with just the invitations prefix (no workspace slug)
12+
router = DefaultRouter()
13+
router.register(r"invitations", WorkspaceInvitationsViewset, basename="workspace-invitations")
14+
15+
# Wrap the router URLs with the workspace slug path
816
urlpatterns = [
9-
path(
10-
"workspaces/<str:slug>/invitations/",
11-
WorkspaceInvitationsViewset.as_view({"get": "list", "post": "create"}),
12-
name="workspace-invitations",
13-
),
14-
path(
15-
"workspaces/<str:slug>/invitations/<uuid:pk>/",
16-
WorkspaceInvitationsViewset.as_view({"get": "retrieve", "delete": "destroy", "patch": "partial_update"}),
17-
name="workspace-invitations",
18-
),
17+
path("workspaces/<str:slug>/", include(router.urls)),
1918
]

0 commit comments

Comments
 (0)