fix: organize admin patches and profile menu layering

This commit is contained in:
kai
2026-08-28 14:50:54 +02:00
parent f0d40f5fd4
commit d79e303396
4 changed files with 50 additions and 47 deletions
+12 -12
View File
@@ -1620,11 +1620,21 @@ def admin_patches_page(request: Request):
"icon": icon,
"description": description,
"image_path": assets.get(code),
"category": category,
}
for code, name, icon, _threshold, description, _category in BADGE_DEFINITIONS
for code, name, icon, _threshold, description, category in BADGE_DEFINITIONS
]
patch_groups = [
{
"code": category,
"label": label,
"patches": [patch for patch in patches if patch["category"] == category],
}
for category, label in BADGE_CATEGORY_LABELS.items()
if any(patch["category"] == category for patch in patches)
]
template = templates.get_template("admin_patches.html")
return template.render(user=user, patches=patches)
return template.render(user=user, patch_groups=patch_groups)
@app.get("/admin/statistics", response_class=HTMLResponse)
@@ -2479,15 +2489,6 @@ def render_profile(
for code, name, icon, threshold, description, category in BADGE_DEFINITIONS
]
badges.sort(key=lambda badge: badge["sort_key"])
badge_groups = [
{
"code": category,
"label": label,
"badges": [badge for badge in badges if badge["earned"] and badge["category"] == category],
}
for category, label in BADGE_CATEGORY_LABELS.items()
if any(badge["earned"] and badge["category"] == category for badge in badges)
]
template = templates.get_template("profile.html")
return HTMLResponse(
@@ -2496,7 +2497,6 @@ def render_profile(
profile=profile,
attended_count=attendance_stats["total"],
badges=badges,
badge_groups=badge_groups,
is_own_profile=force_own or is_own_profile,
can_view_details=can_view_details,
friendship=friendship,