mirror of
https://github.com/fergalmoran/dss.api.git
synced 2025-12-22 09:18:13 +00:00
Done!
This commit is contained in:
@@ -321,6 +321,7 @@ class UserProfileSerializer(serializers.ModelSerializer):
|
|||||||
'profile_image_medium',
|
'profile_image_medium',
|
||||||
'profile_image_header',
|
'profile_image_header',
|
||||||
'slug',
|
'slug',
|
||||||
|
'uid',
|
||||||
'likes',
|
'likes',
|
||||||
'mix_count',
|
'mix_count',
|
||||||
'isme',
|
'isme',
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ urlpatterns = patterns(
|
|||||||
(r'^_embed/', include('spa.embedding.urls')),
|
(r'^_embed/', include('spa.embedding.urls')),
|
||||||
(r'^__redir/blog/', include('spa.blog.urls')),
|
(r'^__redir/blog/', include('spa.blog.urls')),
|
||||||
(r'^__redir/social/', include('spa.social.urls')),
|
(r'^__redir/social/', include('spa.social.urls')),
|
||||||
|
(r'^podcasts/', include('spa.podcast.urls')),
|
||||||
(r'^podcast/', include('spa.podcast.urls')),
|
(r'^podcast/', include('spa.podcast.urls')),
|
||||||
url(r'', include('user_sessions.urls', 'user_sessions')),
|
url(r'', include('user_sessions.urls', 'user_sessions')),
|
||||||
url(r'^', include('api.urls')),
|
url(r'^', include('api.urls')),
|
||||||
|
|||||||
@@ -3,4 +3,7 @@ from django.conf.urls import patterns, url
|
|||||||
urlpatterns = patterns(
|
urlpatterns = patterns(
|
||||||
'',
|
'',
|
||||||
url(r'^(?P<uid>[\w\d_.-]+)/favourites/?$', 'spa.podcast.views.favourites', name='podast_favourites_slug'),
|
url(r'^(?P<uid>[\w\d_.-]+)/favourites/?$', 'spa.podcast.views.favourites', name='podast_favourites_slug'),
|
||||||
|
url(r'^(?P<uid>[\w\d_.-]+)/following/?$', 'spa.podcast.views.following', name='podast_following_slug'),
|
||||||
|
url(r'^(?P<slug>[\w\d_.-]+)/?$', 'spa.podcast.views.user', name='podast_user_slug'),
|
||||||
|
url(r'^/?$', 'spa.podcast.views.featured', name='podast_featured_slug'),
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -3,28 +3,56 @@ from django.http import HttpResponse
|
|||||||
from django.shortcuts import render_to_response
|
from django.shortcuts import render_to_response
|
||||||
from django.template import RequestContext
|
from django.template import RequestContext
|
||||||
|
|
||||||
from spa.models import UserProfile
|
from spa.models import UserProfile, Mix
|
||||||
|
|
||||||
|
|
||||||
def favourites(request, uid):
|
def _get_user(uid):
|
||||||
try:
|
try:
|
||||||
user = UserProfile.objects.order_by('-id').get(uid=uid)
|
user = UserProfile.objects.order_by('-id').get(uid=uid)
|
||||||
except UserProfile.DoesNotExist:
|
except UserProfile.DoesNotExist:
|
||||||
raise Http404("User does not exist")
|
raise Http404("User does not exist")
|
||||||
|
return user
|
||||||
fav_list = user.favourites.all()
|
|
||||||
return _render_podcast(request, user, fav_list)
|
|
||||||
|
|
||||||
|
|
||||||
def _render_podcast(request, user, list):
|
def featured(request):
|
||||||
|
podcast_list = Mix.objects.order_by('-id').filter(is_private=False, is_featured=True)
|
||||||
|
return _render_podcast(request, 'Deep South Sounds', 'DSS Favourites',
|
||||||
|
'All your favourites on Deep South Sounds', podcast_list)
|
||||||
|
|
||||||
|
|
||||||
|
def user(request, slug):
|
||||||
|
user = UserProfile.objects.get(slug=slug)
|
||||||
|
podcast_list = Mix.objects.order_by('-id').filter(is_private=False, user__slug=slug)
|
||||||
|
return _render_podcast(request, user.first_name, 'DSS {0}'.format(user.display_name),
|
||||||
|
'All of {0}\'s mixes on Deep South Sounds'.format(user.display_name), podcast_list,
|
||||||
|
image=user.get_sized_avatar_image(1400, 1400))
|
||||||
|
|
||||||
|
|
||||||
|
def favourites(request, uid):
|
||||||
|
user = _get_user(uid)
|
||||||
|
podcast_list = user.favourites.all()
|
||||||
|
return _render_podcast(request, user.first_name, 'DSS Favourites',
|
||||||
|
'All your favourites on Deep South Sounds', podcast_list)
|
||||||
|
|
||||||
|
|
||||||
|
def following(request, uid):
|
||||||
|
user = _get_user(uid)
|
||||||
|
podcast_list = Mix.objects.order_by('-id').filter(is_private=False, user__in=user.following.all())
|
||||||
|
return _render_podcast(request, user.first_name, 'DSS Following',
|
||||||
|
'Mixes from people you follow on Deep South Sounds', podcast_list)
|
||||||
|
|
||||||
|
|
||||||
|
def _render_podcast(request, user, title, description, podcast_list,
|
||||||
|
image='https://dsscdn2.blob.core.windows.net/static/podcast_logo.png'):
|
||||||
context = {
|
context = {
|
||||||
'title': 'DSS Favourites',
|
'title': title,
|
||||||
'description': 'All your favourites on Deep South Sounds',
|
'description': description,
|
||||||
'link': 'https://deepsouthsounds.com/',
|
'link': 'https://deepsouthsounds.com/',
|
||||||
'user': user.first_name,
|
'image': image,
|
||||||
|
'user': user,
|
||||||
'summary': 'Deep South Sounds is a collective of like minded house heads from Ireland"s Deep South',
|
'summary': 'Deep South Sounds is a collective of like minded house heads from Ireland"s Deep South',
|
||||||
'last_build_date': list[0].upload_date,
|
'last_build_date': podcast_list[0].upload_date,
|
||||||
'objects': list,
|
'objects': podcast_list,
|
||||||
}
|
}
|
||||||
response = render_to_response(
|
response = render_to_response(
|
||||||
'podcast/feed.xml',
|
'podcast/feed.xml',
|
||||||
|
|||||||
@@ -24,7 +24,7 @@
|
|||||||
|
|
||||||
<itunes:explicit>No</itunes:explicit>
|
<itunes:explicit>No</itunes:explicit>
|
||||||
|
|
||||||
<itunes:image href="https://dsscdn2.blob.core.windows.net/static/podcast_logo.png"/>
|
<itunes:image href="{{ image }}"/>
|
||||||
|
|
||||||
<itunes:category text="Technology">
|
<itunes:category text="Technology">
|
||||||
<itunes:category text="Podcasting"/>
|
<itunes:category text="Podcasting"/>
|
||||||
|
|||||||
Reference in New Issue
Block a user