Skip to content

Commit a138b28

Browse files
authored
Update BoD candidates page (#2458)
* Update BoD candidates page * Update code * Update code * Update tests
1 parent 9eed1d9 commit a138b28

36 files changed

+2375
-168
lines changed

backend/apps/github/admin/user.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,13 @@ class MemberProfileInline(admin.StackedInline):
1212
model = MemberProfile
1313
can_delete = False
1414
verbose_name_plural = "OWASP Member Profile"
15-
fields = ("owasp_slack_id", "first_contribution_at")
15+
fields = (
16+
"owasp_slack_id",
17+
"first_contribution_at",
18+
"is_owasp_board_member",
19+
"is_former_owasp_staff",
20+
"is_gsoc_mentor",
21+
)
1622
readonly_fields = ("first_contribution_at",)
1723

1824

backend/apps/github/api/internal/nodes/user.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,27 @@ def first_owasp_contribution_at(self) -> float | None:
6262
return self.owasp_profile.first_contribution_at.timestamp()
6363
return None
6464

65+
@strawberry.field
66+
def is_owasp_board_member(self) -> bool:
67+
"""Resolve if member is currently on OWASP Board of Directors."""
68+
if hasattr(self, "owasp_profile"):
69+
return self.owasp_profile.is_owasp_board_member
70+
return False
71+
72+
@strawberry.field
73+
def is_former_owasp_staff(self) -> bool:
74+
"""Resolve if member is a former OWASP staff member."""
75+
if hasattr(self, "owasp_profile"):
76+
return self.owasp_profile.is_former_owasp_staff
77+
return False
78+
79+
@strawberry.field
80+
def is_gsoc_mentor(self) -> bool:
81+
"""Resolve if member is a Google Summer of Code mentor."""
82+
if hasattr(self, "owasp_profile"):
83+
return self.owasp_profile.is_gsoc_mentor
84+
return False
85+
6586
@strawberry.field
6687
def issues_count(self) -> int:
6788
"""Resolve issues count."""

backend/apps/github/management/commands/github_sync_user.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -470,11 +470,11 @@ def handle(self, *args, **options):
470470
f"{len(commits_data)} commits for {username}"
471471
)
472472
)
473-
474-
# Always populate first contribution date if not already set
475-
self.populate_first_contribution_only(username, user, gh)
476473
else:
477474
self.stdout.write(
478475
self.style.WARNING(f"No PRs, issues, or commits found for {username}")
479476
)
480477
logger.warning("No PRs, issues, or commits found for %s", username)
478+
479+
# Always populate first contribution date if not already set
480+
self.populate_first_contribution_only(username, user, gh)

backend/apps/owasp/admin/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from .entity_channel import EntityChannelAdmin
1111
from .entity_member import EntityMemberAdmin
1212
from .event import EventAdmin
13+
from .member_profile import MemberProfileAdmin
1314
from .member_snapshot import MemberSnapshotAdmin
1415
from .post import PostAdmin
1516
from .project import ProjectAdmin
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
"""Django admin configuration for MemberProfile model."""
2+
3+
from django.contrib import admin
4+
5+
from apps.owasp.models.member_profile import MemberProfile
6+
7+
8+
class MemberProfileAdmin(admin.ModelAdmin):
9+
"""Admin for MemberProfile model."""
10+
11+
autocomplete_fields = ("github_user",)
12+
list_display = (
13+
"github_user",
14+
"owasp_slack_id",
15+
"first_contribution_at",
16+
"is_owasp_board_member",
17+
"is_former_owasp_staff",
18+
"is_gsoc_mentor",
19+
"nest_created_at",
20+
)
21+
list_filter = (
22+
"is_owasp_board_member",
23+
"is_former_owasp_staff",
24+
"is_gsoc_mentor",
25+
"nest_created_at",
26+
)
27+
search_fields = (
28+
"github_user__login",
29+
"github_user__name",
30+
"owasp_slack_id",
31+
)
32+
readonly_fields = (
33+
"nest_created_at",
34+
"nest_updated_at",
35+
)
36+
37+
fieldsets = (
38+
(
39+
"User Information",
40+
{
41+
"fields": (
42+
"github_user",
43+
"owasp_slack_id",
44+
)
45+
},
46+
),
47+
(
48+
"Contribution Information",
49+
{"fields": ("first_contribution_at",)},
50+
),
51+
(
52+
"Membership Flags",
53+
{
54+
"fields": (
55+
"is_owasp_board_member",
56+
"is_former_owasp_staff",
57+
"is_gsoc_mentor",
58+
)
59+
},
60+
),
61+
(
62+
"Timestamps",
63+
{
64+
"fields": (
65+
"nest_created_at",
66+
"nest_updated_at",
67+
),
68+
"classes": ("collapse",),
69+
},
70+
),
71+
)
72+
73+
def get_queryset(self, request):
74+
"""Optimize queryset with select_related."""
75+
queryset = super().get_queryset(request)
76+
return queryset.select_related("github_user")
77+
78+
79+
admin.site.register(MemberProfile, MemberProfileAdmin)

