From 818e16a2ce581e94e99fd60e342990d9f0f49f47 Mon Sep 17 00:00:00 2001 From: yomguy Date: Tue, 15 Mar 2011 18:30:05 +0100 Subject: [PATCH] add make_playlist_current rpc method --- telemeta/web/base.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/telemeta/web/base.py b/telemeta/web/base.py index f555048f..fb0a6bce 100644 --- a/telemeta/web/base.py +++ b/telemeta/web/base.py @@ -785,10 +785,7 @@ class WebView(object): m.name = playlist['name'] m.description = playlist['description'] m.author = request.user - if playlist['is_current'] == 'True': - m.is_current = True - else: - m.is_current = False + m.is_current = False m.save() else: raise 'Error : Bad playlist dictionnary' @@ -797,6 +794,17 @@ class WebView(object): def del_playlist(request, public_id): m = Playlist.objects.get(public_id=public_id) m.delete() + + @jsonrpc_method('telemeta.make_playlist_current') + def make_playlist_current(request, public_id): + playlists = Playlist.objects.filter(author=request.user) + for playlist in playlists: + if playlist.is_current: + playlist.is_current = False + playlist.save() + m = Playlist.objects.get(public_id=public_id) + m.is_current = True + m.save() def get_playlists(self, request): user_playlists = Playlist.objects.filter(author=request.user) -- 2.39.5