mirror of
https://github.com/TrentSPalmer/trentpalmerdotorg.git
synced 2024-12-22 04:52:49 -08:00
add feed_list_api
This commit is contained in:
parent
8b63db59a7
commit
493189ab01
@ -20,4 +20,5 @@ urlpatterns = [
|
||||
path('rss/<str:slug>.xml', AudioRssFeed(), name='rss'),
|
||||
path('feed/<str:pk>/<str:slug>', views.feed, name='feed'),
|
||||
path('episode/<str:pk>/<str:slug>', views.episode, name='episode'),
|
||||
path('feed-list-api/', views.feed_list_api, name='feed_list_api')
|
||||
]
|
||||
|
@ -1,4 +1,5 @@
|
||||
from django.shortcuts import render, reverse
|
||||
from django.http import JsonResponse
|
||||
from django.contrib.sites.shortcuts import get_current_site
|
||||
from .models import Feed, Episode
|
||||
from tp.settings import IMAGES_URL, MP3_URL
|
||||
@ -46,3 +47,15 @@ def feeds(request):
|
||||
request,
|
||||
'audio/feeds.html',
|
||||
{'feeds': feeds, 'IMAGES_URL': IMAGES_URL})
|
||||
|
||||
|
||||
def feed_list_api(request):
|
||||
feeds = Feed.objects.all().order_by('created_on')
|
||||
result = []
|
||||
for feed in feeds:
|
||||
result.append({
|
||||
'title': feed.title,
|
||||
'read_by': feed.user.username,
|
||||
'rss_feed': f'{get_current_site(request)}' + reverse('audio:rss', kwargs={'slug': feed.slug})
|
||||
})
|
||||
return JsonResponse(result, safe=False)
|
||||
|
Loading…
Reference in New Issue
Block a user