# backend/urls.py  (production-ready — works at /school/ sub-path)
from django.contrib import admin
from django.urls import path, include
from django.conf import settings
from django.conf.urls.static import static
from core.views import HomeView, DashboardView

urlpatterns = [
    path('', HomeView.as_view(), name='home'),
    path('dashboard/', DashboardView.as_view(), name='dashboard'),
    path('students/', include('students.urls')),
    path('staff/', include('staff.urls')),
    path('academics/', include('academics.urls')),
    path('attendance/', include('academics.attendance_urls')),

    # Report Cards — preview, single PDF, bulk class PDF
    path('academics/', include('academics.urls_report_cards')),

    path('finance/', include('finance.urls')),
    path('parents/', include('parents.urls')),
    path('reports/', include('reports.urls')),
    path('communication/', include('communication.urls')),
    path('api/', include('api.urls')),
    path('admin/', admin.site.urls),
]

# Serve media files via Django — required on InMotion shared hosting
# where Apache cannot be configured to serve /portal/media/ directly
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

handler403 = 'core.views.handler_403'
handler404 = 'core.views.handler_404'