64 lines
2.6 KiB
Python
64 lines
2.6 KiB
Python
"""
|
|
Custom AdminSite for IGNY8 using Unfold theme.
|
|
|
|
SIMPLIFIED VERSION - Navigation is now handled via UNFOLD settings in settings.py
|
|
This file only handles:
|
|
1. Custom URLs for dashboard, reports, and monitoring pages
|
|
2. Index redirect to dashboard
|
|
|
|
All sidebar navigation is configured in settings.py under UNFOLD["SIDEBAR"]["navigation"]
|
|
"""
|
|
from django.contrib import admin
|
|
from django.urls import path
|
|
from django.shortcuts import redirect
|
|
from unfold.sites import UnfoldAdminSite
|
|
|
|
|
|
class Igny8AdminSite(UnfoldAdminSite):
|
|
"""
|
|
Custom AdminSite based on Unfold.
|
|
Navigation is handled via UNFOLD settings - this just adds custom URLs.
|
|
"""
|
|
site_header = 'IGNY8 Administration'
|
|
site_title = 'IGNY8 Admin'
|
|
index_title = 'IGNY8 Administration'
|
|
|
|
def get_urls(self):
|
|
"""Add custom URLs for dashboard, reports, and monitoring pages"""
|
|
from .dashboard import admin_dashboard
|
|
from .reports import (
|
|
revenue_report, usage_report, content_report, data_quality_report,
|
|
token_usage_report, ai_cost_analysis
|
|
)
|
|
from .monitoring import (
|
|
system_health_dashboard, api_monitor_dashboard, debug_console
|
|
)
|
|
|
|
urls = super().get_urls()
|
|
custom_urls = [
|
|
# Dashboard
|
|
path('dashboard/', self.admin_view(admin_dashboard), name='dashboard'),
|
|
|
|
# Reports
|
|
path('reports/revenue/', self.admin_view(revenue_report), name='report_revenue'),
|
|
path('reports/usage/', self.admin_view(usage_report), name='report_usage'),
|
|
path('reports/content/', self.admin_view(content_report), name='report_content'),
|
|
path('reports/data-quality/', self.admin_view(data_quality_report), name='report_data_quality'),
|
|
path('reports/token-usage/', self.admin_view(token_usage_report), name='report_token_usage'),
|
|
path('reports/ai-cost-analysis/', self.admin_view(ai_cost_analysis), name='report_ai_cost_analysis'),
|
|
|
|
# Monitoring
|
|
path('monitoring/system-health/', self.admin_view(system_health_dashboard), name='monitoring_system_health'),
|
|
path('monitoring/api-monitor/', self.admin_view(api_monitor_dashboard), name='monitoring_api_monitor'),
|
|
path('monitoring/debug-console/', self.admin_view(debug_console), name='monitoring_debug_console'),
|
|
]
|
|
return custom_urls + urls
|
|
|
|
def index(self, request, extra_context=None):
|
|
"""Redirect admin index to custom dashboard"""
|
|
return redirect('admin:dashboard')
|
|
|
|
|
|
# Instantiate custom admin site
|
|
admin_site = Igny8AdminSite(name='admin')
|