Private
Public Access
Add subscription editing, feed-level tags, and a remembered stream filter
Subscription editing was a real gap: there was no way to rename a feed's display title, move it between folders, or create a folder at all outside OPML import. Added an edit page (apps/feeds/views.py:edit_subscription, EditSubscriptionForm) reachable from the subscriptions list. Added feed-level tagging via a new SubscriptionTag model (apps/articles/ models.py), mirroring the existing ArticleTag — tag a whole feed on its edit page, and every one of its articles surfaces under that tag in the stream alongside individually-tagged articles (apps.reader.views._apply_ scope now matches either). Renamed AddTagToArticleForm to AddTagForm since it's shared by both now. The stream also now remembers the last filter (unread/all/starred/saved) in the session instead of always defaulting to "unread" when a sidebar feed/folder/tag link omits ?filter= — sidebar links no longer force ?filter=all, letting the remembered choice apply. Verified end to end against a running dev server: editing a subscription's title/folder, creating a folder inline, tagging a feed and seeing its articles appear under that tag, and the remembered-filter behavior across requests with no ?filter= param. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
cfa64b5485
commit
3b58fdcb7e
15 files changed
+376
-23
No files matched your search
@@ -3,7 +3,7 @@ from django.contrib.auth import get_user_model
|
||||
from django.core.files.uploadedfile import SimpleUploadedFile
|
||||
from django.urls import reverse
|
||||
|
||||
from .models import Feed, Subscription
|
||||
from .models import Feed, Folder, Subscription
|
||||
from .test_opml import SIMPLE_OPML
|
||||
|
||||
User = get_user_model()
|
||||
@@ -38,6 +38,107 @@ def test_subscription_list_shows_only_own_subscriptions(client, alice, bob, alic
|
||||
assert "Example" not in response.content.decode()
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_edit_subscription_updates_title_and_folder(client, alice, alices_subscription):
|
||||
client.login(username="alice", password="pw-alice-123")
|
||||
folder = Folder.objects.create(user=alice, name="Tech")
|
||||
|
||||
response = client.post(
|
||||
reverse("feeds:edit_subscription", args=[alices_subscription.pk]),
|
||||
{"custom_title": "My Example Feed", "folder": folder.pk},
|
||||
)
|
||||
|
||||
assert response.status_code == 302
|
||||
alices_subscription.refresh_from_db()
|
||||
assert alices_subscription.custom_title == "My Example Feed"
|
||||
assert alices_subscription.folder == folder
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_edit_subscription_can_create_a_new_folder(client, alice, alices_subscription):
|
||||
client.login(username="alice", password="pw-alice-123")
|
||||
|
||||
response = client.post(
|
||||
reverse("feeds:edit_subscription", args=[alices_subscription.pk]),
|
||||
{"custom_title": "", "folder": "", "new_folder_name": "Brand New Folder"},
|
||||
)
|
||||
|
||||
assert response.status_code == 302
|
||||
alices_subscription.refresh_from_db()
|
||||
assert alices_subscription.folder.name == "Brand New Folder"
|
||||
assert Folder.objects.filter(user=alice, name="Brand New Folder").count() == 1
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_edit_subscription_can_clear_folder(client, alice, alices_subscription):
|
||||
client.login(username="alice", password="pw-alice-123")
|
||||
alices_subscription.folder = Folder.objects.create(user=alice, name="Tech")
|
||||
alices_subscription.save()
|
||||
|
||||
response = client.post(
|
||||
reverse("feeds:edit_subscription", args=[alices_subscription.pk]),
|
||||
{"custom_title": "", "folder": ""},
|
||||
)
|
||||
|
||||
assert response.status_code == 302
|
||||
alices_subscription.refresh_from_db()
|
||||
assert alices_subscription.folder is None
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_user_cannot_edit_another_users_subscription(client, alice, bob, alices_subscription):
|
||||
client.login(username="bob", password="pw-bob-123")
|
||||
response = client.get(reverse("feeds:edit_subscription", args=[alices_subscription.pk]))
|
||||
assert response.status_code == 404
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_add_tag_to_subscription_creates_tag_and_link(client, alice, alices_subscription):
|
||||
from apps.articles.models import SubscriptionTag, Tag
|
||||
|
||||
client.login(username="alice", password="pw-alice-123")
|
||||
|
||||
response = client.post(
|
||||
reverse("feeds:add_tag_to_subscription", args=[alices_subscription.pk]),
|
||||
{"tag_name": "backend"},
|
||||
)
|
||||
|
||||
assert response.status_code == 200
|
||||
tag = Tag.objects.get(user=alice, name="backend")
|
||||
assert SubscriptionTag.objects.filter(
|
||||
user=alice, subscription=alices_subscription, tag=tag
|
||||
).exists()
|
||||
assert b"backend" in response.content
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_remove_tag_from_subscription(client, alice, alices_subscription):
|
||||
from apps.articles.models import SubscriptionTag, Tag
|
||||
|
||||
client.login(username="alice", password="pw-alice-123")
|
||||
tag = Tag.objects.create(user=alice, name="backend")
|
||||
SubscriptionTag.objects.create(user=alice, subscription=alices_subscription, tag=tag)
|
||||
|
||||
response = client.post(
|
||||
reverse("feeds:remove_tag_from_subscription", args=[alices_subscription.pk, tag.pk])
|
||||
)
|
||||
|
||||
assert response.status_code == 200
|
||||
assert not SubscriptionTag.objects.filter(
|
||||
user=alice, subscription=alices_subscription, tag=tag
|
||||
).exists()
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_user_cannot_tag_another_users_subscription(client, alice, bob, alices_subscription):
|
||||
client.login(username="bob", password="pw-bob-123")
|
||||
response = client.post(
|
||||
reverse("feeds:add_tag_to_subscription", args=[alices_subscription.pk]),
|
||||
{"tag_name": "backend"},
|
||||
)
|
||||
assert response.status_code == 404
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_unsubscribe(client, alice, alices_subscription):
|
||||
client.login(username="alice", password="pw-alice-123")
|
||||
|
||||
Reference in new issue
Block a user