clear credentials of a list of mails (post)
authorCiro Scognamiglio <ciro.scognamiglio@cslash.net>
Fri, 25 Jul 2014 15:43:00 +0000 (17:43 +0200)
committerCiro Scognamiglio <ciro.scognamiglio@cslash.net>
Fri, 25 Jul 2014 15:43:00 +0000 (17:43 +0200)
myslice/urls.py
rest/credentials.py

index a4dcf96..51475ad 100644 (file)
@@ -80,7 +80,7 @@ urls = [
     (r'^update/(?P<object_type>[^/]+)/(?P<object_name>[^/]+)?/?$', 'rest.update.dispatch'),
     (r'^create/(?P<object_type>[^/]+)/(?P<object_name>[^/]+)?/?$', 'rest.create.dispatch'),
     (r'^delete/(?P<object_type>[^/]+)/(?P<object_name>[^/]+)?/?$', 'rest.delete.dispatch'),
-    (r'^credentials/(?P<action>[^/]+)/(?P<object>[^/]+)?/?$', 'rest.credentials.dispatch'),
+    (r'^credentials/(?P<action>[^/]+)/?$', 'rest.credentials.dispatch'),
     #
     # REST monitoring
     (r'^monitor/sfa/getversion/?$', 'rest.monitor.sfaGetVersion'),
index fa1f9b8..d63babf 100644 (file)
@@ -2,16 +2,20 @@ from django.http                    import HttpResponse
 from portal.actions import clear_user_creds
 import json
 
-def dispatch(request, action, object):
+def dispatch(request, action):
     
     if (action == 'clear') :
-        try :
-            res = clear_user_creds(request, object)
-        except :
-            pass
+        res=[]
+        emails = request.POST.getlist('emails[]')
+        if emails :
+            for email in emails :
+                try :
+                    res.append(clear_user_creds(request, email))
+                except :
+                    pass
         
-        if res is not None :
-            ret = { "ret" : 1, "email" : res }
+        if not res :
+            ret = { "ret" : 1, "emails" : res }
         else :
             ret = { "ret" : 0 }