Permalink
Browse files

Added valdidation checks on playlist update

  • Loading branch information...
1 parent ee295ad commit 96b371a884d29e93654bc7bd69389c93f35dbeb6 Henrik Berggren committed Dec 6, 2008
Showing with 13 additions and 3 deletions.
  1. +8 −2 the-cloud-player.py
  2. +5 −1 utils.py
View
@@ -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')))
@@ -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()
View
@@ -5,6 +5,7 @@
import models
from datetime import datetime
import os
+import re
def init_new_user():
google_user = users.get_current_user()
@@ -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.