billboard applets: drop billboard- prefix from partials & ids; Most Recent → Most Recent Scroll; room_scroll → scroll — TDD
- Slug renames (mig 0004): billboard-my-scrolls → my-scrolls; billboard-my-contacts → my-contacts; billboard-most-recent → most-recent-scroll (name → "Most Recent Scroll"); billboard-notes → notes - Partial filenames lose the `billboard-` token to mirror dashboard/gameboard convention; element ids follow (id_applet_my_scrolls, id_applet_my_contacts, id_applet_most_recent_scroll, id_applet_notes, id_applet_scroll); .applet-billboard-scroll → .applet-scroll - View fn billboard.views.room_scroll → scroll; template apps/billboard/room_scroll.html → scroll.html (URL name `billboard:scroll` already correct) - ITs + FTs updated to new identifiers; SCSS selectors retitled Code architected by Disco DeDisco <discodedisco@outlook.com> Git commit message Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
"""Drop the legacy `billboard-` slug prefix from billboard applets and
|
||||
rename Most Recent → Most Recent Scroll.
|
||||
|
||||
The `billboard-` prefix snuck into seed migration 0003 against intent — no
|
||||
other context (dashboard, gameboard, wallet, game-kit) prefixes its applet
|
||||
slugs with the context name, and slugs need to stay portable so users can
|
||||
later rearrange which page hosts which applet.
|
||||
"""
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
RENAMES = [
|
||||
# (old_slug, new_slug, new_name_or_None)
|
||||
('billboard-my-scrolls', 'my-scrolls', None),
|
||||
('billboard-my-contacts', 'my-contacts', None),
|
||||
('billboard-most-recent', 'most-recent-scroll', 'Most Recent Scroll'),
|
||||
('billboard-notes', 'notes', None),
|
||||
]
|
||||
|
||||
|
||||
def _apply(apps, mapping):
|
||||
Applet = apps.get_model('applets', 'Applet')
|
||||
for old_slug, new_slug, new_name in mapping:
|
||||
try:
|
||||
applet = Applet.objects.get(slug=old_slug)
|
||||
except Applet.DoesNotExist:
|
||||
continue
|
||||
applet.slug = new_slug
|
||||
fields = ['slug']
|
||||
if new_name is not None:
|
||||
applet.name = new_name
|
||||
fields.append('name')
|
||||
applet.save(update_fields=fields)
|
||||
|
||||
|
||||
def forward(apps, schema_editor):
|
||||
_apply(apps, RENAMES)
|
||||
|
||||
|
||||
def backward(apps, schema_editor):
|
||||
inverse = [
|
||||
(new, old, 'Most Recent' if old == 'billboard-most-recent' else None)
|
||||
for (old, new, _) in RENAMES
|
||||
]
|
||||
_apply(apps, inverse)
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('applets', '0003_seed_applets'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunPython(forward, backward),
|
||||
]
|
||||
@@ -12,9 +12,9 @@ from apps.lyric.models import User
|
||||
|
||||
def _seed_billboard_applets():
|
||||
for slug, name, cols, rows in [
|
||||
("billboard-my-scrolls", "My Scrolls", 4, 3),
|
||||
("billboard-my-contacts", "Contacts", 4, 3),
|
||||
("billboard-most-recent", "Most Recent", 8, 6),
|
||||
("my-scrolls", "My Scrolls", 4, 3),
|
||||
("my-contacts", "Contacts", 4, 3),
|
||||
("most-recent-scroll", "Most Recent Scroll", 8, 6),
|
||||
]:
|
||||
Applet.objects.get_or_create(
|
||||
slug=slug,
|
||||
@@ -36,9 +36,9 @@ class BillboardViewTest(TestCase):
|
||||
response = self.client.get("/billboard/")
|
||||
self.assertIn("applets", response.context)
|
||||
slugs = [e["applet"].slug for e in response.context["applets"]]
|
||||
self.assertIn("billboard-my-scrolls", slugs)
|
||||
self.assertIn("billboard-my-contacts", slugs)
|
||||
self.assertIn("billboard-most-recent", slugs)
|
||||
self.assertIn("my-scrolls", slugs)
|
||||
self.assertIn("my-contacts", slugs)
|
||||
self.assertIn("most-recent-scroll", slugs)
|
||||
|
||||
def test_passes_my_rooms_context(self):
|
||||
room = Room.objects.create(name="Test Room", owner=self.user)
|
||||
@@ -107,25 +107,25 @@ class ToggleBillboardAppletsTest(TestCase):
|
||||
def test_toggle_hides_unchecked_applets(self):
|
||||
response = self.client.post(
|
||||
reverse("billboard:toggle_applets"),
|
||||
{"applets": ["billboard-my-scrolls"]},
|
||||
{"applets": ["my-scrolls"]},
|
||||
)
|
||||
self.assertEqual(response.status_code, 302)
|
||||
from apps.applets.models import UserApplet
|
||||
contacts = Applet.objects.get(slug="billboard-my-contacts")
|
||||
contacts = Applet.objects.get(slug="my-contacts")
|
||||
ua = UserApplet.objects.get(user=self.user, applet=contacts)
|
||||
self.assertFalse(ua.visible)
|
||||
|
||||
def test_toggle_returns_partial_on_htmx(self):
|
||||
response = self.client.post(
|
||||
reverse("billboard:toggle_applets"),
|
||||
{"applets": ["billboard-my-scrolls"]},
|
||||
{"applets": ["my-scrolls"]},
|
||||
HTTP_HX_REQUEST="true",
|
||||
)
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertTemplateUsed(response, "apps/billboard/_partials/_applets.html")
|
||||
|
||||
def test_htmx_toggle_response_renders_most_recent_with_real_events(self):
|
||||
# Seed a room + event so Most Recent should render prose, not the empty fallback.
|
||||
def test_htmx_toggle_response_renders_most_recent_scroll_with_real_events(self):
|
||||
# Seed a room + event so Most Recent Scroll renders prose, not the empty fallback.
|
||||
room = Room.objects.create(name="Sound Chamber", owner=self.user)
|
||||
record(
|
||||
room, GameEvent.SLOT_FILLED, actor=self.user,
|
||||
@@ -135,9 +135,9 @@ class ToggleBillboardAppletsTest(TestCase):
|
||||
response = self.client.post(
|
||||
reverse("billboard:toggle_applets"),
|
||||
{"applets": [
|
||||
"billboard-my-scrolls",
|
||||
"billboard-my-contacts",
|
||||
"billboard-most-recent",
|
||||
"my-scrolls",
|
||||
"my-contacts",
|
||||
"most-recent-scroll",
|
||||
]},
|
||||
HTTP_HX_REQUEST="true",
|
||||
)
|
||||
@@ -153,7 +153,7 @@ class ToggleBillboardAppletsTest(TestCase):
|
||||
# menu exactly once (the wrapper) — never two siblings of the same id.
|
||||
response = self.client.post(
|
||||
reverse("billboard:toggle_applets"),
|
||||
{"applets": ["billboard-my-scrolls"]},
|
||||
{"applets": ["my-scrolls"]},
|
||||
HTTP_HX_REQUEST="true",
|
||||
)
|
||||
body = response.content.decode("utf-8")
|
||||
@@ -165,28 +165,28 @@ class ToggleBillboardAppletsTest(TestCase):
|
||||
reverse("billboard:toggle_applets"),
|
||||
{"applets": [
|
||||
"new-post", "my-posts",
|
||||
"billboard-my-scrolls",
|
||||
"billboard-most-recent",
|
||||
"my-scrolls",
|
||||
"most-recent-scroll",
|
||||
]},
|
||||
HTTP_HX_REQUEST="true",
|
||||
)
|
||||
# Second toggle: hide Most Recent additionally — Contacts must stay hidden.
|
||||
# Second toggle: hide Most Recent Scroll additionally — Contacts must stay hidden.
|
||||
self.client.post(
|
||||
reverse("billboard:toggle_applets"),
|
||||
{"applets": [
|
||||
"new-post", "my-posts",
|
||||
"billboard-my-scrolls",
|
||||
"my-scrolls",
|
||||
]},
|
||||
HTTP_HX_REQUEST="true",
|
||||
)
|
||||
from apps.applets.models import UserApplet
|
||||
contacts = Applet.objects.get(slug="billboard-my-contacts")
|
||||
most_recent = Applet.objects.get(slug="billboard-most-recent")
|
||||
contacts = Applet.objects.get(slug="my-contacts")
|
||||
most_recent_scroll = Applet.objects.get(slug="most-recent-scroll")
|
||||
self.assertFalse(
|
||||
UserApplet.objects.get(user=self.user, applet=contacts).visible
|
||||
)
|
||||
self.assertFalse(
|
||||
UserApplet.objects.get(user=self.user, applet=most_recent).visible
|
||||
UserApplet.objects.get(user=self.user, applet=most_recent_scroll).visible
|
||||
)
|
||||
|
||||
|
||||
@@ -201,9 +201,9 @@ class BillscrollViewTest(TestCase):
|
||||
token_display="Coin-on-a-String", renewal_days=7,
|
||||
)
|
||||
|
||||
def test_uses_room_scroll_template(self):
|
||||
def test_uses_scroll_template(self):
|
||||
response = self.client.get(f"/billboard/room/{self.room.id}/scroll/")
|
||||
self.assertTemplateUsed(response, "apps/billboard/room_scroll.html")
|
||||
self.assertTemplateUsed(response, "apps/billboard/scroll.html")
|
||||
|
||||
def test_passes_events_context(self):
|
||||
response = self.client.get(f"/billboard/room/{self.room.id}/scroll/")
|
||||
|
||||
@@ -11,6 +11,6 @@ urlpatterns = [
|
||||
path("note/<slug:slug>/set-palette", views.note_set_palette, name="note_set_palette"),
|
||||
path("note/<slug:slug>/don", views.don_title, name="don_title"),
|
||||
path("note/<slug:slug>/doff", views.doff_title, name="doff_title"),
|
||||
path("room/<uuid:room_id>/scroll/", views.room_scroll, name="scroll"),
|
||||
path("room/<uuid:room_id>/scroll/", views.scroll, name="scroll"),
|
||||
path("room/<uuid:room_id>/scroll-position/", views.save_scroll_position, name="save_scroll_position"),
|
||||
]
|
||||
|
||||
@@ -85,11 +85,11 @@ def toggle_billboard_applets(request):
|
||||
|
||||
|
||||
@login_required(login_url="/")
|
||||
def room_scroll(request, room_id):
|
||||
def scroll(request, room_id):
|
||||
room = Room.objects.get(id=room_id)
|
||||
events = room.events.select_related("actor").all()
|
||||
sp = ScrollPosition.objects.filter(user=request.user, room=room).first()
|
||||
return render(request, "apps/billboard/room_scroll.html", {
|
||||
return render(request, "apps/billboard/scroll.html", {
|
||||
"room": room,
|
||||
"events": events,
|
||||
"viewer": request.user,
|
||||
|
||||
Reference in New Issue
Block a user