Story #2558 :: Task: Show real earned badges on the v3 user profile (and honour hide_badges) - #2627
Open
herzog0 wants to merge 2 commits into
Open
Story #2558 :: Task: Show real earned badges on the v3 user profile (and honour hide_badges)#2627herzog0 wants to merge 2 commits into
hide_badges)#2627herzog0 wants to merge 2 commits into
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:
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 |
11 tasks
hide_badges)hide_badges)
herzog0
force-pushed
the
teo/2486-badge-profile-display
branch
from
August 14, 2026 19:57
16e9173 to
6619fe7
Compare
herzog0
force-pushed
the
teo/2486-badge-profile-display
branch
2 times, most recently
from
August 17, 2026 16:32
bf61013 to
7e32217
Compare
herzog0
force-pushed
the
teo/2486-badge-profile-display
branch
from
August 17, 2026 17:22
7e32217 to
91f238b
Compare
herzog0
force-pushed
the
teo/2486-badge-profile-display
branch
2 times, most recently
from
August 17, 2026 23:06
8d329a6 to
69c0dda
Compare
herzog0
force-pushed
the
teo/2486-badge-profile-display
branch
from
August 18, 2026 14:28
69c0dda to
92bb266
Compare
herzog0
force-pushed
the
teo/2486-badge-profile-display
branch
from
August 21, 2026 14:48
92bb266 to
c7c88d9
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Not a duplicate, Github thought the previous one (#2614) was closed since the branches changed order in the PR stack, so I'm reopening this.
Issue: #2558
julia/badge-selectionSummary & Context
The user-visible half. Real badges replace the placeholder gold medal everywhere a badge is
rendered: the profile page, the profile card, news author cards, the post list and the community
page.
badges/display.pyis the whole presentation boundary. The v3 badge templates take a componenttoken and a label, never a model instance, so the rank-to-asset mapping lives there rather than on
the user model.
Changes
badges/display.pyheld_badges- the member's active badges, highest rank first, each rank once. Retiring atier keeps the badges already awarded against it, so a member who also qualifies under its
replacement holds the same rank twice; both rows are real history but only one is a badge to
show.
featured_badge/badge_cards/badge_card.TIER_TOKENS- bronze/silver/gold/platinum/diamond tobadge-tier-1..5, diamond at thetop. A test asserts the token numbers climb with the rank ladder so the pair cannot drift
apart again.
active_badges_prefetch(lookup)- the prefetch every multi-card page needs.hide_badgesfails closed.held_badgesreturns an empty list when the member has hiddentheir badges; only the owner's own views pass
include_hidden.User.featured_badgereplaces thebadge_urlplaceholder. It lives on the model onlybecause templates read it as an attribute; everything about selection and rendering is in
badges.display.users/profile_cards.py: emitsbadge/badge_label. It previously emittedbadge_urlwhile
_user_profile.htmlreadsauthor.badge, so news author cards rendered no badge atall even once real data existed. That is a defect on
develop, fixed here because it is thesame feature.
dateobjects rendered through Django'sDATE_FORMAT, taken throughtimezone.localtimeso an evening award is not dated to the next day west of UTC. There is atest under
TIME_ZONE="America/New_York"pinning it.ak/homepage.py,core/views.py(community),news/views.py(post detail),libraries/mixins.pyandlibraries/utils.py(contributor lists). Each has a constant-query regression test. Thequerysets that
select_relatedthe author ask for badges through the path(
author__badges), becausePrefetch("author", queryset=...)is silently dropped when the FKis already cached.
develop:core/views.py's v3 examples page labelledtier-4 "Diamond" and tier-5 "Platinum" on both the badge and star sets. Platinum is tier 4,
diamond is tier 5. The same inversion in the
_badge_v3.htmlheader comment and theprofile-edit mock is corrected too.
wrong badge; each call site has a
django_assert_num_queriestest, so a regression failsloudly.
featured_badgeis acached_property. A view that awards a badge and re-renders the sameuser instance in one request would show the stale value. Nothing does that today.
one. Letting them pick is a separate ticket
Separate ticket.
Separate ticket. This PR renders what a member has,
not what they could earn.
templates/v3/user_profile_page.htmlswitches from thedemo_badgesmock toprofile_badges.The
core/views.pyexamples page keeps itsdemo_*fixtures, correctly.Screenshots
Peer-review testing steps
Setup.
just migrate,docker compose up, and turn the v3 flag on for everyone at/admin/waffle/flag/- every template here is a v3 one. For step 8 you also needDEBUG_TOOLBAR=Truein
.envand a restart./admin/badges/userachievement/add/- your user, achievementLibrary Authoring, and a note (it is required for a manual grant). Save. Bronze is one grant, so
/admin/badges/userbadge/shows Library Author / Bronze immediately./users/me/- the placeholder gold medal is gone and Bronze is on the card. Thebadges card lists it once, with the award date. Cross-check that date against Awarded at in the
admin: they must be the same day, which is the timezone fix.
grants are intended, counts accumulate). Reload
/users/me/: the card now shows Silver, whilethe badges card lists Bronze and Silver. The card shows one badge, the list shows the ladder.
card lists Gold, Silver, Bronze in that order, highest rank first. Now raise Gold's threshold to 6 on
/admin/badges/badge/: the admin says it retired the old tier and created a replacement, and yourGold stays on the profile even though you no longer meet the new number. That is the
grandfathering working as intended, not a stale render. (One rank showing twice is the case the
dedup in
held_badgesguards; it needs rows the admin will not create for you, so it is covered bytest rather than by hand.)
/news/, the post detailpage,
/community/and the homepage. Your author card carries the same badge on all four. On thebase branch the news author card renders no badge at all even with real data, so this is a fix to
confirm, not just a check.
/admin/libraries/libraryversion/(the contributor cards read the version, not the library), thenopen
/library/<version>/<library>/: those cards carry badges too./users/me/?edit=true. Yourown profile still shows them, because the owner's view passes
include_hidden. Then open/community/,/news/and your post's detail page in a logged-out window: your card there hasno badge at all.
/community/,/news/and a postdetail page. Grant badges to several more members whose cards appear on those pages, reload, and the
count must be unchanged. A count that climbs with the number of cards is the regression these
prefetches exist to prevent.
/v3/demo/components/(staff only) - tier-4 is Platinum andtier-5 is Diamond, on both the badge set and the star set. It was inverted on the base branch.
/users/me/and/community/: badges are server-renderedand must all still be there.
/admin/badges/userbadge/(the action asksfor a note).
/users/me/falls back to Silver on the card, Gold leaves the badges list, and nothingelse moves.
Self-review Checklist
Frontend
Backend