Private
Public Access
Articles and full HTML bodies accumulated forever, growing the database, search index, and backups without bound. Site settings gets a "Retention days" field (0, the default, keeps everything); a nightly beat task deletes articles fetched longer ago than that in bounded chunks, always keeping anything a user starred or saved for later. Read state and tags cascade with the article and the FTS triggers drop search entries. The dashboard shows the article count and oldest article's age, and docs/install.md covers retention, the readiness check, and SQLite's WAL tuning. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
29 lines
977 B
Python
29 lines
977 B
Python
from django.contrib import admin
|
|
from django.shortcuts import redirect
|
|
from django.urls import reverse
|
|
|
|
from .models import SiteSettings
|
|
|
|
|
|
@admin.register(SiteSettings)
|
|
class SiteSettingsAdmin(admin.ModelAdmin):
|
|
"""A true singleton, not a collection — browsing a changelist to pick
|
|
the one row and click into it is an extra, pointless step, so
|
|
"Core > Site settings" in the sidebar goes straight to the (only)
|
|
change form instead, creating the row first if this is a fresh
|
|
install. No changelist/add/delete views exist at all here.
|
|
"""
|
|
|
|
fields = ["fetch_interval_minutes", "retention_days"]
|
|
|
|
def has_add_permission(self, request):
|
|
return False
|
|
|
|
def has_delete_permission(self, request, obj=None):
|
|
return False
|
|
|
|
def changelist_view(self, request, extra_context=None):
|
|
settings_row = SiteSettings.load()
|
|
url = reverse("admin:core_sitesettings_change", args=[settings_row.pk])
|
|
return redirect(url)
|