brief sprint C1: relocate Post + Line from dashboard → billboard (no behavior change) — TDD
Some checks failed
ci/woodpecker/push/pyswiss Pipeline was successful
ci/woodpecker/push/main Pipeline failed

The Post/Line models always read more like billboard tenants than dashboard ones (1st-person personal vs. 2nd-person provenance feed); the upcoming Brief model needs them in the billboard namespace as the canonical surface they FK into. C1 is a pure relocation w. zero new behavior: 789 ITs + 20 sky/Post FTs green against the moved code.

- billboard.models adds Post (owner + shared_with) + Line (text + post FK), schema mirroring the legacy dashboard models 1:1; Post.get_absolute_url now reverses to `billboard:view_post`.
- billboard.forms adds LineForm + ExistingPostLineForm (moved from dashboard.forms; dashboard/forms.py removed).
- billboard.views absorbs new_post / view_post / share_post / my_posts (templates rendered from apps/billboard/post.html + my_posts.html).
- billboard.urls adds the namespaced routes: /billboard/new-post, /billboard/post/<uuid>/, /billboard/post/<uuid>/share-post, /billboard/users/<uuid>/. dashboard.urls drops the corresponding entries.
- _applet-my-posts + _applet-new-post URL refs now use the billboard: namespace; templates/apps/dashboard/{post,my_posts}.html removed.
- api/serializers + api/views + api/tests/integrated/test_views imports flip dashboard.models → billboard.models (PostSerializer / PostDetailAPI / PostLinesAPI / PostsAPI all retain identifiers — the model rename to Brief lands in C2).
- dashboard/tests/integrated/test_{models,views,forms} + dashboard/tests/unit/test_{models,forms} swap imports; test_views URL strings flip /dashboard/post/ → /billboard/post/, /dashboard/new_post → /billboard/new-post, /dashboard/users/ → /billboard/users/, share_post → share-post (path) / billboard:share_post (reverser). Tests stay in dashboard.tests/ for now — relocation TBD.
- functional_tests/my_posts_page.py URL string flips to /billboard/users/.
- Auto-generated migrations: billboard/0001_initial (CreateModel Post + Line), dashboard/0003_remove_post_* (drops legacy Post + Line), drama/0004_alter_gameevent_verb (incidental — choices field caught up).

This commit drops the dashboard Post/Line tables w/o data preservation; user has confirmed staging-side wipe is acceptable. C2 introduces the Brief model + read-tracking + slide-down banner unification. C3 hooks Note-unlock + share-post-invite + magic-link / invalid-link `messages` calls into the new Brief / banner pipeline.

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:
Disco DeDisco
2026-05-08 17:20:06 -04:00
parent f659a64b91
commit d192b1522d
24 changed files with 256 additions and 161 deletions

View File

