Skip to content

Commit

Permalink
Added valdidation checks on playlist update
Browse files Browse the repository at this point in the history
  • Loading branch information
Henrik Berggren committed Dec 6, 2008
1 parent ee295ad commit 96b371a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
10 changes: 8 additions & 2 deletions the-cloud-player.py
Expand Up @@ -82,7 +82,12 @@ def post(self):
library_item = playlist.library_item_for_current_user()

if method == "PUT":


if library_item.is_owner: #A bit special, does not need version handling
if(self.request.get('name') && len(self.request.get('name')) > 0 ):
playlist.name = utils.strip_html(self.request.get('name'))
playlist.put()

if(int(self.request.get('version')) == playlist.version):
if(self.request.get('position')): #Rights: Can always update this
current_user.re_sort_playlists(library_item, int(self.request.get('position')))
Expand All @@ -97,7 +102,8 @@ def post(self):

if (playlist.collaborative or library_item.is_owner): #Rights: Owner or collaborators can update this
if(self.request.get('tracks')):
playlist.tracks = self.request.get('tracks')
playlist.tracks = self.request.get('tracks')

playlist.version += 1
playlist.put()

Expand Down
6 changes: 5 additions & 1 deletion utils.py
Expand Up @@ -5,6 +5,7 @@
import models
from datetime import datetime
import os
import re

def init_new_user():
google_user = users.get_current_user()
Expand Down Expand Up @@ -107,4 +108,7 @@ def parse_smart_filters(playlist, request):
playlist.duration_from = int(request.get('duration_from'))
if(request.get('duration_to')):
playlist.duration_to = int(request.get('duration_to'))
return playlist
return playlist

def strip_html(s):
return re.replace('<.*?>', '', s)

0 comments on commit 96b371a

Please sign in to comment.