chore(api): route using urls

Allow to register function views in the same app instead of globaly.
This commit is contained in:
jo 2022-07-19 18:38:17 +02:00 committed by Jonas L
parent 33e5e8ada3
commit 0e3ede5a1a
6 changed files with 22 additions and 14 deletions

View File

@ -20,3 +20,5 @@ router.register("users", UserViewSet)
router.register("user-tokens", UserTokenViewSet)
router.register("celery-tasks", CeleryTaskViewSet)
router.register("third-party-track-references", ThirdPartyTrackReferenceViewSet)
urls = router.urls

View File

@ -20,3 +20,5 @@ router.register("playout-history-metadata", PlayoutHistoryMetadataViewSet)
router.register("playout-history-templates", PlayoutHistoryTemplateViewSet)
router.register("playout-history-template-fields", PlayoutHistoryTemplateFieldViewSet)
router.register("timestamps", TimestampViewSet)
urls = router.urls

View File

@ -12,3 +12,5 @@ router.register("podcast-episodes", PodcastEpisodeViewSet)
router.register("podcasts", PodcastViewSet)
router.register("station-podcasts", StationPodcastViewSet)
router.register("imported-podcasts", ImportedPodcastViewSet)
urls = router.urls

View File

@ -30,3 +30,5 @@ router.register("smart-block-criteria", SmartBlockCriteriaViewSet)
router.register("smart-blocks", SmartBlockViewSet)
router.register("webstream-metadata", WebstreamMetadataViewSet)
router.register("webstreams", WebstreamViewSet)
urls = router.urls

View File

@ -5,3 +5,5 @@ from .views import FileViewSet, LibraryViewSet
router = routers.DefaultRouter()
router.register("files", FileViewSet)
router.register("libraries", LibraryViewSet)
urls = router.urls

View File

@ -6,26 +6,24 @@ https://docs.djangoproject.com/en/3.2/topics/http/urls/
"""
from django.urls import include, path
from drf_spectacular.views import SpectacularAPIView, SpectacularSwaggerView
from rest_framework import routers
from .core.router import router as core_router
from .core.router import urls as core_urls
from .core.views import version
from .history.router import router as history_router
from .podcasts.router import router as podcasts_router
from .schedule.router import router as schedule_router
from .storage.router import router as storage_router
from .history.router import urls as history_urls
from .podcasts.router import urls as podcasts_urls
from .schedule.router import urls as schedule_urls
from .storage.router import urls as storage_urls
router = routers.DefaultRouter()
router.registry.extend(core_router.registry)
router.registry.extend(history_router.registry)
router.registry.extend(podcasts_router.registry)
router.registry.extend(schedule_router.registry)
router.registry.extend(storage_router.registry)
api_urls = []
api_urls += core_urls
api_urls += history_urls
api_urls += podcasts_urls
api_urls += schedule_urls
api_urls += storage_urls
urlpatterns = [
path("api/v2/", include(router.urls)),
path("api/v2/", include(api_urls)),
path("api/v2/version/", version),
path(
"api/v2/schema/",