@@ -1,12 +1,12 @@
from django.test import TestCase
from apps.dashboard.forms import (
from apps.billboard.forms import (
DUPLICATE_LINE_ERROR,
EMPTY_LINE_ERROR,
ExistingPostLineForm,
LineForm,
)
from apps.dashboard.models import Line, Post
from apps.billboard.models import Line, Post
class LineFormTest(TestCase):

View File

@@ -2,7 +2,7 @@ from django.core.exceptions import ValidationError
from django.db.utils import IntegrityError
from django.test import TestCase
from apps.dashboard.models import Line, Post
from apps.billboard.models import Line, Post
from apps.lyric.models import User
@@ -43,7 +43,7 @@ class LineModelTest(TestCase):
class PostModelTest(TestCase):
def test_get_absolute_url(self):
mypost = Post.objects.create()
self.assertEqual(mypost.get_absolute_url(), f"/dashboard/post/{mypost.id}/")
self.assertEqual(mypost.get_absolute_url(), f"/billboard/post/{mypost.id}/")
def test_post_lines_order(self):
post1 = Post.objects.create()

View File

@@ -8,11 +8,11 @@ from django.urls import reverse
from django.utils import html, timezone
from apps.applets.models import Applet, UserApplet
from apps.dashboard.forms import (
from apps.billboard.forms import (
DUPLICATE_LINE_ERROR,
EMPTY_LINE_ERROR,
)
from apps.dashboard.models import Line, Post
from apps.billboard.models import Line, Post
from apps.drama.models import Note
from apps.lyric.models import User
@@ -37,19 +37,19 @@ class NewPostTest(TestCase):
)
def test_can_save_a_POST_request(self):
self.client.post("/dashboard/new_post", data={"text": "A new post line"})
self.client.post("/billboard/new-post", data={"text": "A new post line"})
self.assertEqual(Line.objects.count(), 1)
new_line = Line.objects.get()
self.assertEqual(new_line.text, "A new post line")
def test_redirects_after_POST(self):
response = self.client.post("/dashboard/new_post", data={"text": "A new post line"})
response = self.client.post("/billboard/new-post", data={"text": "A new post line"})
new_post = Post.objects.get()
self.assertRedirects(response, f"/dashboard/post/{new_post.id}/")
self.assertRedirects(response, f"/billboard/post/{new_post.id}/")
# Post invalid input helper
def post_invalid_input(self):
return self.client.post("/dashboard/new_post", data={"text": ""})
return self.client.post("/billboard/new-post", data={"text": ""})
def test_for_invalid_input_nothing_saved_to_db(self):
self.post_invalid_input()
@@ -68,12 +68,12 @@ class NewPostTest(TestCase):
class PostViewTest(TestCase):
def test_uses_post_template(self):
mypost = Post.objects.create()
response = self.client.get(f"/dashboard/post/{mypost.id}/")
self.assertTemplateUsed(response, "apps/dashboard/post.html")
response = self.client.get(f"/billboard/post/{mypost.id}/")
self.assertTemplateUsed(response, "apps/billboard/post.html")
def test_renders_input_form(self):
mypost = Post.objects.create()
url = f"/dashboard/post/{mypost.id}/"
url = f"/billboard/post/{mypost.id}/"
response = self.client.get(url)
parsed = lxml.html.fromstring(response.content)
forms = parsed.cssselect("form[method=POST]")
@@ -90,7 +90,7 @@ class PostViewTest(TestCase):
other_post = Post.objects.create()
Line.objects.create(text="other post line", post=other_post)
# When/Act
response = self.client.get(f"/dashboard/post/{correct_post.id}/")
response = self.client.get(f"/billboard/post/{correct_post.id}/")
# Then/Assert
self.assertContains(response, "itemey 1")
self.assertContains(response, "itemey 2")
@@ -101,7 +101,7 @@ class PostViewTest(TestCase):
correct_post = Post.objects.create()
self.client.post(
f"/dashboard/post/{correct_post.id}/",
f"/billboard/post/{correct_post.id}/",
data={"text": "A new line for an existing post"},
)
@@ -115,16 +115,16 @@ class PostViewTest(TestCase):
correct_post = Post.objects.create()
response = self.client.post(
f"/dashboard/post/{correct_post.id}/",
f"/billboard/post/{correct_post.id}/",
data={"text": "A new line for an existing post"},
)
self.assertRedirects(response, f"/dashboard/post/{correct_post.id}/")
self.assertRedirects(response, f"/billboard/post/{correct_post.id}/")
# Post invalid input helper
def post_invalid_input(self):
mypost = Post.objects.create()
return self.client.post(f"/dashboard/post/{mypost.id}/", data={"text": ""})
return self.client.post(f"/billboard/post/{mypost.id}/", data={"text": ""})
def test_for_invalid_input_nothing_saved_to_db(self):
self.post_invalid_input()
@@ -133,7 +133,7 @@ class PostViewTest(TestCase):
def test_for_invalid_input_renders_post_template(self):
response = self.post_invalid_input()
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, "apps/dashboard/post.html")
self.assertTemplateUsed(response, "apps/billboard/post.html")
def test_for_invalid_input_shows_error_on_page(self):
response = self.post_invalid_input()
@@ -150,46 +150,46 @@ class PostViewTest(TestCase):
Line.objects.create(post=post1, text="lorem ipsum")
response = self.client.post(
f"/dashboard/post/{post1.id}/",
f"/billboard/post/{post1.id}/",
data={"text": "lorem ipsum"},
)
expected_error = html.escape(DUPLICATE_LINE_ERROR)
self.assertContains(response, expected_error)
self.assertTemplateUsed(response, "apps/dashboard/post.html")
self.assertTemplateUsed(response, "apps/billboard/post.html")
self.assertEqual(Line.objects.all().count(), 1)
class MyPostsTest(TestCase):
def test_my_posts_url_renders_my_posts_template(self):
user = User.objects.create(email="a@b.cde")
self.client.force_login(user)
response = self.client.get(f"/dashboard/users/{user.id}/")
self.assertTemplateUsed(response, "apps/dashboard/my_posts.html")
response = self.client.get(f"/billboard/users/{user.id}/")
self.assertTemplateUsed(response, "apps/billboard/my_posts.html")
def test_passes_correct_owner_to_template(self):
User.objects.create(email="wrongowner@example.com")
correct_user = User.objects.create(email="a@b.cde")
self.client.force_login(correct_user)
response = self.client.get(f"/dashboard/users/{correct_user.id}/")
response = self.client.get(f"/billboard/users/{correct_user.id}/")
self.assertEqual(response.context["owner"], correct_user)
def test_post_owner_is_saved_if_user_is_authenticated(self):
user = User.objects.create(email="a@b.cde")
self.client.force_login(user)
self.client.post("/dashboard/new_post", data={"text": "new line"})
self.client.post("/billboard/new-post", data={"text": "new line"})
new_post = Post.objects.get()
self.assertEqual(new_post.owner, user)
def test_my_posts_redirects_if_not_logged_in(self):
user = User.objects.create(email="a@b.cde")
response = self.client.get(f"/dashboard/users/{user.id}/")
response = self.client.get(f"/billboard/users/{user.id}/")
self.assertRedirects(response, "/")
def test_my_posts_returns_403_for_wrong_user(self):
user1 = User.objects.create(email="a@b.cde")
user2 = User.objects.create(email="wrongowner@example.com")
self.client.force_login(user2)
response = self.client.get(f"/dashboard/users/{user1.id}/")
response = self.client.get(f"/billboard/users/{user1.id}/")
self.assertEqual(response.status_code, 403)
class SharePostTest(TestCase):
@@ -197,16 +197,16 @@ class SharePostTest(TestCase):
our_post = Post.objects.create()
alice = User.objects.create(email="alice@example.com")
response = self.client.post(
f"/dashboard/post/{our_post.id}/share_post",
f"/billboard/post/{our_post.id}/share-post",
data={"recipient": "alice@example.com"},
)
self.assertRedirects(response, f"/dashboard/post/{our_post.id}/")
self.assertRedirects(response, f"/billboard/post/{our_post.id}/")
def test_post_with_email_adds_user_to_shared_with(self):
our_post = Post.objects.create()
alice = User.objects.create(email="alice@example.com")
self.client.post(
f"/dashboard/post/{our_post.id}/share_post",
f"/billboard/post/{our_post.id}/share-post",
data={"recipient": "alice@example.com"},
)
self.assertIn(alice, our_post.shared_with.all())
@@ -214,12 +214,12 @@ class SharePostTest(TestCase):
def test_post_with_nonexistent_email_redirects_to_post(self):
our_post = Post.objects.create()
response = self.client.post(
f"/dashboard/post/{our_post.id}/share_post",
f"/billboard/post/{our_post.id}/share-post",
data={"recipient": "nobody@example.com"},
)
self.assertRedirects(
response,
f"/dashboard/post/{our_post.id}/",
f"/billboard/post/{our_post.id}/",
fetch_redirect_response=False,
)
@@ -227,7 +227,7 @@ class SharePostTest(TestCase):
owner = User.objects.create(email="owner@example.com")
our_post = Post.objects.create(owner=owner)
self.client.force_login(owner)
self.client.post(reverse("share_post", args=[our_post.id]),
self.client.post(reverse("billboard:share_post", args=[our_post.id]),
data={"recipient": "owner@example.com"})
self.assertNotIn(owner, our_post.shared_with.all())
@@ -235,7 +235,7 @@ class SharePostTest(TestCase):
def test_share_post_shows_privacy_safe_message(self):
our_post = Post.objects.create()
response = self.client.post(
f"/dashboard/post/{our_post.id}/share_post",
f"/billboard/post/{our_post.id}/share-post",
data={"recipient": "nobody@example.com"},
follow=True,
)
@@ -251,20 +251,20 @@ class ViewAuthPostTest(TestCase):
self.our_post = Post.objects.create(owner=self.owner)
def test_anonymous_user_is_redirected(self):
response = self.client.get(reverse("view_post", args=[self.our_post.id]))
response = self.client.get(reverse("billboard:view_post", args=[self.our_post.id]))
self.assertRedirects(response, "/", fetch_redirect_response=False)
def test_non_owner_non_shared_user_gets_403(self):
stranger = User.objects.create(email="stranger@example.com")
self.client.force_login(stranger)
response = self.client.get(reverse("view_post", args=[self.our_post.id]))
response = self.client.get(reverse("billboard:view_post", args=[self.our_post.id]))
self.assertEqual(response.status_code, 403)
def test_shared_with_user_can_access_post(self):
guest = User.objects.create(email="guest@example.com")
self.our_post.shared_with.add(guest)
self.client.force_login(guest)
response = self.client.get(reverse("view_post", args=[self.our_post.id]))
response = self.client.get(reverse("billboard:view_post", args=[self.our_post.id]))
self.assertEqual(response.status_code, 200)
@override_settings(COMPRESS_ENABLED=False)

View File

@@ -1,6 +1,6 @@
from django.test import SimpleTestCase
from apps.dashboard.forms import (
from apps.billboard.forms import (
EMPTY_LINE_ERROR,
LineForm,
)

View File

@@ -1,6 +1,6 @@
from django.test import SimpleTestCase
from apps.dashboard.models import Line
from apps.billboard.models import Line
class SimpleLineModelTest(SimpleTestCase):