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:
ksmithandClaude Sonnet 5 committed 2026-10-30 21:30:06 -06:00
1 parent 3b58fdcb7e
commit 0e132e9ab9
24 files changed
+417 -307

No files matched your search

+28 -14
View File
@@ -3,7 +3,7 @@ import responses
from django.contrib.auth import get_user_model
from django.urls import reverse
from .models import Feed, Folder, Subscription
from .models import Feed, Subscription
User = get_user_model()
@@ -44,19 +44,6 @@ def test_a_user_cannot_subscribe_to_the_same_feed_twice(two_users):
Subscription.objects.create(user=alice, feed=feed)
@pytest.mark.django_db
def test_folder_names_are_scoped_per_user(two_users):
alice, bob = two_users
Folder.objects.create(user=alice, name="Tech")
# Same folder name for a different user must be allowed.
Folder.objects.create(user=bob, name="Tech")
assert Folder.objects.filter(name="Tech").count() == 2
with pytest.raises(Exception):
Folder.objects.create(user=alice, name="Tech")
GOOD_FEED_XML = """<?xml version="1.0"?>
<rss version="2.0"><channel>
<title>Example Blog</title>
@@ -86,6 +73,33 @@ def test_add_feed_view_requires_login(client):
assert response.status_code == 302
@pytest.mark.django_db
@responses.activate
def test_add_feed_view_creates_tags_from_comma_separated_tag_names(client, two_users):
from apps.articles.models import SubscriptionTag, Tag
alice, _ = two_users
client.login(username="alice", password="pw-alice-123")
responses.add(responses.GET, "https://example.com/feed.xml", body=GOOD_FEED_XML, status=200)
response = client.post(
reverse("feeds:add_feed"),
{"feed_url": "https://example.com/feed.xml", "tag_names": "Tech, backend"},
)
assert response.status_code == 302
subscription = Subscription.objects.get(
user=alice, feed__feed_url="https://example.com/feed.xml"
)
tag_names = set(
Tag.objects.filter(
subscription_tags__subscription=subscription, subscription_tags__user=alice
).values_list("name", flat=True)
)
assert tag_names == {"Tech", "backend"}
assert SubscriptionTag.objects.filter(user=alice, subscription=subscription).count() == 2
@pytest.mark.django_db
@responses.activate
def test_add_feed_view_rejects_duplicate_subscription(client, two_users):