from api.views import ping, secure_ping
from django.conf import settings
from django.contrib import admin
from django.urls import path, include
from django.shortcuts import render, redirect
from rest_framework import routers
from risks.views import RiskViewSet, ControlViewSet, ResidualRiskViewSet, UserViewSet, AuditViewSet

router = routers.DefaultRouter()
router.register(r"risks", RiskViewSet)
router.register(r"controls", ControlViewSet)
router.register(r"residual-risks", ResidualRiskViewSet)
router.register(r"users", UserViewSet)
router.register(r"logs", AuditViewSet)

urlpatterns = [
    # Risk Management
    path("", include("risks.urls", namespace="risks")),
    # Admin
    path("admin/", admin.site.urls),
    # Login/Logout
    path("accounts/", include("django.contrib.auth.urls")),
    # Language Switch
    path("i18n/", include("django.conf.urls.i18n")),
    # API
    path("api/", include(router.urls)),
    path("api/ping/", ping),
    path("api/secure-ping/", secure_ping),
]

# Add OIDC routes only if Single Sign-On is enabled
if settings.SSO_ENABLED:
    urlpatterns += [
        path("oidc/", include("mozilla_django_oidc.urls")),
    ]
