Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Added valdidation checks on playlist update

  • Loading branch information...
commit 96b371a884d29e93654bc7bd69389c93f35dbeb6 1 parent ee295ad
authored December 06, 2008
10  the-cloud-player.py
@@ -82,7 +82,12 @@ def post(self):
82 82
     library_item = playlist.library_item_for_current_user()
83 83
     
84 84
     if method == "PUT":
85  
-  
  85
+    
  86
+      if library_item.is_owner: #A bit special, does not need version handling
  87
+        if(self.request.get('name') && len(self.request.get('name')) > 0  ):
  88
+          playlist.name = utils.strip_html(self.request.get('name'))
  89
+          playlist.put()
  90
+      
86 91
       if(int(self.request.get('version')) == playlist.version):
87 92
         if(self.request.get('position')): #Rights: Can always update this
88 93
           current_user.re_sort_playlists(library_item, int(self.request.get('position')))
@@ -97,7 +102,8 @@ def post(self):
97 102
 
98 103
         if (playlist.collaborative or library_item.is_owner): #Rights: Owner or collaborators can update this
99 104
           if(self.request.get('tracks')):
100  
-            playlist.tracks = self.request.get('tracks')        
  105
+            playlist.tracks = self.request.get('tracks')
  106
+            
101 107
           playlist.version += 1
102 108
           playlist.put()
103 109
         
6  utils.py
@@ -5,6 +5,7 @@
5 5
 import models
6 6
 from datetime import datetime
7 7
 import os
  8
+import re
8 9
 
9 10
 def init_new_user():
10 11
   google_user = users.get_current_user()
@@ -107,4 +108,7 @@ def parse_smart_filters(playlist, request):
107 108
     playlist.duration_from = int(request.get('duration_from'))
108 109
   if(request.get('duration_to')):
109 110
     playlist.duration_to = int(request.get('duration_to'))
110  
-  return playlist
  111
+  return playlist
  112
+
  113
+def strip_html(s):
  114
+  return re.replace('<.*?>', '', s)    

0 notes on commit 96b371a

Please sign in to comment.
Something went wrong with that request. Please try again.