Skip to content

Commit 190ad78

Browse files
committed
Update badge usage to use new options
1 parent 9a85e74 commit 190ad78

2 files changed

Lines changed: 21 additions & 28 deletions

File tree

templates/v3/user_profile_page.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<div class="user-profile__container">
1515
<div class="user-profile__profile-card-row">
1616
{% with user_info as user %}
17-
{% include 'v3/includes/_user_card.html' with username=user.user_name avatar_url=user.avatar_url badge_name=user.featured_badge.name badge_icon_src=user.featured_badge.icon_url member_since=user.member_since role=user.role flag_emoji='🇺🇸' compact=True %}
17+
{% include 'v3/includes/_user_card.html' with username=user.user_name avatar_url=user.avatar_url badge_name=user.featured_badge.name badge=user.featured_badge.badge member_since=user.member_since role=user.role flag_emoji='🇺🇸' compact=True %}
1818
{% endwith %}
1919
<div class="user-profile__button-group">
2020
{% include "v3/includes/_button.html" with label="GitHub" url="#" icon_name="pixel-github" icon_position="right" style="secondary" icon_viewbox="0 0 16 16" only %}

users/views.py

Lines changed: 20 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
from rest_framework.permissions import IsAuthenticated, AllowAny
2525
from waffle import flag_is_active
2626

27+
from core.constants import BadgeToken
2728
from core.mixins import V3Mixin
2829
from libraries.models import CommitAuthorEmail
2930
from .forms import (
@@ -101,22 +102,14 @@ class CurrentUserProfileView(
101102
v3_template_name = "v3/user_profile_page.html"
102103

103104
def get_v3_context_data(self, **kwargs):
104-
badge_img = f"{settings.STATIC_URL}img/v3/badges"
105105
user = self.request.user
106106
ctx = {}
107-
ctx["badge_icon_srcs"] = [
108-
f"{badge_img}/badge-first-place.png",
109-
f"{badge_img}/badge-second-place.png",
110-
f"{badge_img}/badge-bronze.png",
111-
f"{badge_img}/badge-gold-medal.png",
112-
f"{badge_img}/badge-military-star.png",
113-
]
114107
ctx["user_info"] = {
115108
"user_name": user.display_name,
116109
"avatar_url": user.get_avatar_url(),
117110
"featured_badge": {
118111
"name": "Bug Catcher",
119-
"icon_url": ctx["badge_icon_srcs"][0],
112+
"badge": BadgeToken.TIER_5,
120113
},
121114
"member_since": user.date_joined.year,
122115
"role": "Contributor",
@@ -242,34 +235,34 @@ def get_v3_context_data(self, **kwargs):
242235
}
243236
ctx["demo_badges"] = [
244237
{
245-
"icon_src": f"{badge_img}/badge-first-place.png",
246-
"name": "Patch Wizard",
247-
"earned_date": "08/08/2025",
248-
},
249-
{
250-
"icon_src": f"{badge_img}/badge-gold-medal.png",
251-
"name": "Standard Bearer",
252-
"earned_date": "03/07/2025",
253-
},
254-
{
255-
"icon_src": f"{badge_img}/badge-military-star.png",
256-
"name": "Review Hawk",
257-
"earned_date": "03/06/2025",
238+
"icon": BadgeToken.TIER_1,
239+
"name": "Code Whisperer",
240+
"earned_date": "01/01/2025",
258241
},
259242
{
260-
"icon_src": f"{badge_img}/badge-second-place.png",
243+
"icon": BadgeToken.TIER_2,
261244
"name": "Library Alchemist",
262245
"earned_date": "03/04/2025",
263246
},
264247
{
265-
"icon_src": f"{badge_img}/badge-first-place.png",
248+
"icon": BadgeToken.TIER_3,
249+
"name": "Patch Wizard",
250+
"earned_date": "08/08/2025",
251+
},
252+
{
253+
"icon": BadgeToken.TIER_4,
266254
"name": "Bug Catcher",
267255
"earned_date": "02/04/2025",
268256
},
269257
{
270-
"icon_src": f"{badge_img}/badge-bronze.png",
271-
"name": "Code Whisperer",
272-
"earned_date": "01/01/2025",
258+
"icon": BadgeToken.TIER_5,
259+
"name": "Standard Bearer",
260+
"earned_date": "03/07/2025",
261+
},
262+
{
263+
"icon": BadgeToken.STAR_TIER_3,
264+
"name": "Review Hawk",
265+
"earned_date": "03/06/2025",
273266
},
274267
]
275268
ctx["posts"] = [

0 commit comments

Comments
 (0)