Skip to content

Story 2490: Group Icon for Various Author cases in User Profile#2501

Open
julhoang wants to merge 57 commits into
developfrom
julia/various-authors-design
Open

Story 2490: Group Icon for Various Author cases in User Profile#2501
julhoang wants to merge 57 commits into
developfrom
julia/various-authors-design

Conversation

@julhoang

@julhoang julhoang commented Jun 24, 2026

Copy link
Copy Markdown
Collaborator

Issue: #2490

⚠️ Base branch is Homepage Popular Search Term (#2481), not develop ⚠️

Summary & Context

Renders libraries whose author is a collective label (e.g. "Various Authors") with a group icon instead of a single-person initial/avatar, and shows them as a single un-linked line with no role. Applies the same treatment everywhere library authors/contributors are listed.

Changes

Collective-author detection

  • Add is_collective_author and collective_author_label filters to users/templatetags/avatar_tags.py — regex match on names starting with "various" (case-insensitive), with a canonical "Various Authors" display label
  • Add apply_collective_author_overrides() helper to libraries/utils.py — for matching V3 profile dicts, sets name → "Various Authors", profile_url → None, role → None

Avatar group icon

  • Add people-group icon to templates/includes/icon.html
  • Update _avatar_v3.html — new top-priority branch renders the group icon when name is a collective label; rendering order is now group icon → image → initials → placeholder
  • Add .avatar--collective styles to avatar.css — icon scales to fill the avatar container, inset by --space-medium

Apply across author/contributor surfaces

  • Wire apply_collective_author_overrides() into the three V3 builders that shape author/contributor dicts:
    • libraries/utils.py build_library_intro_context – homepage Library Intro card
    • libraries/views.py LibraryDetail.get_v3_context_data – "This Release" and "All Contributors" lists
    • versions/views.py VersionDetail.get_v3_contributors – release-page contributors

Demo & tests

  • Add a "Various Authors" case to the V3 Demo page's User Profile section.
  • Add users/tests/test_avatar_tags.py covering both filters

Risks & Considerations

  • Broad regex match: any name starting with "various" is treated as collective. This is intended for the first iteration (only known case: Boost.Math), but note it now applies to contributor lists too, not just the intro card.
  • Template-level detection is global: _avatar_v3.html renders the group icon for any avatar whose name starts with "various", including surfaces that don't run the override (e.g. news author cards). The name/link/role normalization is scoped to the library author/contributor paths only. Harmless in practice (real users aren't named "Various…").
  • Unrelated change: static/css/v3/contributors-list.css adds overflow-y: auto to fix the overflow issue on the V3 demo page.

Peer-Testing Guidelines

  1. Visit http://localhost:8000/v3/demo/components/#user-profile — the last entry ("Various Authors") should render the group icon with a single name line, no role, and no profile link. Confirm the surrounding individual profiles are unchanged.
  2. To set up Boost.Math as featured library on homepage: Visit http://localhost:8000/cms/settings/core/homepagesettings/1/ and select "Math"
