Private
Public Access
Remove folders; feeds are organized by tags now
Folders are gone — organization is tags-only, via the SubscriptionTag model added last commit. A migration converts every existing Folder into a same-named Tag applied to its feeds, and every folder-scoped FilterRule into an equivalent tag-scoped one, before the Folder table is dropped, so upgrading an existing instance loses nothing (verified by seeding the pre-removal schema directly and running the migration chain against it). Unlike folders, a feed can carry more than one tag, so: - apps.articles.tasks.apply_filter_rules_for_feed and apps.rules.tasks's backlog re-apply now scope by "does this feed carry tag X" rather than "does this feed belong to folder X". - apps.feeds.opml: a feed's tags export as a comma-separated "category" attribute (the standard OPML way to represent multiple categories) instead of nesting under one folder outline. Import reads both that attribute and nested category outlines, turning each enclosing level into its own tag rather than collapsing to the nearest one. - The sidebar groups feeds by tag instead of folder, so a feed with two tags now appears in both groups; untagged feeds fall into "Untagged". AddFeedForm gained a comma-separated tag_names field for parity with the old add-time folder picker. EditSubscriptionForm dropped its folder field entirely — tagging a subscription happens through the tag editor already on that page. Verified end to end: the migration chain from empty, the data migration against a seeded pre-removal schema (folder/subscription/rule all convert correctly), and the running app's sidebar grouping, OPML export category attributes, and tag editor. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
3b58fdcb7e
commit
0e132e9ab9
24 files changed
+417
-307
No files matched your search
+7
-22
@@ -10,7 +10,7 @@ from django.views.decorators.http import require_POST
|
||||
|
||||
from apps.articles.models import Article, Tag, UserArticleState
|
||||
from apps.articles.queries import with_user_state
|
||||
from apps.feeds.models import Feed, Folder
|
||||
from apps.feeds.models import Feed
|
||||
|
||||
FILTER_CHOICES = [
|
||||
("unread", "Unread"),
|
||||
@@ -39,13 +39,9 @@ def _get_or_create_state(user, article):
|
||||
|
||||
def _apply_scope(request, queryset):
|
||||
"""Narrows an already-base-scoped Article queryset by the optional
|
||||
?tag=/?feed=/?folder= params the sidebar links use. feed_id alone is
|
||||
enough to scope by feed (the base queryset already restricts to the
|
||||
user's own subscriptions); folder_id must be combined with user in the
|
||||
same .filter() call — Feed is shared across users, so a separate call
|
||||
would match any user's subscription with that folder_id, not just this
|
||||
user's, leaking other users' folder contents in.
|
||||
"""
|
||||
?tag=/?feed= params the sidebar links use. feed_id alone is enough to
|
||||
scope by feed (the base queryset already restricts to the user's own
|
||||
subscriptions)."""
|
||||
active_tag = None
|
||||
tag_id = request.GET.get("tag")
|
||||
if tag_id:
|
||||
@@ -71,17 +67,7 @@ def _apply_scope(request, queryset):
|
||||
if active_feed:
|
||||
queryset = queryset.filter(feed_id=active_feed.pk)
|
||||
|
||||
active_folder = None
|
||||
folder_id = request.GET.get("folder")
|
||||
if folder_id:
|
||||
active_folder = Folder.objects.filter(user=request.user, pk=folder_id).first()
|
||||
if active_folder:
|
||||
queryset = queryset.filter(
|
||||
feed__subscriptions__user=request.user,
|
||||
feed__subscriptions__folder_id=active_folder.pk,
|
||||
)
|
||||
|
||||
return queryset, active_tag, active_feed, active_folder
|
||||
return queryset, active_tag, active_feed
|
||||
|
||||
|
||||
def _date_label(day, today):
|
||||
@@ -131,7 +117,7 @@ def stream(request):
|
||||
user_states__user=request.user, user_states__is_saved_for_later=True
|
||||
)
|
||||
|
||||
queryset, active_tag, active_feed, active_folder = _apply_scope(request, queryset)
|
||||
queryset, active_tag, active_feed = _apply_scope(request, queryset)
|
||||
|
||||
try:
|
||||
page = max(int(request.GET.get("page", 1)), 1)
|
||||
@@ -148,7 +134,6 @@ def stream(request):
|
||||
"filters": FILTER_CHOICES,
|
||||
"active_tag": active_tag,
|
||||
"active_feed": active_feed,
|
||||
"active_folder": active_folder,
|
||||
"user_tags": Tag.objects.filter(user=request.user),
|
||||
"page": page,
|
||||
"has_next_page": end < total_count,
|
||||
@@ -164,7 +149,7 @@ def mark_all_read(request):
|
||||
scope (tag included, "unread"/"all" filter excluded since it's a no-op
|
||||
choice here) as read — bulk, not one UserArticleState per article."""
|
||||
queryset = _base_queryset(request.user)
|
||||
queryset, _active_tag, _active_feed, _active_folder = _apply_scope(request, queryset)
|
||||
queryset, _active_tag, _active_feed = _apply_scope(request, queryset)
|
||||
|
||||
unread_articles = queryset.exclude(user_states__user=request.user, user_states__is_read=True)
|
||||
unread_ids = list(unread_articles.values_list("id", flat=True))
|
||||
|
||||
Reference in new issue
Block a user