applet feed unification — My Buds + My Notes drop the [Feature forthcoming] / empty placeholders for live top-3 feeds, mirroring the long-standing My Posts pattern; all five in-grid list applets (My Posts / My Buds / My Notes / My Scrolls / My Games) now route their <ul> through a single shared partial _applet-grid-list.html (newly extracted) so item rendering + empty-state row + scroll-buffer all live in one place — _applet-list-shell.html (the dedicated billbuds/billposts page shell) now internally includes the same grid-list partial for its inner <ul>, so the dedicated-page and in-grid lists share the same skeleton; new per-applet item partials _my_buds_applet_item.html (mirrors _my_buds_item.html w. data-bud-id + display_name), _my_notes_item.html (links to billboard:my_notes; uses display_name), _my_posts_applet_item.html (Post link + title), _my_scrolls_item.html (Room link to billboard:scroll), _my_games_item.html (Room link to epic:gatekeeper); view-side _billboard_context gains _recent_buds(user) — sorts the User.buds auto-through table by -id so newest-added-first w.o. an explicit through model w. timestamps (manage [r.to_user for r in rows]) — + _recent_notes(user) (user.notes.order_by('-earned_at')[:limit]); same two helpers threaded into new_post's GET-with-form-errors branch (line 270-274) so the rerender keeps the new applet content visible; 7 ITs added to BillboardViewTest covering recent_buds ordering / cap / empty + recent_notes ordering / cap / cross-user isolation / empty; SCSS — .applet-list / .applet-list-entry / .applet-list-buffer lifted from .applet-list-page .applet-scroll scope to top level so they apply in both surfaces; in-grid applets get display: flex; flex-direction: column; .applet-list { flex: 1 } so the list scrolls within the applet box; #id_applet_my_games ul-centring + .scroll-list + #id_applet_notes h2 { writing-mode: vertical-rl ... } overrides removed (centring was an empty-state-only behaviour, scroll-list + vertical-rl redundant w. the new shared rule + the %applet-box > h2 rule); My Games items now left-aligned by default; empty-state row recovers the centred-italic-dim treatment via .applet-list-entry--empty { flex: 1; display: flex; align-items: center; justify-content: center; opacity: 0.6; font-style: italic } + .applet-list:has(> .applet-list-entry--empty) { display: flex; flex-direction: column } — so "No buds yet" / "No notes yet" / "No games yet" / "No scrolls yet" / "No posts yet" all centre in their applet aperture, reverting to the left-aligned stack the moment a real item lands; Most Recent Scroll's outer empty <p><small>No recent activity.</small></p> adopts the same .applet-list-entry .applet-list-entry--empty classes (section is already flex-column from existing rule) so it picks up the unified centred-italic-dim treatment
pipeline fix — `_post_gear.html` (commit 6a7464e) gated the NVM target on `{% url 'billboard:my_posts' user_id=request.user.id %}`, which exploded w. NoReverseMatch when an anonymous user (Percival ch.18 anonymous-post lab — ownerless `Post.objects.create()`) hit view_post (which has no @login_required); whole gear-include now wrapped in `{% if request.user.is_authenticated %}` since anonymous viewers can't DEL/BYE/back-to-my-posts anyway; AnonymousPostViewerTest pins the 200-render + gear-absence contract so future ownerless-post regressions surface in ITs (pipeline run #298 fixed) — TDD
Code architected by Disco DeDisco <discodedisco@outlook.com>
Git commit message Co-Authored-By:
Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -85,6 +85,73 @@ class BillboardViewTest(TestCase):
|
||||
self.assertIsNone(response.context["recent_room"])
|
||||
self.assertEqual(list(response.context["recent_events"]), [])
|
||||
|
||||
# ── recent_buds + recent_notes (applet feed) ──────────────────────
|
||||
# Mirrors the recent_posts pattern: each in-grid applet now lists
|
||||
# its own most-recent items (capped at 3) plus an empty-state row.
|
||||
|
||||
def test_passes_recent_buds_context(self):
|
||||
first = User.objects.create(email="first-bud@test.io")
|
||||
second = User.objects.create(email="second-bud@test.io")
|
||||
self.user.buds.add(first)
|
||||
self.user.buds.add(second)
|
||||
response = self.client.get("/billboard/")
|
||||
# Most-recently-added bud is first
|
||||
self.assertEqual(list(response.context["recent_buds"]), [second, first])
|
||||
|
||||
def test_recent_buds_capped_at_3(self):
|
||||
added = [
|
||||
User.objects.create(email=f"bud{i}@test.io") for i in range(5)
|
||||
]
|
||||
for u in added:
|
||||
self.user.buds.add(u)
|
||||
response = self.client.get("/billboard/")
|
||||
recent = list(response.context["recent_buds"])
|
||||
self.assertEqual(len(recent), 3)
|
||||
# Newest three in newest-first order
|
||||
self.assertEqual(recent, list(reversed(added))[:3])
|
||||
|
||||
def test_recent_buds_empty_when_no_buds(self):
|
||||
response = self.client.get("/billboard/")
|
||||
self.assertEqual(list(response.context["recent_buds"]), [])
|
||||
|
||||
def test_passes_recent_notes_context(self):
|
||||
Note.objects.create(
|
||||
user=self.user, slug="stargazer",
|
||||
earned_at=timezone.now() - timezone.timedelta(days=2),
|
||||
)
|
||||
Note.objects.create(
|
||||
user=self.user, slug="super-schizo",
|
||||
earned_at=timezone.now(),
|
||||
)
|
||||
response = self.client.get("/billboard/")
|
||||
slugs = [n.slug for n in response.context["recent_notes"]]
|
||||
# Most-recently-earned first
|
||||
self.assertEqual(slugs, ["super-schizo", "stargazer"])
|
||||
|
||||
def test_recent_notes_capped_at_3(self):
|
||||
slugs = ["stargazer", "super-schizo", "super-nomad", "ladidah", "doodah"]
|
||||
base = timezone.now()
|
||||
for i, slug in enumerate(slugs):
|
||||
Note.objects.create(
|
||||
user=self.user, slug=slug,
|
||||
earned_at=base - timezone.timedelta(hours=i),
|
||||
)
|
||||
response = self.client.get("/billboard/")
|
||||
names = [n.slug for n in response.context["recent_notes"]]
|
||||
self.assertEqual(len(names), 3)
|
||||
# Newest-first; oldest two trimmed
|
||||
self.assertEqual(names, slugs[:3])
|
||||
|
||||
def test_recent_notes_excludes_other_users(self):
|
||||
other = User.objects.create(email="other-note@test.io")
|
||||
Note.objects.create(user=other, slug="stargazer", earned_at=timezone.now())
|
||||
response = self.client.get("/billboard/")
|
||||
self.assertEqual(list(response.context["recent_notes"]), [])
|
||||
|
||||
def test_recent_notes_empty_when_no_notes(self):
|
||||
response = self.client.get("/billboard/")
|
||||
self.assertEqual(list(response.context["recent_notes"]), [])
|
||||
|
||||
|
||||
class SaveScrollPositionViewTest(TestCase):
|
||||
def setUp(self):
|
||||
@@ -602,3 +669,31 @@ class AbandonPostViewTest(TestCase):
|
||||
self.client.post(reverse("billboard:abandon_post", args=[admin_post.id]))
|
||||
admin_post.refresh_from_db()
|
||||
self.assertIn(self.invitee, admin_post.shared_with.all())
|
||||
|
||||
|
||||
class AnonymousPostViewerTest(TestCase):
|
||||
"""view_post has no @login_required (Percival ch.18 anonymous-post lab —
|
||||
ownerless Posts are viewable by anyone). The gear menu's NVM target
|
||||
reverses `my_posts user_id=request.user.id`, which previously exploded
|
||||
w. NoReverseMatch when request.user.id was None (anonymous user).
|
||||
Gear menu must be gated on is_authenticated; the post body still renders
|
||||
for anonymous viewers of ownerless posts."""
|
||||
|
||||
def setUp(self):
|
||||
from apps.billboard.models import Post
|
||||
# Ownerless Post — matches the Percival anonymous-share contract
|
||||
# exercised by apps.dashboard.tests.integrated.test_views.SharePostTest.
|
||||
# No Line needed; the empty post still exercises the template render.
|
||||
self.post = Post.objects.create(title="Public-ish")
|
||||
|
||||
def test_anonymous_can_view_ownerless_post_without_500(self):
|
||||
response = self.client.get(
|
||||
reverse("billboard:view_post", args=[self.post.id])
|
||||
)
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
def test_anonymous_gets_no_gear_menu(self):
|
||||
response = self.client.get(
|
||||
reverse("billboard:view_post", args=[self.post.id])
|
||||
)
|
||||
self.assertNotIn(b"id_post_menu", response.content)
|
||||
|
||||
Reference in New Issue
Block a user