from django.urls import include, path from rest_framework_nested import routers from apps.alerts.views import ProjectAlertViewSet from apps.environments.views import EnvironmentProjectViewSet from apps.releases.views import ReleaseFileViewSet, ReleaseViewSet from .views import ProjectKeyViewSet, ProjectViewSet router = routers.SimpleRouter() router.register(r"projects", ProjectViewSet) projects_router = routers.NestedSimpleRouter(router, r"projects", lookup="project") projects_router.register(r"keys", ProjectKeyViewSet, basename="project-keys") projects_router.register(r"alerts", ProjectAlertViewSet, basename="project-alerts") projects_router.register( r"environments", EnvironmentProjectViewSet, basename="project-environments" ) projects_router.register(r"releases", ReleaseViewSet, basename="project-releases") releases_router = routers.NestedSimpleRouter( projects_router, r"releases", lookup="release" ) releases_router.register(r"files", ReleaseFileViewSet, basename="files") urlpatterns = [ path("", include(router.urls)), path("", include(projects_router.urls)), path("", include(releases_router.urls)), ]