Private
Public Access
Add hardening and deployment: admin dashboard, security headers, install docs
Adds an admin-only dashboard (apps/core) surfacing feeds that are failing to fetch, with error messages, subscriber counts, and a one-click retry that resets backoff and re-queues the fetch. Hardens config/settings/prod.py with the remaining standard Django security settings (HSTS preload, nosniff, referrer-policy, frame-options, SameSite cookies) plus a Content-Security-Policy header via django-csp, as a second layer behind nh3's HTML sanitization of feed content. Adds docs/install.md (pip + gunicorn + systemd + nginx, SQLite and Postgres both covered) plus the systemd units and nginx snippet it references, LICENSE (AGPL-3.0-or-later, matching pyproject.toml), and an updated README. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
7577110238
commit
3f6474ce94
16 files changed
+1226
-6
No files matched your search
+43
-1
@@ -1 +1,43 @@
|
||||
# Create your views here.
|
||||
from django.contrib import messages
|
||||
from django.contrib.auth.decorators import user_passes_test
|
||||
from django.db.models import Count, Q
|
||||
from django.shortcuts import get_object_or_404, redirect, render
|
||||
from django.views.decorators.http import require_POST
|
||||
|
||||
from apps.articles.models import Article
|
||||
from apps.feeds.models import Feed, Subscription
|
||||
from apps.feeds.tasks import fetch_feed, reset_feed_backoff
|
||||
|
||||
is_admin = user_passes_test(lambda u: u.is_authenticated and u.is_staff)
|
||||
|
||||
|
||||
@is_admin
|
||||
def dashboard(request):
|
||||
feeds = Feed.objects.annotate(subscriber_count=Count("subscriptions"))
|
||||
erroring_feeds = feeds.filter(
|
||||
Q(last_fetch_status=Feed.STATUS_ERROR) | Q(fetch_error_count__gt=0)
|
||||
).order_by("-fetch_error_count")
|
||||
|
||||
stats = {
|
||||
"feed_count": feeds.count(),
|
||||
"active_feed_count": feeds.filter(is_active=True).count(),
|
||||
"error_feed_count": erroring_feeds.count(),
|
||||
"subscription_count": Subscription.objects.count(),
|
||||
"article_count": Article.objects.count(),
|
||||
}
|
||||
|
||||
return render(
|
||||
request,
|
||||
"core/dashboard.html",
|
||||
{"stats": stats, "erroring_feeds": erroring_feeds},
|
||||
)
|
||||
|
||||
|
||||
@is_admin
|
||||
@require_POST
|
||||
def retry_feed(request, feed_id):
|
||||
feed = get_object_or_404(Feed, pk=feed_id)
|
||||
reset_feed_backoff.delay(feed.id)
|
||||
fetch_feed.delay(feed.id)
|
||||
messages.success(request, f"Queued an immediate retry for '{feed.title or feed.feed_url}'.")
|
||||
return redirect("core:dashboard")
|
||||
Reference in new issue
Block a user