Story 2490: Group Icon for Various Author cases in User Profile#2501
Story 2490: Group Icon for Various Author cases in User Profile#2501julhoang wants to merge 57 commits into
Conversation
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.
- exclusions: match case-insensitively in admin to avoid IntegrityError on a case-variant of an already-excluded term - move HOMEPAGE_POPULAR_TERMS_DISPLAY to core/constants.py (drops the circular-import workaround in core/admin.py) - drop vestigial `skipped` flag from the refresh result (always False) - reduce label / exclusion term max_length to 64 - add trailing newline to env.template
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
templates/v3/includes/_avatar_v3.html (1)
30-34: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueConsider normalizing the
aria-labelto 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 viaapply_collective_author_overridesand 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
📒 Files selected for processing (10)
core/views.pylibraries/utils.pylibraries/views.pystatic/css/v3/avatar.cssstatic/css/v3/contributors-list.csstemplates/includes/icon.htmltemplates/v3/includes/_avatar_v3.htmlusers/templatetags/avatar_tags.pyusers/tests/test_avatar_tags.pyversions/views.py
julioest
left a comment
There was a problem hiding this comment.
Approved ✅ Clicked through the demo + a library page. The "Various Authors" card looks great and everything else works as expected
herzog0
left a comment
There was a problem hiding this comment.
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?
|
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 |
5f915df to
da79fd3
Compare
Issue: #2490
developSummary & 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
is_collective_authorandcollective_author_labelfilters tousers/templatetags/avatar_tags.py— regex match on names starting with "various" (case-insensitive), with a canonical "Various Authors" display labelapply_collective_author_overrides()helper tolibraries/utils.py— for matching V3 profile dicts, setsname→ "Various Authors",profile_url→ None,role→ NoneAvatar group icon
people-groupicon totemplates/includes/icon.html_avatar_v3.html— new top-priority branch renders the group icon whennameis a collective label; rendering order is now group icon → image → initials → placeholder.avatar--collectivestyles toavatar.css— icon scales to fill the avatar container, inset by--space-mediumApply across author/contributor surfaces
apply_collective_author_overrides()into the three V3 builders that shape author/contributor dicts:libraries/utils.pybuild_library_intro_context– homepage Library Intro cardlibraries/views.pyLibraryDetail.get_v3_context_data– "This Release" and "All Contributors" listsversions/views.pyVersionDetail.get_v3_contributors– release-page contributorsDemo & tests
users/tests/test_avatar_tags.pycovering both filtersRisks & Considerations
_avatar_v3.htmlrenders 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…").static/css/v3/contributors-list.cssaddsoverflow-y: autoto fix the overflow issue on the V3 demo page.Peer-Testing Guidelines
Screenshots
Self-review Checklist
Frontend
Summary by CodeRabbit
New Features
Bug Fixes
Tests