diff --git a/src/config/settings/base.py b/src/config/settings/base.py index 6bcbdc8..88fff1f 100644 --- a/src/config/settings/base.py +++ b/src/config/settings/base.py @@ -14,6 +14,7 @@ INSTALLED_APPS = [ "django.contrib.humanize", "rest_framework", "openclaw", + "openclaw_daily", ] MIDDLEWARE = [ diff --git a/src/openclaw/admin_custom_site.py b/src/openclaw/admin_custom_site.py index ce291b4..01e8e4e 100644 --- a/src/openclaw/admin_custom_site.py +++ b/src/openclaw/admin_custom_site.py @@ -1,9 +1,10 @@ """ -Custom AdminSite for OpenClaw — adds Daily Report to sidebar + URLs. -Re-registers Session/Message/ToolCall from admin.py, and adds custom report URLs. +Custom AdminSite for OpenClaw — adds Daily Report to sidebar. """ from django.contrib.admin import AdminSite +from django.contrib.admin.sites import AdminSite +from django.urls import path from openclaw.admin_new_views import daily_report_list_view, daily_report_detail_view @@ -14,7 +15,6 @@ class OpenClawAdminSite(AdminSite): index_title = "Agent Sessions" def get_urls(self): - from django.urls import path urls = super().get_urls() custom_urls = [ path( @@ -35,15 +35,35 @@ class OpenClawAdminSite(AdminSite): ] return custom_urls + urls - def index(self, request, extra_context=None): - extra_context = extra_context or {} - extra_context["show_daily_report"] = True - return super().index(request, extra_context) + def get_app_list(self, request, app_label=None): + """ + Inject 'Daily Reports' as a sidebar app item, before the OpenClaw app. + """ + app_list = super().get_app_list(request, app_label) + + # Our custom item to inject + daily_reports_item = { + "name": "Daily Reports", + "app_label": "openclaw_daily", + "app_url": "/admin/daily-reports/", + "models": [ + { + "name": "Daily Reports", + "object_name": "DailyReports", + "admin_url": "/admin/daily-reports/", + "view_only": True, + }, + ], + } + + # Insert at the top of the app list + app_list.insert(0, daily_reports_item) + return app_list openclaw_admin_site = OpenClawAdminSite(name="openclaw_admin") -# Re-register models with this custom site (imported from admin.py) +# Re-register models with this custom site from openclaw.admin import SessionAdmin, MessageAdmin, ToolCallAdmin from openclaw.models import Session, Message, ToolCall diff --git a/src/openclaw_daily/__init__.py b/src/openclaw_daily/__init__.py new file mode 100644 index 0000000..7cef06e --- /dev/null +++ b/src/openclaw_daily/__init__.py @@ -0,0 +1 @@ +default_app_config = "openclaw_daily.apps.OpenClawDailyConfig" diff --git a/src/openclaw_daily/apps.py b/src/openclaw_daily/apps.py new file mode 100644 index 0000000..02fdb94 --- /dev/null +++ b/src/openclaw_daily/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + +class OpenClawDailyConfig(AppConfig): + name = "openclaw_daily" + label = "openclaw_daily" + verbose_name = "Daily Reports" diff --git a/src/templates/admin/index.html b/src/templates/admin/index.html deleted file mode 100644 index d0fc367..0000000 --- a/src/templates/admin/index.html +++ /dev/null @@ -1,24 +0,0 @@ -{% extends "admin/index.html" %} -{% load static %} - -{% block branding %} -

- {{ site_header|default:"Django Admin" }} -

-{% endblock %} - -{% block nav-sidebar %} -{{ block.super }} - -{# Daily Report custom sidebar item #} -
- - -
- - 📊 Daily Reports - -
-
- -{% endblock %}