from django.urls import include, path
from rest_framework import routers
from rest_framework.authtoken.views import obtain_auth_token

from . import views
from sync.views import SynchronizationApi, UserDataAccessApi, DataAccessViewSet
from authentication.views import CustomAuthToken, Logout, ChangePasswordView

router = routers.DefaultRouter()
router.register(r'users', views.UserViewSet)
router.register(r'user-names', views.ShortUserViewSet)
router.register(r'clubs', views.ClubViewSet)
router.register(r'tournaments', views.TournamentViewSet)
router.register(r'events', views.EventViewSet)
router.register(r'rounds', views.RoundViewSet)
router.register(r'group-stages', views.GroupStageViewSet)
router.register(r'matches', views.MatchViewSet)
router.register(r'team-scores', views.TeamScoreViewSet)
router.register(r'team-registrations', views.TeamRegistrationViewSet)
router.register(r'player-registrations', views.PlayerRegistrationViewSet)
router.register(r'purchases', views.PurchaseViewSet)
router.register(r'courts', views.CourtViewSet)
router.register(r'date-intervals', views.DateIntervalViewSet)
router.register(r'draw-logs', views.DrawLogViewSet)
router.register(r'failed-api-calls', views.FailedApiCallViewSet)
router.register(r'logs', views.LogViewSet)
router.register(r'device-token', views.DeviceTokenViewSet)
router.register(r'data-access', DataAccessViewSet)
router.register(r'unregistered-teams', views.UnregisteredTeamViewSet)
router.register(r'unregistered-players', views.UnregisteredPlayerViewSet)

urlpatterns = [
    path('', include(router.urls)),

    path('sync-data/', SynchronizationApi.as_view(), name="data"),
    path('data-access/', UserDataAccessApi.as_view(), name="user-data-access"),

    path('api-token-auth/', obtain_auth_token, name='api_token_auth'),
    path("user-by-token/", views.user_by_token, name="user_by_token"),

    # authentication
    path("change-password/", ChangePasswordView.as_view(), name="change_password"),
    path('token-auth/', CustomAuthToken.as_view()),
    path('api-token-logout/', Logout.as_view()),

    # forgotten password
    path('dj-rest-auth/', include('dj_rest_auth.urls')),

]
