Add tags and tag-based stream filtering

Implements tag management (create/delete) and per-article tagging with
a freeform "add tag" input that creates the tag on first use instead
of requiring a separate create-then-assign flow. Tags render as pills
in the stream header; clicking one filters the stream to articles
carrying that tag, combinable with the existing read/starred/saved
filters.

The "Saved" filter already added in the reading-UI milestone functions
as the reading list, so this closes out the reading-list/tags
milestone without a separate dedicated view.

Verified live in-browser: creating a tag from an article, the pill
appearing in the stream nav, filtering by it, and deleting it from the
tag-management page, all via htmx without full page reloads.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
ksmithandClaude Sonnet 5 committed 2026-10-30 16:26:30 -06:00
1 parent 69e3520e3b
commit 579696efc0
12 files changed
+386 -5

No files matched your search

+12 -1
View File
@@ -5,7 +5,7 @@ from django.shortcuts import get_object_or_404, render
from django.utils import timezone
from django.views.decorators.http import require_POST
from apps.articles.models import Article, UserArticleState
from apps.articles.models import Article, Tag, UserArticleState
FILTER_CHOICES = [
("unread", "Unread"),
@@ -65,6 +65,15 @@ def stream(request):
user_states__user=request.user, user_states__is_saved_for_later=True
)
active_tag = None
tag_id = request.GET.get("tag")
if tag_id:
active_tag = Tag.objects.filter(user=request.user, pk=tag_id).first()
if active_tag:
queryset = queryset.filter(
article_tags__user=request.user, article_tags__tag=active_tag
)
try:
page = max(int(request.GET.get("page", 1)), 1)
except ValueError:
@@ -78,6 +87,8 @@ def stream(request):
"articles": articles,
"active_filter": active_filter,
"filters": FILTER_CHOICES,
"active_tag": active_tag,
"user_tags": Tag.objects.filter(user=request.user),
"page": page,
"has_next_page": end < total_count,
"has_previous_page": page > 1,