|
53 | 53 | # ── V3 context helpers ───────────────────────────────────────────────────── |
54 | 54 |
|
55 | 55 |
|
56 | | -def _format_commit_authors_for_v3(authors, role): |
57 | | - """Convert CommitAuthor objects to the dict format expected by _user_profile.html.""" |
58 | | - result = [] |
59 | | - for author in authors: |
60 | | - result.append( |
61 | | - { |
62 | | - "name": getattr(author, "display_name", None) |
63 | | - or getattr(author, "name", str(author)), |
64 | | - "profile_url": getattr(author, "github_profile_url", None), |
65 | | - "role": role, |
66 | | - "avatar_url": getattr(author, "avatar_url", "") or "", |
67 | | - "badge_url": None, |
68 | | - } |
69 | | - ) |
70 | | - return result |
71 | | - |
72 | | - |
73 | 56 | def _build_quick_start_links(documentation_url, github_url, github_issues_url): |
74 | 57 | """Build the quick-start links list for the V3 library hero card.""" |
75 | 58 | links = [] |
@@ -558,22 +541,23 @@ def get_v3_context_data(self, base_context=None, **kwargs): |
558 | 541 | u.to_v3_profile_dict("Maintainer") |
559 | 542 | for u in base_context.get("maintainers", []) |
560 | 543 | ] |
561 | | - + _format_commit_authors_for_v3( |
562 | | - list(base_context.get("top_contributors_release_new", [])), |
563 | | - "New Contributor", |
564 | | - ) |
565 | | - + _format_commit_authors_for_v3( |
566 | | - list(base_context.get("top_contributors_release_old", [])), |
567 | | - "Contributor", |
568 | | - ) |
| 544 | + + [ |
| 545 | + a.to_v3_profile_dict("New Contributor") |
| 546 | + for a in base_context.get("top_contributors_release_new", []) |
| 547 | + ] |
| 548 | + + [ |
| 549 | + a.to_v3_profile_dict("Contributor") |
| 550 | + for a in base_context.get("top_contributors_release_old", []) |
| 551 | + ] |
569 | 552 | ) |
570 | 553 | context["this_release_contributors"] = ( |
571 | 554 | this_release or SharedResources.library_release_contributors |
572 | 555 | ) |
573 | 556 |
|
574 | | - all_time = _format_commit_authors_for_v3( |
575 | | - list(base_context.get("previous_contributors", [])), "Contributor" |
576 | | - ) |
| 557 | + all_time = [ |
| 558 | + a.to_v3_profile_dict("Contributor") |
| 559 | + for a in base_context.get("previous_contributors", []) |
| 560 | + ] |
577 | 561 | context["all_time_contributors"] = ( |
578 | 562 | all_time or SharedResources.library_all_contributors |
579 | 563 | ) |
|
0 commit comments