|
1 | 1 | """URL routing for the CTJ API; mounted at `/api/` from `backend.urls`. |
2 | 2 |
|
3 | | -Five resource routers are auto-registered via DRF's `DefaultRouter`, |
4 | | -which generates standard list/detail paths for each ViewSet. |
5 | | -Two explicit `path()` entries (`healthcheck` and `users/<uuid>/`) |
6 | | -sit alongside, and a catch-all `re_path` at the end returns a JSON |
7 | | -404 (via `api_not_found`) for anything else under `/api/*`. |
| 3 | +One resource (`opportunities`) is auto-routed via DRF's |
| 4 | +`DefaultRouter` because it's a full-CRUD `ModelViewSet`. Every |
| 5 | +other endpoint is an explicit `path()` entry pointing at a |
| 6 | +function-based view (see `ctj_api.views` for the shape rule): |
| 7 | +
|
| 8 | +- `healthcheck`: the liveness endpoint. |
| 9 | +- `users/<uuid>/`: the per-user detail FBV. |
| 10 | +- `communityOfPractice/`, `roles/`, `skills/`, `projects/`: |
| 11 | + list + detail FBV pairs for read-only catalog resources. |
| 12 | +
|
| 13 | +A catch-all `re_path` at the end returns a JSON 404 (via |
| 14 | +`api_not_found`) for anything else under `/api/*`. |
8 | 15 |
|
9 | 16 | Order matters: the catch-all is last; if it moved up, it would |
10 | | -match before the explicit paths and shadow them. |
| 17 | +match before the explicit paths and shadow them. The router |
| 18 | +include sits before the catch-all for the same reason. |
11 | 19 | """ |
12 | 20 |
|
13 | 21 | from django.urls import include, path, re_path |
|
17 | 25 |
|
18 | 26 | router = DefaultRouter() |
19 | 27 | router.register(r"opportunities", views.OpportunityViewSet) |
20 | | -router.register(r"communityOfPractice", views.CommunityOfPracticeViewSet) |
21 | | -router.register(r"roles", views.RoleViewSet) |
22 | | -router.register(r"skills", views.SkillViewSet) |
23 | | -router.register(r"projects", views.ProjectViewSet) |
24 | 28 |
|
25 | 29 | urlpatterns = [ |
26 | 30 | path("healthcheck", views.healthcheck, name="healthcheck"), |
| 31 | + path("users/<uuid:pk>/", views.user_detail), |
| 32 | + path("communityOfPractice/", views.community_of_practice_list), |
| 33 | + path( |
| 34 | + "communityOfPractice/<uuid:pk>/", |
| 35 | + views.community_of_practice_detail, |
| 36 | + ), |
| 37 | + path("roles/", views.role_list), |
| 38 | + path("roles/<uuid:pk>/", views.role_detail), |
| 39 | + path("skills/", views.skill_list), |
| 40 | + path("skills/<uuid:pk>/", views.skill_detail), |
| 41 | + path("projects/", views.project_list), |
| 42 | + path("projects/<uuid:pk>/", views.project_detail), |
27 | 43 | re_path(r"^", include(router.urls)), |
28 | | - path("users/<uuid:pk>/", views.UserDetail.as_view()), |
29 | 44 | # Catch-all for incorrect API routes |
30 | 45 | re_path(r"^.*$", views.api_not_found), |
31 | 46 | ] |
0 commit comments