backend/apps/owasp/admin/member_snapshot.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ class MemberSnapshotAdmin(admin.ModelAdmin):
1313
"commits",
1414
"pull_requests",
1515
"issues",
16+
"messages",
1617
)
1718
list_display = (
1819
"github_user",
@@ -21,6 +22,7 @@ class MemberSnapshotAdmin(admin.ModelAdmin):
2122
"commits_count",
2223
"pull_requests_count",
2324
"issues_count",
25+
"messages_count",
2426
"total_contributions",
2527
"nest_created_at",
2628
)
@@ -37,10 +39,14 @@ class MemberSnapshotAdmin(admin.ModelAdmin):
3739
"commits_count",
3840
"pull_requests_count",
3941
"issues_count",
42+
"messages_count",
4043
"total_contributions",
4144
"contribution_heatmap_data",
45+
"communication_heatmap_data",
4246
"chapter_contributions",
4347
"project_contributions",
48+
"repository_contributions",
49+
"channel_communications",
4450
"nest_created_at",
4551
"nest_updated_at",
4652
)
@@ -58,7 +64,7 @@ class MemberSnapshotAdmin(admin.ModelAdmin):
5864
},
5965
),
6066
(
61-
"Contributions",
67+
"GitHub Contributions",
6268
{
6369
"fields": (
6470
"commits",
@@ -67,17 +73,25 @@ class MemberSnapshotAdmin(admin.ModelAdmin):
6773
)
6874
},
6975
),
76+
(
77+
"Slack Communications",
78+
{"fields": ("messages",)},
79+
),
7080
(
7181
"Statistics",
7282
{
7383
"fields": (
7484
"commits_count",
7585
"pull_requests_count",
7686
"issues_count",
87+
"messages_count",
7788
"total_contributions",
7889
"contribution_heatmap_data",
90+
"communication_heatmap_data",
7991
"chapter_contributions",
8092
"project_contributions",
93+
"repository_contributions",
94+
"channel_communications",
8195
)
8296
},
8397
),

backend/apps/owasp/api/internal/nodes/member_snapshot.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,11 @@
1313
"start_at",
1414
"end_at",
1515
"contribution_heatmap_data",
16+
"communication_heatmap_data",
1617
"chapter_contributions",
1718
"project_contributions",
19+
"repository_contributions",
20+
"channel_communications",
1821
],
1922
)
2023
class MemberSnapshotNode(strawberry.relay.Node):
@@ -40,6 +43,11 @@ def pull_requests_count(self) -> int:
4043
"""Resolve pull requests count."""
4144
return self.pull_requests_count
4245

46+
@strawberry.field
47+
def messages_count(self) -> int:
48+
"""Resolve Slack messages count."""
49+
return self.messages_count
50+
4351
@strawberry.field
4452
def total_contributions(self) -> int:
4553
"""Resolve total contributions."""

0 commit comments

Comments
 (0)