# (c) cavaliba.com - core urls.py

from django.conf import settings
from django.contrib import admin
from django.contrib.auth.views import LoginView, PasswordChangeDoneView, PasswordChangeView
from django.urls import include, path

import app_home.views

# import debug_toolbar
import app_sirene.views

admin.site.site_header = "CAVALIBA DB ADMIN"
admin.site.site_title = "Cavaliba"
admin.site.site_name = "Cavaliba Admin Tools"


# '' or 'tw4'
HTML_TEMPLATE_PATH = settings.CAVALIBA_HTML_FRAMEWORK


# core URLS

urlpatterns = [
    # /status/   => app_home status
    path("status/", app_home.views.status, name="status"),
    # /  >> /sirene/
    path("", app_sirene.views.index),
    # home/  >> app_home
    path("home/", include("app_home.urls")),
    # sirene/
    path("sirene/", include("app_sirene.urls")),
    #    path('', include('app_sirene.urls')),
    # user/
    # path('user/', include('app_user.urls')),
    # data/
    path("data/", include("app_data.urls")),
    # appstatus/
    path("appstatus/", include("app_status.urls")),
    # ipam/
    path("ipam/", include("app_ipam.urls")),
    # api
    path("api/", include("app_data.api.urls")),
    # local django auth
    path(
        "accounts/login/",
        LoginView.as_view(template_name=f"registration/{HTML_TEMPLATE_PATH}/login.html"),
        name="login",
    ),
    path(
        "accounts/password_change/",
        PasswordChangeView.as_view(
            template_name=f"registration/{HTML_TEMPLATE_PATH}/password_change.html"
        ),
        name="password_change",
    ),
    path(
        "accounts/password_change/done/",
        PasswordChangeDoneView.as_view(
            template_name=f"registration/{HTML_TEMPLATE_PATH}/password_change_done.html"
        ),
        name="password_change_done",
    ),
    path("accounts/", include("django.contrib.auth.urls")),
    # django admin
    path("private/admin/", admin.site.urls),
    path("private/tinymce/", include("tinymce.urls")),
]


# Conditional DDT django debug toolbar

if settings.DEBUG:
    try:
        import debug_toolbar

        urlpatterns = urlpatterns + [path("private/__debug__/", include(debug_toolbar.urls))]
    except ImportError:
        pass
