from django.conf import settings
from django.conf.urls.static import static
from django.contrib import admin
from django.urls import path, re_path
from django.views.generic.base import RedirectView

from .datasets import views as dataset_views
from .points import views as points_views


urlpatterns = [
    path("admin/", admin.site.urls),
    re_path(r"admin$", RedirectView.as_view(url="admin/", permanent=True)),
    path("api/v1/datasets/", dataset_views.DatasetList.as_view()),
    path("api/v1/datasets/<int:dataset_id>/indicators/", dataset_views.DatasetIndicatorsList.as_view()),
    path("api/v1/indicators/", dataset_views.IndicatorsList.as_view()),
    path("api/v1/indicators/<int:indicator_id>/", dataset_views.IndicatorDataView.as_view()),
    path("api/v1/indicators/<int:indicator_id>/geographies/<str:geography_code>/", dataset_views.IndicatorDataView.as_view()),
    path("api/v1/profiles/", dataset_views.ProfileList.as_view()),
    path("api/v1/profiles/<int:pk>/", dataset_views.ProfileDetail.as_view()),
    path("api/v1/profiles/<int:profile_id>/geographies/<str:geography_code>/", dataset_views.profile_geography_data),
    path("api/v1/geography/search/", dataset_views.search_geography),
    path("api/v1/points/", points_views.LocationList.as_view()),
    path("api/v1/points/themes/", points_views.ThemeList.as_view()),
    path("api/v1/points/themes/<int:theme_id>/", points_views.LocationList.as_view()),
    path("api/v1/points/categories/", points_views.CategoryList.as_view()),
    path("api/v1/points/categories/<int:category_id>/", points_views.LocationList.as_view()),
    re_path(r"^$", RedirectView.as_view(url="/api/v1/datasets/", permanent=False)),

] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
