Skip to content

Commit f460d9e

Browse files
authored
Add GitHub Issue URL column to Sponsorship (#298)
* Add GitHub Issue URL column to Sponsorship Closes #295
1 parent 563d74f commit f460d9e

File tree

9 files changed

+73
-1
lines changed

9 files changed

+73
-1
lines changed

sponsorship/admin.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ class SponsorshipProfileAdmin(ImportExportModelAdmin):
5555
"sponsorship_tier",
5656
"progress_status",
5757
"sponsorship_override_amount",
58+
"github_issue_url",
5859
"po_number",
5960
"main_contact_user",
6061
)
@@ -74,6 +75,7 @@ class SponsorshipProfileAdmin(ImportExportModelAdmin):
7475
"logo",
7576
"company_description",
7677
"progress_status",
78+
"github_issue_url",
7779
"main_contact_user",
7880
)
7981
resource_classes = [SponsorshipProfileResource]

sponsorship/forms.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ class Meta:
2626
"logo",
2727
"company_description",
2828
"progress_status",
29+
"github_issue_url",
2930
]
3031
widgets = {
3132
"company_description": forms.Textarea(
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Generated by Django 5.2.8 on 2025-12-05 00:45
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
("sponsorship", "0007_individualdonation"),
10+
]
11+
12+
operations = [
13+
migrations.AddField(
14+
model_name="sponsorshipprofile",
15+
name="github_issue_url",
16+
field=models.URLField(
17+
blank=True,
18+
help_text="Link to the GitHub issue tracking this sponsorship",
19+
null=True,
20+
),
21+
),
22+
]

sponsorship/models.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,11 @@ class SponsorshipProfile(BaseModel):
6969
null=True,
7070
help_text="Purchase Order number for the sponsorship contract and invoice",
7171
)
72+
github_issue_url = models.URLField(
73+
blank=True,
74+
null=True,
75+
help_text="Link to the GitHub issue tracking this sponsorship",
76+
)
7277

7378
def __str__(self):
7479
return self.organization_name

sponsorship/templates/sponsorship/sponsorship_profile_detail.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,11 @@ <h6>
109109
<p>
110110
<strong>Last Updated:</strong> {{ profile.modified_date }}
111111
</p>
112+
<p>
113+
<strong>GitHub Issue:</strong> <a href="{{ profile.github_issue_url }}"
114+
target="_blank"
115+
rel="noopener noreferrer">{{ profile.github_issue_url }}</a>
116+
</p>
112117
</div>
113118
</div>
114119
</div>

sponsorship/templates/sponsorship/sponsorship_profile_form.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ <h5 class="card-title mb-0">
4646
{% bootstrap_field form.logo %}
4747
{% bootstrap_field form.company_description %}
4848
{% bootstrap_field form.progress_status %}
49+
{% bootstrap_field form.github_issue_url %}
4950
</div>
5051
</div>
5152
<div class="mt-4">

sponsorship/views.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ class SponsorshipProfileTable(tables.Table):
6666
accessor="sponsorship_tier__name", verbose_name="Sponsorship Tier"
6767
)
6868
logo = tables.Column(accessor="logo", verbose_name="Logo")
69+
github_issue_url = tables.Column(
70+
accessor="github_issue_url", verbose_name="GitHub Issue"
71+
)
6972

7073
class Meta:
7174
model = SponsorshipProfile
@@ -75,6 +78,7 @@ class Meta:
7578
"tier_name",
7679
"amount",
7780
"progress_status",
81+
"github_issue_url",
7882
"creation_date",
7983
"updated_date",
8084
"actions",
@@ -153,6 +157,16 @@ def render_actions(self, value, record):
153157
edit_url,
154158
)
155159

160+
def render_github_issue_url(self, value, record):
161+
"""Render the GitHub Issue URL if exists."""
162+
if value:
163+
return format_html(
164+
'<a href="{}" target="_blank"><i class="fa-brands fa-github"></i></a>',
165+
value,
166+
)
167+
else:
168+
return ""
169+
156170

157171
class SponsorshipProfileFilter(django_filters.FilterSet):
158172
search = django_filters.CharFilter(

templates/emails/sponsorship/sponsor_information_partial.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@
99
- **Sponsor Address:** {{ profile.organization_address }}
1010
- **Sponsorship Amount:** {% if profile.sponsorship_override_amount %}Custom Amount: {{ profile.sponsorship_override_amount }}{% else %}As per tier: {{ profile.sponsorship_tier.amount }}{% endif %}
1111
- **PO Number:** {% if profile.po_number %}{{ profile.po_number }}{% else %}N/A{% endif %}
12-
- **Internal Contact User:** {{ profile.main_contact_user.get_full_name }}
12+
- **Internal Contact User:** {{ profile.main_contact_user.get_full_name }}
13+
- **GitHub Issue Url**: {% if profile.github_issue_url %}{{ profile.github_issue_url }}{% else %}N/A{% endif %}

tests/sponsorship/test_views.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,27 @@ def test_sponsors_table_render_actions(self, client, admin_user):
255255
assert "btn-primary" in action_button
256256
assert "Update" in action_button
257257

258+
def test_sponsors_table_render_github_issue_url(self, client, admin_user):
259+
260+
profile = SponsorshipProfile.objects.create(
261+
organization_name="Override Corp",
262+
)
263+
264+
client.force_login(admin_user)
265+
url = reverse("sponsorship:sponsorship_list")
266+
267+
response = client.get(url)
268+
sponsors_table = response.context["table"]
269+
gh_url_render = sponsors_table.render_github_issue_url("", profile)
270+
assert gh_url_render == ""
271+
272+
profile.github_issue_url = "https://github.com/python/cpython/issues/1234"
273+
profile.save()
274+
gh_url_render = sponsors_table.render_github_issue_url(
275+
profile.github_issue_url, profile
276+
)
277+
assert profile.github_issue_url in gh_url_render
278+
258279

259280
@pytest.mark.django_db
260281
class TestSponsorshipCreateViews:

0 commit comments

Comments
 (0)