Skip to content

Commit 2a1af2b

Browse files
committed
Support GitHub sponsors as a payout option
1 parent 87768f7 commit 2a1af2b

File tree

4 files changed

+124
-0
lines changed

4 files changed

+124
-0
lines changed

adserver/constants.py

+2
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,13 @@
3535
PAYOUT_STRIPE = "stripe"
3636
PAYOUT_PAYPAL = "paypal"
3737
PAYOUT_OPENCOLLECTIVE = "opencollective"
38+
PAYOUT_GITHUB = "github"
3839
PAYOUT_OTHER = "other"
3940
PUBLISHER_PAYOUT_METHODS = (
4041
(PAYOUT_STRIPE, _("Stripe (Bank transfer, debit card)")),
4142
(PAYOUT_PAYPAL, _("PayPal")),
4243
(PAYOUT_OPENCOLLECTIVE, _("Open Collective")),
44+
(PAYOUT_GITHUB, _("GitHub sponsors")),
4345
(PAYOUT_OTHER, _("Other")),
4446
)
4547

adserver/forms.py

+9
Original file line numberDiff line numberDiff line change
@@ -1198,6 +1198,14 @@ def __init__(self, *args, **kwargs):
11981198
Field("paypal_email", placeholder="[email protected]"),
11991199
data_bind="visible: (payoutMethod() == 'paypal')",
12001200
),
1201+
Div(
1202+
PrependedText(
1203+
"github_sponsors_name",
1204+
"https://github.com/sponsors/",
1205+
placeholder="your-github-name",
1206+
),
1207+
data_bind="visible: (payoutMethod() == 'github')",
1208+
),
12011209
"skip_payouts",
12021210
css_class="my-3",
12031211
),
@@ -1242,6 +1250,7 @@ class Meta:
12421250
"payout_method",
12431251
"open_collective_name",
12441252
"paypal_email",
1253+
"github_sponsors_name",
12451254
"skip_payouts",
12461255
"allow_affiliate_campaigns",
12471256
"allow_community_campaigns",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
# Generated by Django 4.2.4 on 2024-02-16 20:54
2+
from django.db import migrations
3+
from django.db import models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
("adserver", "0091_publisher_group_default"),
10+
]
11+
12+
operations = [
13+
migrations.AddField(
14+
model_name="historicalpublisher",
15+
name="github_sponsors_name",
16+
field=models.CharField(
17+
blank=True,
18+
default=None,
19+
max_length=200,
20+
null=True,
21+
verbose_name="GitHub sponsors name",
22+
),
23+
),
24+
migrations.AddField(
25+
model_name="publisher",
26+
name="github_sponsors_name",
27+
field=models.CharField(
28+
blank=True,
29+
default=None,
30+
max_length=200,
31+
null=True,
32+
verbose_name="GitHub sponsors name",
33+
),
34+
),
35+
migrations.AlterField(
36+
model_name="historicalpublisher",
37+
name="payout_method",
38+
field=models.CharField(
39+
blank=True,
40+
choices=[
41+
("stripe", "Stripe (Bank transfer, debit card)"),
42+
("paypal", "PayPal"),
43+
("opencollective", "Open Collective"),
44+
("github", "GitHub sponsors"),
45+
("other", "Other"),
46+
],
47+
default=None,
48+
max_length=100,
49+
null=True,
50+
),
51+
),
52+
migrations.AlterField(
53+
model_name="historicalpublisherpayout",
54+
name="method",
55+
field=models.CharField(
56+
blank=True,
57+
choices=[
58+
("stripe", "Stripe (Bank transfer, debit card)"),
59+
("paypal", "PayPal"),
60+
("opencollective", "Open Collective"),
61+
("github", "GitHub sponsors"),
62+
("other", "Other"),
63+
],
64+
default=None,
65+
max_length=100,
66+
null=True,
67+
),
68+
),
69+
migrations.AlterField(
70+
model_name="publisher",
71+
name="payout_method",
72+
field=models.CharField(
73+
blank=True,
74+
choices=[
75+
("stripe", "Stripe (Bank transfer, debit card)"),
76+
("paypal", "PayPal"),
77+
("opencollective", "Open Collective"),
78+
("github", "GitHub sponsors"),
79+
("other", "Other"),
80+
],
81+
default=None,
82+
max_length=100,
83+
null=True,
84+
),
85+
),
86+
migrations.AlterField(
87+
model_name="publisherpayout",
88+
name="method",
89+
field=models.CharField(
90+
blank=True,
91+
choices=[
92+
("stripe", "Stripe (Bank transfer, debit card)"),
93+
("paypal", "PayPal"),
94+
("opencollective", "Open Collective"),
95+
("github", "GitHub sponsors"),
96+
("other", "Other"),
97+
],
98+
default=None,
99+
max_length=100,
100+
null=True,
101+
),
102+
),
103+
]

adserver/models.py

+10
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
from .constants import OFFERS
4747
from .constants import PAID
4848
from .constants import PAID_CAMPAIGN
49+
from .constants import PAYOUT_GITHUB
4950
from .constants import PAYOUT_OPENCOLLECTIVE
5051
from .constants import PAYOUT_PAYPAL
5152
from .constants import PAYOUT_STATUS
@@ -418,6 +419,13 @@ class Publisher(TimeStampedModel, IndestructibleModel):
418419
paypal_email = models.EmailField(
419420
_("PayPal email address"), blank=True, null=True, default=None
420421
)
422+
github_sponsors_name = models.CharField(
423+
_("GitHub sponsors name"),
424+
max_length=200,
425+
blank=True,
426+
null=True,
427+
default=None,
428+
)
421429

422430
# Record additional details to the offer for this publisher
423431
# This can be used for publishers where their traffic needs more scrutiny
@@ -527,6 +535,8 @@ def payout_url(self):
527535
return f"https://opencollective.com/{self.open_collective_name}"
528536
if self.payout_method == PAYOUT_PAYPAL and self.paypal_email:
529537
return "https://www.paypal.com/myaccount/transfer/homepage/pay"
538+
if self.payout_method == PAYOUT_GITHUB and self.github_sponsors_name:
539+
return f"https://github.com/sponsors/{self.github_sponsors_name}"
530540
return ""
531541

532542
def get_daily_earn(self):

0 commit comments

Comments
 (0)