From 8adc81a69a69a11b8ae132c604107495fda2f99d Mon Sep 17 00:00:00 2001 From: Jacob Kaplan-Moss Date: Wed, 20 Nov 2024 08:49:37 -0800 Subject: [PATCH 1/5] Sketch out a funding.json --- .../static/.well-known/funding-manifest-urls | 1 + djangoproject/urls/www.py | 2 + fundraising/views.py | 115 +++++++++++++++++- 3 files changed, 117 insertions(+), 1 deletion(-) create mode 100644 djangoproject/static/.well-known/funding-manifest-urls diff --git a/djangoproject/static/.well-known/funding-manifest-urls b/djangoproject/static/.well-known/funding-manifest-urls new file mode 100644 index 000000000..a287b161e --- /dev/null +++ b/djangoproject/static/.well-known/funding-manifest-urls @@ -0,0 +1 @@ +https://djangoproject.com/funding.json \ No newline at end of file diff --git a/djangoproject/urls/www.py b/djangoproject/urls/www.py index 22edfa736..4b82bb7d9 100644 --- a/djangoproject/urls/www.py +++ b/djangoproject/urls/www.py @@ -15,6 +15,7 @@ from blog.sitemaps import WeblogSitemap from foundation.feeds import FoundationMinutesFeed from foundation.views import CoreDevelopers +from fundraising.views import funding_json admin.autodiscover() @@ -98,6 +99,7 @@ path("foundation/django_core/", CoreDevelopers.as_view()), path("foundation/minutes/", include("foundation.urls.meetings")), path("foundation/", include("members.urls")), + path("funding.json", funding_json, name="funding-json"), # see https://floss.fund path("fundraising/", include("fundraising.urls")), # Used by docs search suggestions re_path( diff --git a/fundraising/views.py b/fundraising/views.py index 7b657044d..c6f529542 100644 --- a/fundraising/views.py +++ b/fundraising/views.py @@ -16,8 +16,10 @@ from django.views.decorators.csrf import csrf_exempt from django.views.decorators.http import require_POST +from members.models import CORPORATE_MEMBERSHIP_AMOUNTS + from .forms import DjangoHeroForm, DonationForm, PaymentForm -from .models import DjangoHero, Donation, Payment, Testimonial +from .models import INTERVAL_CHOICES, DjangoHero, Donation, Payment, Testimonial logger = logging.getLogger(__name__) @@ -338,3 +340,114 @@ def checkout_session_completed(self): ) return HttpResponse(status=204) + + +def funding_json(request): + """ + Generate a funding.json -- see https://floss.fund/funding-manifest/ + """ + funding = { + "version": "v1.0.0", + "entity": { + "type": "organisation", + "role": "owner", + "name": "Django Software Foundation", + "email": "foundation@djangoproject.com", + "description": "Development of Django is supported by the Django Software Foundation, a 501(c)(3) non-profit.", + "webpageUrl": { + "url": "http://djangoproject.com/foundation", + }, + }, + "projects": [ + { + "guid": "django", + "name": "Django", + "description": "Django is a Python web framework that makes it possible to build better web apps quickly and with less code", + "webpageUrl": { + "url": "http://djangoproject.com/", + }, + "repositoryUrl": { + "url": "http://github.com/django/django", + "wellKnown": "http://github.com/django/django/blob/main/static/.well-known/funding-manifest-urls", + }, + "licenses": ["spdx:BSD-3-Clause"], + "tags": ["python", "web", "django"], + } + ], + "funding": { + "channels": [ + { + "guid": "stripe", + "type": "payment-provider", + "address": "https://www.djangoproject.com/fundraising/", + "description": "Pay with your debit/credit card, and set up recurring support.", + }, + { + "guid": "github-sponsors", + "type": "payment-provider", + "address": "https://github.com/sponsors/django", + "description": "Donate via GitHub sponsors", + }, + { + "guid": "bank", + "type": "bank", + "description": "Pay via bank transfer or check - contact foundation@djangoproject.com for details.", + }, + ], + "plans": [], + }, + } + + # translate our keys for frequency into the ones understood by funding.json + frequency_translation = { + "onetime": "one-time", + "quarterly": "other", + } + + # Pay-what-you-want individual funding levels + for frequency, title in INTERVAL_CHOICES: + funding["funding"]["plans"].append( + { + "guid": f"individual-{frequency}", + "status": "active", + "name": f"Django Hero - {title}", + "description": f"Support Django as an individual, - {title.lower()}", + "amount": 0, + "currency": "USD", + "frequency": frequency_translation.get(frequency, frequency), + "channels": [c["guid"] for c in funding["funding"]["channels"]], + } + ) + + # "leadership level" donation + funding["funding"]["plans"].append( + { + "guid": "individual-leadership", + "status": "active", + "name": "Django Hero - Leadership Level", + "description": "Django Hero - Leadership Level - Donate $1,000/yr or more", + "amount": 1000, + "currency": "USD", + "frequency": "yearly", + "channels": [c["guid"] for c in funding["funding"]["channels"]], + } + ) + + # corporate sponsorships + for level, amount in CORPORATE_MEMBERSHIP_AMOUNTS.items(): + funding["funding"]["plans"].append( + { + "guid": f"corporate-{level}", + "status": "active", + "name": f"Corporate Sponsorship - {level.title()}", + "description": f"Corporate Sponsoreship - {level.title()}", + "amount": amount, + "currency": "USD", + "frequency": "yearly", + "channels": [c["guid"] for c in funding["funding"]["channels"]], + } + ) + + # TODO: it'd be nice to do history. We do have the data, but not in the dp.com app. + + return JsonResponse(funding) From cda36f2769e9320abb38a5d30c1e5571b52d18c5 Mon Sep 17 00:00:00 2001 From: Jacob Kaplan-Moss Date: Wed, 20 Nov 2024 10:44:22 -0800 Subject: [PATCH 2/5] =?UTF-8?q?=F0=9F=9A=A8=20fix=20line=20length=20errors?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fundraising/views.py | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/fundraising/views.py b/fundraising/views.py index c6f529542..a2bb82cf3 100644 --- a/fundraising/views.py +++ b/fundraising/views.py @@ -353,7 +353,10 @@ def funding_json(request): "role": "owner", "name": "Django Software Foundation", "email": "foundation@djangoproject.com", - "description": "Development of Django is supported by the Django Software Foundation, a 501(c)(3) non-profit.", + "description": ( + "Development of Django is supported by the Django Software Foundation, " + "a 501(c)(3) non-profit." + ), "webpageUrl": { "url": "http://djangoproject.com/foundation", }, @@ -362,13 +365,19 @@ def funding_json(request): { "guid": "django", "name": "Django", - "description": "Django is a Python web framework that makes it possible to build better web apps quickly and with less code", + "description": ( + "Django is a Python web framework that makes it possible to build " + "better web apps quickly and with less code" + ), "webpageUrl": { "url": "http://djangoproject.com/", }, "repositoryUrl": { "url": "http://github.com/django/django", - "wellKnown": "http://github.com/django/django/blob/main/static/.well-known/funding-manifest-urls", + "wellKnown": ( + "http://github.com/django/django/blob/main/static/" + ".well-known/funding-manifest-urls" + ), }, "licenses": ["spdx:BSD-3-Clause"], "tags": ["python", "web", "django"], @@ -380,7 +389,10 @@ def funding_json(request): "guid": "stripe", "type": "payment-provider", "address": "https://www.djangoproject.com/fundraising/", - "description": "Pay with your debit/credit card, and set up recurring support.", + "description": ( + "Pay with your debit/credit card, " + "and set up recurring support." + ), }, { "guid": "github-sponsors", @@ -391,7 +403,10 @@ def funding_json(request): { "guid": "bank", "type": "bank", - "description": "Pay via bank transfer or check - contact foundation@djangoproject.com for details.", + "description": ( + "Pay via bank transfer or check - " + "contact foundation@djangoproject.com for details." + ), }, ], "plans": [], From 671c4de3aa1457dd1accdf4b0c6a3c1afdbb74e5 Mon Sep 17 00:00:00 2001 From: Jacob Kaplan-Moss Date: Wed, 20 Nov 2024 13:51:29 -0800 Subject: [PATCH 3/5] =?UTF-8?q?=F0=9F=90=9B=20fix=20some=20domains?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Baptiste Mispelon --- fundraising/views.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/fundraising/views.py b/fundraising/views.py index a2bb82cf3..47bb4a543 100644 --- a/fundraising/views.py +++ b/fundraising/views.py @@ -358,7 +358,7 @@ def funding_json(request): "a 501(c)(3) non-profit." ), "webpageUrl": { - "url": "http://djangoproject.com/foundation", + "url": "https://www.djangoproject.com/foundation", }, }, "projects": [ @@ -370,12 +370,12 @@ def funding_json(request): "better web apps quickly and with less code" ), "webpageUrl": { - "url": "http://djangoproject.com/", + "url": "https://www.djangoproject.com/", }, "repositoryUrl": { - "url": "http://github.com/django/django", + "url": "https://github.com/django/django", "wellKnown": ( - "http://github.com/django/django/blob/main/static/" + "https://github.com/django/django/blob/main/static/" ".well-known/funding-manifest-urls" ), }, From 2ac9185435c727e57d58680ba42bd990384ee524 Mon Sep 17 00:00:00 2001 From: Jacob Kaplan-Moss Date: Wed, 20 Nov 2024 13:52:12 -0800 Subject: [PATCH 4/5] =?UTF-8?q?=F0=9F=90=9B=20use=20correct=20www=20subdom?= =?UTF-8?q?ain?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- djangoproject/static/.well-known/funding-manifest-urls | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/djangoproject/static/.well-known/funding-manifest-urls b/djangoproject/static/.well-known/funding-manifest-urls index a287b161e..ece2fc5fd 100644 --- a/djangoproject/static/.well-known/funding-manifest-urls +++ b/djangoproject/static/.well-known/funding-manifest-urls @@ -1 +1 @@ -https://djangoproject.com/funding.json \ No newline at end of file +https://www.djangoproject.com/funding.json From 1dd15cf66db7c7dbb11872bb472571cabdba0adb Mon Sep 17 00:00:00 2001 From: Jacob Kaplan-Moss Date: Wed, 20 Nov 2024 13:52:33 -0800 Subject: [PATCH 5/5] =?UTF-8?q?=F0=9F=94=A5=20remove=20TODO=20(will=20move?= =?UTF-8?q?=20it=20to=20a=20ticket)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fundraising/views.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/fundraising/views.py b/fundraising/views.py index 47bb4a543..e22dc16f1 100644 --- a/fundraising/views.py +++ b/fundraising/views.py @@ -463,6 +463,4 @@ def funding_json(request): } ) - # TODO: it'd be nice to do history. We do have the data, but not in the dp.com app. - return JsonResponse(funding)