Merge branch 'fibre' of ssh://git.onelab.eu/git/myslice into fibre
[unfold.git] / rest / credentials.py
1 from django.http                    import HttpResponse
2 from portal.actions import clear_user_creds
3 import json
4
5 def dispatch(request, action):
6     
7     if (action == 'clear') :
8         res=[]
9         emails = request.POST.getlist('emails[]')
10         if not emails:
11             emails = request.GET.getlist('emails[]')
12         import pdb
13         pdb.set_trace()
14         if emails :
15             for email in emails :
16                 try :
17                     clear = clear_user_creds(request, email)
18                     if clear is not None:
19                         res.append(clear)
20                 except :
21                     pass
22         
23         if not res :
24             ret = { "ret" : 1, "emails" : emails }
25         else :
26             ret = { "ret" : 0 }
27     
28     return HttpResponse(json.dumps(ret), content_type="application/json")