feat(2492): wire public profile to real user data - #2536
Conversation
|
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 |
|
Marked as draft until updated with all the changes from the related PRs. |
|
Merged latest changes from develop through cy/2447-profile-visibility branch. UPDATE django_migrations SET name='0024_user_country_user_hide_badges_and_more'
WHERE app='users' AND name='0023_user_country_user_hide_badges_and_more';This brings the bio and tagline, however, I'm not sure where the tagline it should appear by looking at the figma design @henryajisegiri :
(This is how it looks in the edit page:)
Update: as discussed in a recent daily, this is shown currently in the homepage for library authors, not in the public profile. |
001bae0 to
12070f8
Compare
Extract V3UserProfileContextMixin out of CurrentUserProfileView so the new public route and /users/me/ share the same read-only profile context; the only difference is the trailing header button (Edit Profile for the owner, Share for a visitor). Wire up PublicUserProfileView, the route, and User.get_absolute_url(); deactivated accounts 404 instead of staying reachable. Serve `role` instead of `public_role` to visitors: `public_role` deliberately ignores the hide-public-role opt-out so owners still see their own role, which meant the public route was leaking a role a user had explicitly hidden. Hide the achievements/badges cards (and their empty-state include) when there's no data, matching the "no empty/null UI rendered" acceptance criteria over the Figma empty-panels comp. Drop the whole right column when it would otherwise be empty, so the bio card takes full width instead of sitting next to a blank gap. Normalize edit_profile_url() to "?edit=true" for consistent querystring casing.


Issue: #2492
Summary & Context
Wires the public-facing v3 profile page (
/users/me/) to real user data instead of the demo scaffolding: renders the header (name, avatar, member-since, role, country flag), the profile-link buttons, the Bio card, and the Achievements / Badges empty-state cards, matching the Figma. Sections with no data are hidden.This PR stacks on
cy/2447-profile-visibility(#2517) and contains only the public-view commit. Will be retargeted todeveloponce #2517 merges.Changes
get_v3_context_datawithget_v3_public_context+get_v3_profile_link_buttons: the header is built from real user data (display name, avatar,year_joined, role, country flag).user.profile_links: only populated links render, email becomes amailto:, the row ends with Share, and there is no Edit Profile in the public view._safe_web_url(scheme-less becomes https;javascript:/data:dropped) to avoid stored XSS from unvalidated link values.Bio card renders an empty state ("This user hasn't added a bio yet."); the view readsUpdated, bio card renders saved bio and empty state if applicable.getattr(user, "biography", ""), so it shows the bio automatically once Story 2458: Webpage Integration: Edit User Profile - Bio and tagline #2502 lands._empty_state_card.html.users/tests/test_v3_profile_public.py(header, links, unsafe-scheme, empty bio, always-on achievements/badges).Update:
How to test
Covers the public profile page at
/users/<id>/: what a visitor (logged inor anonymous) sees when they look at someone else's profile.
The
v3flag needs to be on. Django admin → Waffle → Flags →v3→tick Everyone, save.
You need at least two accounts:
Where to set profile data
Most of what's on the page is self-service — log in as the Owner and go
to
/users/me/?edit=true:A few things are staff-only, set from Django admin on the user's own
change page (
/admin/users/user/<id>/change/):internal_role), under Personal infoTest cases
Open profiles anonymously (logged out) unless a step says otherwise.
eligible) → the badge appears in the header with that label.
Role" and save.
/users/<id>/(as the owner or anonymously)still shows their role — the profile page is exempt from the opt-out.
news feed's user card), if that surface is reachable in this
environment.
3. Bio
render as real HTML (not literal
**/*/-characters)."This user hasn't added a bio yet." rather than nothing.
underline syntax. Not a bug if it's missing.
4. Profile links
Share, in that order.
buttons). Email link should be a
mailto:link.5. Sections with no data are hidden
contributions: the page shows the bio card (with its empty state) and
nothing else — no empty panels, headings, or placeholder cards for
GitHub activity, badges, achievements, or posts.
library role shows no Author/Maintainer/Contributor rows in the bio card.
6. Share vs. Edit Profile
Edit Profile).
/users/<id>/URL → buttonis Edit Profile instead. (This is the one case where the button
depends on who's looking, not just which URL.)
7. Nothing owner-facing leaks to the public
On any profile you don't own (anonymous or as Visitor), confirm none of the
following appear anywhere on the page: Edit Profile, Account
connections, Save Changes, Delete Account, Commit Email,
Email Preferences — and there's no form, input, or dropdown anywhere on
the page. It should read as a static page.
8. No-JS rendering
doesn't execute it) and reload a populated profile.
present — this page is server-rendered, not client-assembled.
9. Unknown / deactivated account
number) → 404, not a blank or broken page.
URL also 404s.
Out of scope for this ticket
here; needs an OAuth scope spike)
PRs that should land first (so the public view can show complete data)
This PR renders today (with empty/stub states) but depends on fields owned by other pending PRs. Recommended order:
User.biography; required for the Bio to render (empty state until then).User.rolestub ("Contributor") until then.User.get_contributor_data()for the Bio card's contributor section (needs a one-line wiring here once merged).Risks & Considerations
Screenshots
Empty
With Bio, Profile links and Country
With library contributions
With avatar
Self-review Checklist
Frontend