diff --git a/src/apps/drama/models.py b/src/apps/drama/models.py index 97c4ed5..3eba88c 100644 --- a/src/apps/drama/models.py +++ b/src/apps/drama/models.py @@ -293,21 +293,31 @@ class Note(models.Model): post.title = NOTE_UNLOCK_POST_TITLE post.save(update_fields=["title"]) - username = user.username or user.email + # Bare-email fallback when user.username is None (no `@` prefix — + # the address already carries one). When username is set, use the + # `@handle` form. Both wrapped in .post-attribution so the CSS + # palette key (--quaUser) lights up the username + title combo. + handle = f"@{user.username}" if user.username else user.email note_anchor = ( f'' f'{note.display_name}' ) + attr_handle = f'{handle}' + attr_title = f'{note.display_title}' if slug in _ADMIN_NOTE_SLUGS: line_text = ( - f"The administration recognizes {username} for {note_anchor}, " - f"which comes with the customary title of {note.display_title}. " + f"The administration recognizes {attr_handle} for {note_anchor}, " + f"which comes with the customary title of {attr_title}. " "This does not entail any additional benefits." ) else: + attr_combo = ( + f'{handle} ' + f'the {note.display_title}' + ) line_text = ( f"Look!—new Note unlocked. {note_anchor} " - f"recognizes {username} the {note.display_title}." + f"recognizes {attr_combo}." ) # Lazy get-or-create: TransactionTestCase flushes the migration-seeded diff --git a/src/apps/lyric/templatetags/lyric_extras.py b/src/apps/lyric/templatetags/lyric_extras.py index fe8c5bd..88169c7 100644 --- a/src/apps/lyric/templatetags/lyric_extras.py +++ b/src/apps/lyric/templatetags/lyric_extras.py @@ -48,3 +48,16 @@ def display_name(user): if user.username: return user.username return truncate_email(user.email) + + +@register.filter +def at_handle(user): + """`@username` when the user has set one; falls back to the truncated + email otherwise (no `@` prefix on bare emails since the address itself + already carries the `@`). Used in post.html to colour usernames in the + --quaUser palette key while leaving emails as-is.""" + if user is None: + return "" + if user.username: + return f"@{user.username}" + return truncate_email(user.email) diff --git a/src/static_src/scss/_billboard.scss b/src/static_src/scss/_billboard.scss index 76a720c..a4ef689 100644 --- a/src/static_src/scss/_billboard.scss +++ b/src/static_src/scss/_billboard.scss @@ -130,6 +130,14 @@ body.page-billposts { padding: 0.75rem; gap: 0.5rem; + // Username + title attribution spans — line author column, self/shared + // header lines, server-rendered grant prose. --quaUser palette key + // unifies them across the page; placed at .post-page scope so it + // applies in BOTH .post-header and #id_post_table descendants. + .post-attribution { + color: rgba(var(--quaUser), 1); + } + .post-header { flex-shrink: 0; @@ -169,7 +177,7 @@ body.page-billposts { .post-line-author { font-weight: bold; - opacity: 0.75; + color: rgba(var(--quaUser), 1); white-space: nowrap; font-size: 0.85rem; } diff --git a/src/templates/apps/billboard/post.html b/src/templates/apps/billboard/post.html index 5a00487..c830fc0 100644 --- a/src/templates/apps/billboard/post.html +++ b/src/templates/apps/billboard/post.html @@ -16,10 +16,10 @@

{{ post.title }}

{% with recipients=post.shared_with.all %} {% if recipients %} -

shared between {% for r in recipients %}{{ r|display_name }}{% if not forloop.last %}, {% endif %}{% endfor %}

-

& me, {{ post.owner|display_name }} the {{ post.owner.active_title_display }}

+

shared between {% for r in recipients %}{{ r|at_handle }}{% if not forloop.last %}, {% endif %}{% endfor %}

+

& me, {{ post.owner|at_handle }} the {{ post.owner.active_title_display }}

{% else %} -

just me, {{ post.owner|display_name }} the {{ post.owner.active_title_display }}

+

just me, {{ post.owner|at_handle }} the {{ post.owner.active_title_display }}

{% endif %} {% endwith %} @@ -27,7 +27,7 @@