Screenshot 2026-06-24 at 1 05 43 PM 3. Re-load the homepage Library Intro card and confirm the group icon + single line. 4. Open a library detail page (http://localhost:8000/library/latest/math/); confirm the contributor cards give any collective author the same treatment and that normal contributors keep their avatar/role/link.

Screenshots

Before After
Screenshot 2026-06-24 at 1 08 46 PM Screenshot 2026-06-24 at 1 08 09 PM
Screenshot 2026-06-24 at 1 09 55 PM Screenshot 2026-06-24 at 1 10 41 PM
Screenshot 2026-06-24 at 1 10 10 PM Screenshot 2026-06-24 at 1 10 33 PM

Self-review Checklist

  • Tag at least one team member from each team to review this PR
  • Link this PR to the related GitHub Project ticket

Frontend

  • UI implementation matches Figma design
  • Tested in light and dark mode
  • Responsive / mobile verified
  • Accessibility checked (keyboard navigation, etc.)
  • Ensure design tokens are used for colors, spacing, typography, etc. – No hardcoded values
  • Test without JavaScript (if applicable)
  • No console errors or warnings

Summary by CodeRabbit

  • New Features

    • Added support for a collective “Various Authors” profile style across contributor and author displays.
    • Introduced a group/avatar icon for collective author entries.
  • Bug Fixes

    • Improved contributor rendering so collective author names display consistently with the correct label and missing profile link/role.
    • Updated contributor lists to better handle overflow in tall layouts.
  • Tests

    • Added coverage for collective-author detection and label normalization.

julhoang added 30 commits June 24, 2026 09:12
Adds Entry.to_v3_post_card_dict() and fixes the two existing
to_v3_profile_dict() methods (User, CommitAuthor) to actually match
their template contract:
- 'badge_url' -> 'badge' (the dead key no template ever read)
- 'bio' added to CommitAuthor for the 6-key shape consistency
- User name fallback no longer returns the email-suffixed __str__

Reuses these methods to collapse two inline card dicts:
- CommunityView.get_v3_context_data: 20-line post-dict comprehension
- build_library_intro_context: 20-line author dict block, including a
  latent AttributeError on the dormant top_contributors branch.

POST_CARD_TAG_LABELS lives on news/models.py as the single source of
truth for category labels.
Moves per-card data shaping out of HomepageView.get_v3_context_data
and into ak/homepage.py:
- build_community_posts, build_join_developers_links,
  build_get_started_code, build_library_intro, hero_image_context
- WHY_BOOST_CARDS, HELLO_WORLD_SNIPPET, HERO_* constants at module
  scope so they allocate once at import, not per request

Flattens the card context wrappers ({'items': [...]}/'bars': [...])
so each context key carries a flat list. Chrome (heading, CTA,
variant, theme) moves into the homepage template, matching how
other V3 surfaces already pass these literals.

Co-locates event_to_card_dict + upcoming_events next to the rest of
the calendar pipeline in core/calendar.py.

HomepageView.get_v3_context_data goes from ~150 lines to ~40 lines
of one-key-per-line orchestration.
@coderabbitai

coderabbitai Bot commented Jun 24, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 8bc33abe-50a5-43d0-b972-646fa0cf3237

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • ✅ Review completed - (🔄 Check again to review again)
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch julia/various-authors-design

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@julhoang julhoang changed the title feat: add new group icon for various author cases in user profile Story 2490: Group Icon for Various Author cases in User Profile Jun 24, 2026
@julhoang julhoang marked this pull request as ready for review June 24, 2026 20:16

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
templates/v3/includes/_avatar_v3.html (1)

30-34: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Consider normalizing the aria-label to the canonical collective label.

The wrapper exposes aria-label="{{ name }}", which echoes the raw input. If this template is included with a non-canonical collective value (e.g. name="various"), screen readers will announce "various" rather than "Various Authors". Production paths normalize via apply_collective_author_overrides and the demo passes a normalized string, so this is only a hardening nit for direct includes.

♻️ Normalize label for direct includes
-  {% if name|is_collective_author %}
-    <span class="avatar avatar--{{ size }} avatar--collective" role="img" aria-label="{{ name }}">
+  {% if name|is_collective_author %}
+    <span class="avatar avatar--{{ size }} avatar--collective" role="img" aria-label="{{ name|collective_author_label }}">
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@templates/v3/includes/_avatar_v3.html` around lines 30 - 34, The collective
avatar branch in _avatar_v3.html uses aria-label from the raw name value, so
direct includes can announce a non-canonical label. Update the conditional
branch that renders the avatar--collective span to derive the accessible label
from the normalized collective author value instead of echoing name, consistent
with apply_collective_author_overrides and the existing collective handling in
the template.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@templates/v3/includes/_avatar_v3.html`:
- Around line 30-34: The collective avatar branch in _avatar_v3.html uses
aria-label from the raw name value, so direct includes can announce a
non-canonical label. Update the conditional branch that renders the
avatar--collective span to derive the accessible label from the normalized
collective author value instead of echoing name, consistent with
apply_collective_author_overrides and the existing collective handling in the
template.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: dc3126c2-a0fe-4b15-a919-bb82e891d47a

📥 Commits

Reviewing files that changed from the base of the PR and between 8d97155 and 6a0ebee.

📒 Files selected for processing (10)
  • core/views.py
  • libraries/utils.py
  • libraries/views.py
  • static/css/v3/avatar.css
  • static/css/v3/contributors-list.css
  • templates/includes/icon.html
  • templates/v3/includes/_avatar_v3.html
  • users/templatetags/avatar_tags.py
  • users/tests/test_avatar_tags.py
  • versions/views.py

@julioest julioest self-requested a review June 29, 2026 21:26

@julioest julioest left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved ✅ Clicked through the demo + a library page. The "Various Authors" card looks great and everything else works as expected

@herzog0 herzog0 self-requested a review July 2, 2026 16:56

@herzog0 herzog0 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Heya, thanks for this @julhoang!
I was just wondering if a better place to put this logic in wouldn't be the two to_v3_profile_dict methods in users/models.py and libraries/models.py.

Every array that are passed as arguments to apply_collective_author_overrides had previously been generated by to_v3_profile_dict, so I think there won't be any loose ties in this case.

Anything I'm not considering in here?

@julhoang

julhoang commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator Author

Hi @herzog0, thanks for raising this! I did consider that approach, but I chose to scope it down to just the Library Intro card context and the Libraries context for greater control. I noticed the to_v3_profile_dict method is used across a wider variety of cases (e.g. post authors, possibly Boost user profiles, etc.), so with a generic regex matching only "Various", I'd prefer to keep the scope of impact contained. Does this sound reasonable to you?

@herzog0 herzog0 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@julhoang yep, sure thing, approved then, thanks!

@julhoang julhoang force-pushed the julia/homepage-search-popular-terms branch 2 times, most recently from 5f915df to da79fd3 Compare July 8, 2026 19:06
Base automatically changed from julia/homepage-search-popular-terms to develop July 8, 2026 19:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Task: Homepage – Show group icon for collective author labels (e.g. "Various Authors")

3 participants