from django.urls import include, path
from rest_framework.routers import DefaultRouter
from .views import HubViewSet, HubPermissionViewSet, TagsViewSet

hub_router = DefaultRouter()
hub_router.register('', HubViewSet, basename='hub')

moderators_router = DefaultRouter()
moderators_router.register('', HubPermissionViewSet, basename='hub-moderator')

tags_router = DefaultRouter()
tags_router.register('', TagsViewSet, basename='hub-tag')

# moderators/ and tags/ must be declared BEFORE the hub router urls so that
# Django resolves them before the hub's generic /{pk}/ pattern can swallow them.
urlpatterns = [
    path('moderators/', include(moderators_router.urls)),
    path('tags/', include(tags_router.urls)),
] + hub_router.urls
