Skip to content

Commit

Permalink
add canonical organisation json output
Browse files Browse the repository at this point in the history
  • Loading branch information
drkane committed Nov 13, 2020
1 parent 831b616 commit cc9d578
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions ftc/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
path("source/<str:source>", views.orgid_type, name="orgid_source"),
path("scrapes/feed.rss", feeds.ScrapesFeedRSS()),
path("scrapes/feed.atom", feeds.ScrapesFeedAtom()),
path("<path:org_id>/canonical.json", views.get_orgid_canon),
path("<path:org_id>.json", views.get_orgid, {"filetype": "json"}),
path("<path:org_id>.html", views.get_orgid, {"filetype": "html"}),
path(
Expand Down
11 changes: 11 additions & 0 deletions ftc/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,17 @@ def get_orgid(request, org_id, filetype="html", preview=False, as_charity=False)
)


@xframe_options_exempt
def get_orgid_canon(request, org_id):

related_orgs = list(Organisation.objects.filter(linked_orgs__contains=[org_id]))
if not related_orgs:
raise Http404("No Organisation found.")
related_orgs = RelatedOrganisation(related_orgs)

return JsonResponse(related_orgs.to_json())


def get_random_org(request):
"""Get a random charity record"""
# filetype = request.GET.get("filetype", "html")
Expand Down

0 comments on commit cc9d578

Please sign in to comment.