diff --git a/src/apps/lyric/models.py b/src/apps/lyric/models.py index 8ab8103..7985ce2 100644 --- a/src/apps/lyric/models.py +++ b/src/apps/lyric/models.py @@ -151,11 +151,14 @@ class User(AbstractBaseUser): @property def active_title_display(self): """Render-ready string for "{username} the {title}" attributions — - returns the donned Note's recognition title, or 'Earthman' when no - Note is donned. The 'Earthman' default mirrors the dashboard greeting - fallback in dashboard/views.home_page.""" + returns the donned Note's `display_name`, or 'Earthman' when no + Note is donned. Uses `display_name` (not `display_title`) so the + Baltimorean rename — `display_title="Ard!"` (navbar DON greeting + flair only) vs. `display_name="Baltimorean"` (everywhere else) — + propagates to inline attributions like `.post-attribution`. For + non-overridden slugs the two are equal so this is a no-op.""" if self.active_title_id: - return self.active_title.display_title + return self.active_title.display_name return "Earthman" @property diff --git a/src/apps/lyric/tests/integrated/test_models.py b/src/apps/lyric/tests/integrated/test_models.py index 0378d11..05794e2 100644 --- a/src/apps/lyric/tests/integrated/test_models.py +++ b/src/apps/lyric/tests/integrated/test_models.py @@ -51,6 +51,32 @@ class UserModelTest(TestCase): user.refresh_from_db() self.assertIsNone(user.active_title) + def test_active_title_display_returns_earthman_when_no_note_donned(self): + user = User.objects.create(email="a@b.cde") + self.assertEqual(user.active_title_display, "Earthman") + + def test_active_title_display_uses_display_name_not_display_title(self): + """Inline attributions like `.post-attribution` should render the + Note's `display_name`, not its `display_title` — the only divergence + today is Baltimorean (display_title="Ard!" navbar-flair, display_name + ="Baltimorean" everywhere else). Pinning here so future Notes that + override one field but not the other don't surprise the post page.""" + user = User.objects.create(email="ard@b.cde") + note = Note.objects.create(user=user, slug="baltimorean", earned_at=timezone.now()) + user.active_title = note + user.save(update_fields=["active_title"]) + self.assertEqual(user.active_title_display, "Baltimorean") + + def test_active_title_display_falls_through_to_display_title_for_non_overridden_slugs(self): + """Stargazer / Schizo / Nomad don't override display_name, so + active_title_display returns the same string display_title would — + the rename pattern is no-op for these surfaces.""" + user = User.objects.create(email="star@b.cde") + note = Note.objects.create(user=user, slug="stargazer", earned_at=timezone.now()) + user.active_title = note + user.save(update_fields=["active_title"]) + self.assertEqual(user.active_title_display, note.display_title) + class LoginTokenModelTest(TestCase): def test_links_user_with_autogen_uid(self): login_token1 = LoginToken.objects.create(email="a@b.cde")