From 44f88730f16d2d2e45422d98a50ca1ffae9cec7b Mon Sep 17 00:00:00 2001 From: Bibiana Cristofol Amat Date: Thu, 14 May 2026 12:10:48 +0100 Subject: [PATCH] api: add "/v1/org/funder" https://github.com/ThreeSixtyGiving/datastore/issues/301 --- datastore/api/org/api.py | 11 +++++++++++ datastore/api/urls.py | 5 +++++ datastore/tests/test_org_api.py | 25 +++++++++++++++++++++++++ 3 files changed, 41 insertions(+) diff --git a/datastore/api/org/api.py b/datastore/api/org/api.py index eb02f9bb..2cca850c 100644 --- a/datastore/api/org/api.py +++ b/datastore/api/org/api.py @@ -31,6 +31,17 @@ def get_queryset(self): ) +class FunderListView(generics.ListAPIView): + throttle_classes = [ScopedRateThrottle] + throttle_scope = "public-api-org-list" + serializer_class = serializers.OrganisationListSerializer + pagination_class = OrganisationsPagination + + def get_queryset(self): + fields = ["org_id", "name"] + return db.Funder.objects.order_by().values(*fields) + + class OrganisationDetailView(generics.RetrieveAPIView): """ Get details about the given organisation. diff --git a/datastore/api/urls.py b/datastore/api/urls.py index e36d1595..b6545dc9 100644 --- a/datastore/api/urls.py +++ b/datastore/api/urls.py @@ -65,6 +65,11 @@ api.org.api.OrganisationGrantsReceivedView.as_view(), name="organisation-grants-received", ), + path( + "v1/org/funder/", + api.org.api.FunderListView.as_view(), + name="funder-list", + ), path( "v1/org//", api.org.api.OrganisationDetailView.as_view(), diff --git a/datastore/tests/test_org_api.py b/datastore/tests/test_org_api.py index 26de5f50..7d33b81a 100644 --- a/datastore/tests/test_org_api.py +++ b/datastore/tests/test_org_api.py @@ -460,3 +460,28 @@ def test_non_existent_org_grants_received(self): ) self.assertEqual(response.status_code, 404) + + # + # Funder List + # + + def test_funder_list(self): + """Check that the given Funder Org is in the Funder List""" + + data = self.client.get( + "/api/v1/org/funder/", + headers={"accept": "application/json"}, + ).json() + + self.assertGreaterEqual(data["count"], 1) + + expected_entry = { + "org_id": self.funder_org_id, + "name": self.funder_org_name, + "self": "http://testserver" + + reverse_lazy( + "api:organisation-detail", kwargs={"org_id": self.funder_org_id} + ), + } + + self.assertIn(expected_entry, data["results"])