urls.py 1.1 KB

123456789101112131415161718192021222324252627282930
  1. from django.urls import include, path
  2. from rest_framework_nested import routers
  3. from apps.alerts.views import ProjectAlertViewSet
  4. from apps.environments.views import EnvironmentProjectViewSet
  5. from apps.releases.views import ReleaseFileViewSet, ReleaseViewSet
  6. from .views import ProjectKeyViewSet, ProjectViewSet
  7. router = routers.SimpleRouter()
  8. router.register(r"projects", ProjectViewSet)
  9. projects_router = routers.NestedSimpleRouter(router, r"projects", lookup="project")
  10. projects_router.register(r"keys", ProjectKeyViewSet, basename="project-keys")
  11. projects_router.register(r"alerts", ProjectAlertViewSet, basename="project-alerts")
  12. projects_router.register(
  13. r"environments", EnvironmentProjectViewSet, basename="project-environments"
  14. )
  15. projects_router.register(r"releases", ReleaseViewSet, basename="project-releases")
  16. releases_router = routers.NestedSimpleRouter(
  17. projects_router, r"releases", lookup="release"
  18. )
  19. releases_router.register(r"files", ReleaseFileViewSet, basename="files")
  20. urlpatterns = [
  21. path("", include(router.urls)),
  22. path("", include(projects_router.urls)),
  23. path("", include(releases_router.urls)),
  24. ]