"""konova URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/3.1/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  path('', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.urls import include, path
    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
"""
import debug_toolbar
from django.contrib import admin
from django.urls import path, include

from konova.settings import SSO_SERVER, SSO_PUBLIC_KEY, SSO_PRIVATE_KEY, DEBUG
from konova.sso.sso import KonovaSSOClient
from konova.views.logout import logout_view
from konova.views.geometry import get_geom_parcels, get_geom_parcels_content
from konova.views.home import home_view
from konova.views.map_proxy import ClientProxyParcelSearch, ClientProxyParcelWFS

sso_client = KonovaSSOClient(SSO_SERVER, SSO_PUBLIC_KEY, SSO_PRIVATE_KEY)
urlpatterns = [
    path('admin/', admin.site.urls),
    path('login/', include(sso_client.get_urls())),
    path('logout/', logout_view, name="logout"),
    path('', home_view, name="home"),
    path('intervention/', include("intervention.urls")),
    path('compensation/', include("compensation.urls")),
    path('ema/', include("ema.urls")),
    path('user/', include("user.urls")),
    path('news/', include("news.urls")),
    path('cl/', include("codelist.urls")),
    path('analysis/', include("analysis.urls")),
    path('api/', include("api.urls")),
    path('geom/<id>/parcels/', get_geom_parcels, name="geometry-parcels"),
    path('geom/<id>/parcels/<int:page>', get_geom_parcels_content, name="geometry-parcels-content"),
    path('client/proxy', ClientProxyParcelSearch.as_view(), name="client-proxy-search"),
    path('client/proxy/wfs', ClientProxyParcelWFS.as_view(), name="client-proxy-wfs"),
]

if DEBUG:
    urlpatterns += [
        path('__debug__/', include(debug_toolbar.urls)),
    ]

handler404 = "konova.views.error.get_404_view"
handler500 = "konova.views.error.get_500_view"